In the SAP system, Dynpro (Dynamic Program) is a very important concept. Dynpro is a tool used to build SAP's graphical interface, which can help us create and manage user interfaces. The ABAP Dynpro program is often used to create interactive applications that help users interact with the system through a graphical interface.
An ABAP Dynpro program consists of a series of screens, each of which consists of elements such as input fields, buttons, tables, etc. Each screen has some ABAP code associated with it that defines how the system should respond when the user interacts with screen elements. For example, when a user clicks a button, the ABAP code associated with the button is executed.
When creating an ABAP Dynpro program, we first need to create one or more screens. Each screen consists of a Layout and some ABAP code. Layout defines the elements on the screen and their layout, while ABAP code defines the behavior of these elements.
For example, we can create a simple ABAP Dynpro program that contains an input field for entering a name and a button for displaying a welcome message. When the user enters a name and clicks the button, the system displays a welcome message containing the entered name.
First, we need to create a screen (for example, screen number 1000). In the layout of this screen, we add an input field and a button. The name of the input field can be NAME
and the name of the button can be DISPLAY_MESSAGE
.
Then, we need to write some ABAP code for this screen. In this code, we first define a global variable G_NAME
to store the name entered by the user. Then, we DISPLAY_MESSAGE
define an PROCESS ON VALUE-REQUEST
event handler for the button. In this handler, we read NAME
the value of the input field and store it in G_NAME
, and then display a G_NAME
welcome message containing .
The following is the ABAP code for this Dynpro program:
DATA: G_NAME TYPE STRING.
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
MODULE STATUS_1000 OUTPUT.
SET PF-STATUS 'SCREEN_1000'.
SET TITLEBAR 'TITLE_1000'.
ENDMODULE.
MODULE USER_COMMAND_1000 INPUT.
CASE SY-UCOMM.
WHEN 'DISPLAY_MESSAGE'.
READ TABLE SCREEN WITH KEY NAME = 'NAME' INTO DATA(WA_SCREEN).
G_NAME = WA_SCREEN-VALUE.
MESSAGE `欢迎,` && G_NAME TYPE 'I'.
WHEN 'BACK'.
LEAVE TO SCREEN '0'.
ENDCASE.
ENDMODULE.
In this code, PROCESS BEFORE OUTPUT
and PROCESS AFTER INPUT
are two processing blocks, executed before the screen is displayed and after the user input. MODULE STATUS_1000
Used to set the status of the screen, such as PF-STATUS and TITLEBAR.