Selection Screen is a user interface element in SAP ABAP that is used to get input from the user at the start of a program execution. It allows users to input the required values or parameters for the program to execute correctly.
A selection screen can be defined using ABAP statements and provides a set of input fields that can be used to receive the user's input. These input fields include selection options, parameters, checkboxes, and radio buttons.
Here are some common selection screen elements in SAP ABAP:
Selection Options: Allows users to select multiple values from a list of available options.
Parameters: Allows users to input a single value such as date, text, or number.
Checkboxes: Allows users to select one or more options.
Radio Buttons: Allows users to select a single option from a set of available options.
In addition to these elements, selection screens can also include pushbuttons such as execute, cancel, or help. The selection screen is displayed at the start of the program and allows the user to input values before executing the program.
Once the user enters the required values, the program can use these values to perform further operations. Therefore, selection screens play a vital role in user interaction with SAP ABAP programs.
CODE FOR THE ABOVE IMAGE GIVEN BELOW:
DATA : V_Z TYPE I.
SELECTION-SCREEN BEGIN OF BLOCK BK1 WITH FRAME title t1. " Selctiom screen block layout.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 8(20) LB1.
""""8 MEANS STARTING FROM 8 FROM LEFT POSITION AND RESERVE 20 CHAR OR SPACES NOW FOR ENTIRE TEXT GIVING SOME VARIABLE NAME LB1
PARAMETERS : P_X TYPE I DEFAULT 20 OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 8(20) LB2.
""""8 MEANS STARTING FROM 8 FROM LEFT POSITION AND RESERVE 20 CHAR OR SPACES NOW FOR ENTIRE TEXT GIVING SOME VARIABLE NAME LB1
PARAMETERS : P_Y TYPE I DEFAULT 15 OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK BK1.
SELECTION-SCREEN BEGIN OF BLOCK BK2 WITH FRAME TITLE T2.
PARAMETERS : P_R1 RADIOBUTTON GROUP GRP1,
P_R2 RADIOBUTTON GROUP GRP1,
P_R3 RADIOBUTTON GROUP GRP1,
P_R4 RADIOBUTTON GROUP GRP1,
P_R5 RADIOBUTTON GROUP GRP1 DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK BK2.
INITIALIZATION.
LB1 = 'ENTER FIRST NUMBER'.
LB2 = 'ENTER SECOND NUMBER'.
T1 = 'ENTER INPUT VALUES'.
T2 = 'ARITHMETIC OPERATIONS'.
START-OF-SELECTION.
IF P_R1 = 'X'.
V_Z = P_X + P_Y.
WRITE :/ 'SUM IS :', V_Z.
ELSEIF P_R2 = 'X'.
V_Z = P_X - P_Y.
if V_Z >= 0.
WRITE :/ 'DIFFERENCE IS :', V_Z.
ELSE.
WRITE :/ 'DIFFERENCE IS : -' NO-GAP,V_Z NO-SIGN LEFT-JUSTIFIED.
ENDIF.
ELSEIF P_R3 = 'X'.
V_Z = P_X * P_Y.
WRITE :/ 'PRODUCT IS :', V_Z.
ELSEIF P_R4 = 'X'.
V_Z = P_X / P_Y.
WRITE :/ ' IS :', V_Z.
ELSE.
write :/ 'NONE OF THE BUTTON IS SELECTED'.
MESSAGE 'NONE RADIOBUTTON SELECTED' TYPE 'I'.
ENDIF.
Follow me for more on LinkedIn : 👍 (432) LinkedIn
No comments:
Post a Comment