SAP ABAP SELECT-OPTIONS to have Upper and Lower Case
SELECT-OPTIONS by default displays all characters in UPPER CASE. This happens once the user hits the ENTER Key. If you wish to force Lower Case on the field values entered in the SELECT-OPTIONS fields use the addition LOWER CASE.
The Syntax is as follows.
SELECT-OPTIONS: s_ernam for vbak-ernam LOWER CASE.
The code is as follows.
REPORT ZEX_SELECTOPTIONS.
Tables: VBAK, VBAP.
Data: int_vbak type vbak occurs 0 with header line.
Select-options: s_vbeln for vbak-vbeln , s_auart for vbak-auart, s_ernam for vbak-ernam LOWER CASE.
Select * INTO int_VBAK from VBAK where VBELN in s_vbeln. APPEND int_VBAK. CLEAR int_VBAK. ENDSELECT.
loop at int_vbak. Write:/ int_vbak-vbeln, int_vbak-AUART. endloop.
write:/ s_vbeln-low, s_auart-low, s_ernam-low.
In the above example, s_ernam has the addition of LOWER CASE where as s_auart does not have the addition. Once you execute the program the output will show auart in upper case where as ernam in the case that has been entered by the user as it is.
Not: If TYPE addition is used to refer data types from the ABAP dictionary, then you cannot use the LOWER CASE addition. If you enter the following data
Sales Order 4969 Order Type or Created By JohN
Then the Output would be as follows.
Select Options in SAP ABAP 4969 OR 4969 OR JohN
This is because s_ernam has the LOWER CASE addition where as s_auart does not have the addition.
SAP ABAP POPUP Function Module to Confirm Data SAVE
In ABAP if you wish to POP up a Dialog BOX asking the user if the data needs to be saved. Basically this function module POP-UP a dialog box asking for confirmation to SAVE the data, or proceed without saving.
The Parameters
START COLUMN and START ROW define the position of the POP-UP Dialog BOX.
Find the code below.
REPORT ZEX_POPUPTOCONFIRMDATALOSS .
Data: d_ans(20).
CALL FUNCTION 'POPUP_TO_CONFIRM_DATA_LOSS' EXPORTING DEFAULTOPTION = 'J' TITEL = 'Dialog for Data' START_COLUMN = 25 START_ROW = 6 IMPORTING ANSWER = d_ans .
* Based on the answer you can select the step in the flow logic. Write:/ 'Answer =', d_ans.
Based on the User Input the logic in the program can take the desired flow.
SAP ABAP Selection Screen Making Fields Obligatory
In ABAP Selection Screen you can make certain fields OBLIGATORY. This can be done by using the addition OBLIGATORY. Please find the syntax below.
SELECT-OPTIONS: s_vbeln for vbak-vbeln OBLIGATORY
If the addition OBLIGATORY is used the user is forced to enter values in the respective fields before proceeding further. A question mark appears in the selection screen for the SELECT-OPTIONS field.
Find the code below.
REPORT ZEX_SELECTOPTIONS.
Tables: VBAK, VBAP.
Data: int_vbak type vbak occurs 0 with header line.
Select-options: s_vbeln for vbak-vbeln OBLIGATORY.
Select * INTO int_VBAK from VBAK where VBELN in s_vbeln. APPEND int_VBAK. CLEAR int_VBAK. ENDSELECT.
loop at int_vbak. Write:/ int_vbak-vbeln, int_vbak-AUART. endloop.
SAP ABAP SELECT-OPTIONS restricting entry to single fields
In the selection screen if the entry is to be restricted to single field then the following Syntax can be used.
SELECT-OPTIONS s_vbeln FOR VBAK-VBELN NO INTERVALS
If the above statement is used in the program then only one field appears in the Selection-Screen. You can also use NO-EXTENSION in case you want to suppress the push button for multiple selection. In that case the syntax would be as follows.
SELECT-OPTIONS: s_vbeln for vbak-vbeln NO-EXTENSION NO INTERVALS
Find the code below.
REPORT ZEX_SELECTOPTIONS.
Tables: VBAK, VBAP.
Data: int_vbak type vbak occurs 0 with header line.
Select-options: s_vbeln for vbak-vbeln NO-EXTENSION NO INTERVALS.
Select * INTO int_VBAK from VBAK where VBELN in s_vbeln. APPEND int_VBAK. CLEAR int_VBAK. ENDSELECT.
To restrict entry to only one row you can use the following Syntax.
SELECT-OPTIONS s_vbeln FOR VBAK-VBELN NO-EXTENSION
If NO-EXTENSION is used then the Push Button for multiple selection does not appear on the selection screen and hence multiple selections are not available for the User.
Find the code below. REPORT ZEX_SELECTOPTIONS. Tables: VBAK, VBAP. Data: int_vbak type vbak occurs 0 with header line. Select-options: s_vbeln for vbak-vbeln NO-EXTENSION. Select * INTO int_VBAK from VBAK where VBELN in s_vbeln. APPEND int_VBAK. CLEAR int_VBAK. ENDSELECT. Loop at s_vbeln. WRITE: / 'SIGN:', s_vbeln-sign, 'OPTION:', s_vbeln-option, 'LOW:', s_vbeln-low, 'HIGH:', s_vbeln-high. Endloop. loop at int_vbak. Write:/ int_vbak-vbeln, int_vbak-AUART. endloop.
Always use Pretty Printer and Extended Program Check before releasing the code.
Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.