1. Go to SE80 , create program:
2. Create the screen for user dialog program:
3. Click on the button Layout to go to screen paiter.Screen painter is a tool that helps design the screen of module program.
4. In this example, we will create a simple program that calculate two number and show its result:
You could see on the left side is the elements you will add to the screen.First,add two input fields A and B.
Second,Create the output field RESULT to contain the calculation result from A + B.
Third,create the button with the name CAL , fctCode CAL.
Double click to the screen 1000 ,it will show you the flow logic of the screen 1000.
It has two PROCESSES:
PROCESS BEFORE OUTPUT : In this proscess,you could set the initial values of the screen elements or do the initial logics.
PROCESS AFTER INPUT: In this proscess,you could get the value from the screen elements and do the needful.
Create the MOUDLEs in each PROCESS.
Here' code example.Notice that the name of variants in the flow logic must be same name with the name of screen elements:
REPORT ZUSERDIALOG_01.
DATA: A TYPE I,
B TYPE I,
RESULT type i.
CALL SCREEN 1000.
*&---------------------------------------------------------------------*
*& Module STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_1000 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
A = 1.
B = 1.
ENDMODULE. " STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1000 INPUT.
IF sy-ucomm = 'CAL'.
RESULT = A + B.
ENDIF.
ENDMODULE. " USER_COMMAND_1000 INPUT
F8 to run program:
The result will show after pressing CAL button.
The end. Hope this information helpful for you.