Make user fill parameters in a defined order? - abap

I have a selection-screen block with two parameters (p1 & p2). I want to force the user to fill the p1 first and then the p2...
Someone can help me with this ?
Thanks

I would greyout the 2nd parameter (input = 0) and display a hint to the right that Parameter 1 needs to bw filled first.

Related

Unhide a column in ALV grid

I have two SAP systems with the same program.
The column Nome 2 is displayed in the ALV grid of the system1 but in the ALV grid of the system2 is hidden and when select the details you could see the Nome 2 value in both sistems.
The program uses field catalog to pass a list of fields to display in ALV, and also uses the function 'REUSE_ALV_GRID_DISPLAY'.
I would be very pleased if someone have any suggestions that could solve it.
Regards,
Nataly
Check the no-out property of fieldcatalog in system 1. It seems to be enabled there:
You suppose to search lines like this:
IF T_FIELDCAT-FIELDNAME = 'NOME1'.
T_FIELDCAT-NO_OUT = 'X'.
MODIFY T_FIELDCAT INDEX sy-tabix.
ENDLOOP.
Remove NO-OUT line and voilá!

How to make a search helper for region filtering from a preselected country

I have a selection screen like below code and I want to make a search helper to filter regions from selected value in P_LAND1:
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS: P_LAND1 TYPE LAND1,
P_BLAND TYPE BLAND.
SELECTION-SCREEN END OF BLOCK B1.
Simpliest way is to reference the fields to the table-field, where they are maintained in SAP (keeping in mind that an input help is defined as well, but you can check it in SE11, not an issue in this case). For countries this will be table T005, for regions table T005S (pls. note the field is not regio, but bland):
PARAMETERS: p_land1 TYPE t005-land1,
p_bland TYPE t005s-bland.
Also note, for the region by pressing F4 all possible values will be displayed, not just the regions of the country you entered one field above. If you need a user friendly solution, it has to be coded separately (in event AT SELECTION-SCREEN on VALUE-REQUEST FOR ...)

Dynamically fill selection-screen parameter on change

Suppose I have a selection-screen block with two parameters. I want to dynamically fill the second parameter based on what the user inputs in the first, for instance by querying a table to find the expected value for the key field in parameter 1.
As an example, say I have a program that does something for a combination of order number (p_aufnr) and WBS element (p_wbs). Instead of asking the user to provide both, I can determine one of them from the PSPEL field on the AUFK table. However, I still want to show this field to the user after he inputs his order number so he can verify that the WBS element is correct.
I've managed to do this by using the AT SELECTION SCREEN ON p_aufnr event to assign a value to p_wbs. This event is processed when the user presses enter. However, I can only ever get it to work once. So if the user enters an order number, realises from the retrieved WBS element that he made a mistake and changes it, the second parameter never changes. Even though the AT SELECTION SCREEN event is processed in the debugger, the parameter is not updated.
Am I not supposed to use this event for my scenario? If so, how would I then implement this sort of dynamic selection screen?
Forgot to add a code sample. The following report illustrates my issue: after entering a value in p_netw and pressing enter, p_wbs is filled with the value 1. However, if you press enter again the AT SELECTION-SCREEN ON routine is processed but the value for p_wbs is not updated, while lv_count is.
DATA: lv_count TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK main.
PARAMETERS: p_netw TYPE aufnr OBLIGATORY MODIF ID auf.
PARAMETERS: p_wbs TYPE i MODIF ID psp.
SELECTION-SCREEN END OF BLOCK main.
AT SELECTION-SCREEN ON p_netw.
ADD 1 TO lv_count.
p_wbs = lv_count.
START-OF-SELECTION.
PERFORM main.
FORM main.
WRITE: 'The value reached ', lv_count.
ENDFORM.
Apparently the data is not written back to the screen if you update the field in the field-specific block. If you move the field update from AT SELECTION-SCREEN ON p_netw to the global AT SELECTION-SCREEN event, it works. Don't ask me why, though - this seems to a case of undocumented system behaviour...
DATA: lv_count TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK main.
PARAMETERS: p_netw TYPE aufnr OBLIGATORY MODIF ID auf.
PARAMETERS: p_wbs TYPE i MODIF ID psp.
SELECTION-SCREEN END OF BLOCK main.
AT SELECTION-SCREEN ON p_netw.
ADD 1 TO lv_count.
AT SELECTION-SCREEN.
p_wbs = lv_count.
You need to use a PAI (process after input) module on your screen which then takes the new p_aufnr and finds the appropriate p_wbs - probably exactly like your at selection screen event. You will then CALL SCREEN ### <-- your screen number to display the data on your screen. Without any code to work off thats all i can help with.

Changing TextBox fields on Lost Focus

I am making a database with access 2007. I have a form for the call center to enter customer info; Name, Address, Phone Number, ect.
There is a field for credit card numbers and while we are supposed to enter them as first 4 numbers and last for number ie.1234xxxxxxxx4321
I want to make sure if they do enter them in that it keeps the first and last 4 numbers but changes other characters to "x" when the field loses focus. Could anyone point me in the right direction of how to do this?
Thanks in advance for all help in this matter.
If you are only storing the first 4 and last 4 digits then the following works. Modify the function validCreditCardNumber() to have whatever checks you want to apply.
Function validCreditCardNumber(creditCardNumber) As Boolean
If Len(creditCardNumber) = 12 Then
validCreditCardNumber = True
Else
validCreditCardNumber = False
End If
End Function
Private Sub cbxCreditCardNumber_LostFocus()
If validCreditCardNumber(cbxCreditCardNumber) Then
cbxCreditCardNumber.Text = Left(cbxCreditCardNumber.Text, 4) & "xxxxxxxx" & Right(cbxCreditCardNumber.Text, 4)
End If
End Sub
If you want to store the entire number but only hide the digits from the screen then I think a input masks are what you are looking for.
All you need is something like this in your form code.
Private Sub txtCC_LostFocus()
txtCC.Text = Left(txtCC, 4) & String(8, "x") & Right(txtCC, 4)
End Sub
Then what you see is what will get stored in the DB. ie.1234xxxxxxxx4321
I'm going to assume you don't want to actually keep the whole CC# in your DB. That is a huge no-no unless you spend massive time & money to meet PCI compliance. Here's some info on PCI: http://www.pcicomplianceguide.org/pcifaqs.php
There is no input mask available for partial masking of a string entry. You will need to use a custom function to change the data entered. The best way to do this would probably be to link the field in the table to a hidden textbox. You can then have a visible textbox apply some function to the value in the hidden textbox to change the characters to "X" in the LostFocus event of the visible textbox. However, it's also going to have to write the data to the hidden textbox when you change it.

How to select multiple ranges for a parameter WITHOUT first filling all other required parameters?

I'd want to be able to have multiple range selections for "Sales order no."
Problem is: when i press the button marked with green, i get the error "Fill in all required entry fields".
I put my main processing block at the START-OF-SELECTION event.
What to do to not have this happen? It seems to me that i should be able to add multiple selections without all the hassle of first filling every other mandatory field.
With parameters/select-options set to OBLIGATORY, this won't work. I had the very same problem some time ago, and had no chance to fill the OBLIGATORY input parameters with useful values by default, so I did the following:
Remove the OBLIGATORY option from all select-options and parameters
Handle the check for obligatory input yourself in cases no F4,help, F1 help or the button next to any select option is pressed:
Code:
AT SELECTION-SCREEN ON s_reswk.
IF sy-ucomm(1) <> '%' AND " sel screen action request
sy-ucomm(1) <> '_' AND " scope option
s_reswk IS INITIAL. " Obligatory input missing
MESSAGE text-e01 TYPE 'E'. " Error message
ENDIF.
Here's what i found that completely reproduces the behavior set by the OBLIGATORY addition:
1:Take OUT the "OBLIGATORY" addition.
2:at PBO:
LOOP AT SCREEN.
IF screen-name cs 'name-of-your-select-options-or-parameter'.
screen-required = 2.
MODIFY SCREEN.
ENDIF.
3: at PAI:
if sscrfields-ucomm = 'ONLI'.
if 'name of your select-option-or-parameter' is initial.
clear sscrfields.
message 'Fill in all required fields.'(009) type 'E'.
endif.
endif.
Notice the first if statement contains a 'cs' logical operator. That's cuz the name of your control will contain other weird stuff as well. For instance %_P_MATNR_%SCREEN%% (where your parameter was p_matnr).
Also, the declaration : TABLES sscrfields. is necessary.