Drop Down List Program in SAP ABAP.
When was the last time you saw someone creating Drop Down list in SAP ?
Answer would be “rarely”, today we will see
Two ways of creating a drop down list in SAP.
They are:
1. Simple Way
2. Effective Way
Let’s look at the Simple way of creating the drop down with an example [ Calculation ].
Tasks : ADD , MULIPLY, SUBTRACT, DIVISION.
TABLE: ZADDITION
FIELDS: NUMBER1, OPERATION.
Screens shots of it.
NAVIGATION: SE11 à DATABASE à DATA ELEMENT à DOMAIN à VALUE RANGE
Maintain drop down list values as show below in screen shots.
Value range of operation field.
Value range of number1 field.
Go to SE38 and create an Executable Program.
Maintain below code.
Code :
REPORT ZLIST1.
DATA RESULT TYPE I.
PARAMETER NUM1 TYPE ZADDITION-NUMBER1 AS listbox VISIBLE LENGTH 30.
PARAMETER NUM2 TYPE ZADDITION-NUMBER1 AS listbox VISIBLE LENGTH 30.
PARAMETER TASK TYPE ZADDITION-OPERATION AS listbox VISIBLE LENGTH 30.
IF TASK = 'ADD'.
RESULT = NUM1 + NUM2.
WRITE:/ RESULT.
ELSEIF TASK = 'SUB'.
RESULT = NUM1 - NUM2.
WRITE:/ RESULT.
ELSEIF TASK = 'MUL'.
RESULT = NUM1 * NUM2.
WRITE:/ RESULT.
ELSE.
IF NUM1 = 0 & NUM2 = 0.
MESSAGE ‘INVALID INPUT’ TYPE I.
EXIT.
ELSEIF NUM2 = 0.
MESSAGE ‘INVALID’ TYPE I.
EXIT.
ELSE.
RESULT = NUM1 / NUM2.
WRITE:/ RESULT.
ENDIF.
Save!
Press Ctrl + F2 to check syntax errors.
Press Ctrl + F3 to activate the program.
Press F8 to Execute.
You’re done with simple way.