Input Checks in Dialog Modules
Use
Input checks in PAI modules cannot be programmed until the contents of the input fields have been transported to the ABAP program. Here, the content can be checked using logical expressions. The user should then be allowed to correct any wrong entries on the screen before any further modules are called.
This can be done by sending warning (type W) or error (type E) messages from PAI modules called in combination with the statements FIELD and CHAIN .
Checking Single Fields
If a warning or error message is sent in a module mod called in combination with a FIELD statement:
FIELD f MODULE mod .
the corresponding input field on the current dynpro is made ready for input again, allowing the user to enter a new value. If the field is only checked once, PAI processing continues directly after the FIELD statement, and the preceding modules are not called again.
Checking a Set of Fields
If a warning or an error message is sent in a module mod 1 mod 2 called within a processing chain:
CHAIN.
FIELD: f1, f2,...
MODULE mod1.
FIELD: g1, g2,...
MODULE mod2.
...
ENDCHAIN.
all of the input fields on the current dynpro that belong to the processing chain are made ready for input again, including those in FIELD statements after the MODULE statement. None of the other fields are ready for input. Even if a MODULE statement appears within a processing chain, combined with a FIELD statement, all of the input fields in the chain are made ready for input again and not just the field in question. The user can repeat the input. If the fields in the processing chain are only checked once, the PAI processing continues directly after the automatic checks after the CHAIN statement, and the preceding modules are not called again.
Controlling Input and Data Transport
If the FIELD statement is used outside of a processing chain, only a single field is made ready for input when a warning or error message is displayed. If FIELD statements are used between CHAIN - ENDCHAIN, this controls a set of fields. All of the fields controlled by a FIELD statement are transported back to the screen, bypassing PBO processing. This means that changes to the field content before a message are displayed on the screen. This also applies to the sending of information messages where no fields are made ready for input.
Checking Fields Repeatedly
Sometimes it is necessary to specify the same field in more than one FIELD or CHAIN statement. If one of the associated modules sends a warning or error message, PAI processing resumes with the value that the user corrected. However, in this case, processing cannot simply resume at the associated FIELD or CHAIN statement if the field in question has already been included in an earlier FIELD or CHAIN statement.
Instead, all of the FIELD and CHAIN statements containing a field in which an error occurred are repeated. PAI processing resumes after the first FIELD or CHAIN statement containing one or more of the fields in which the error occurred in the FIELD or CHAIN statement and modified by the user the last time the screen was displayed.
PROCESS AFTER INPUT.
FIELD f1 MODULE m1.
FIELD f2 MODULE m2.
CHAIN.
FIELD: f1, f2, f3.
FIELD: f4, f5, f1.
MODULE m3.
MODULE m4.
ENDCHAIN.
CHAIN.
FIELD: f6.
MODULE m5.
ENDCHAIN.
CHAIN.
FIELD f4.
MODULE m6.
ENDCHAIN.
If module m 6 contains a warning or error message, the screen is displayed again, after which processing resumes with the first CHAIN statement. Module m3 is called since this is the first occurrence of the field f 4.
Remaining Functions in the FIELD Statement
All of the functions of the FIELD and CHAIN statements for controlling data transport and conditional module calls can also be used in combination with warning and error messages. The contents of each field are transported after the FIELD statement in which the field occurs. If a warning or error message occurs in a conditional module of a processing chain, all of the fields in that chain are ready for input when the screen is displayed again, although not all of the fields will have been transported.
If a warning or error message occurs in a module that is not associated with fields using a FIELD or CHAIN statement, none of the fields on the screen will be ready for input. In this case, the user can only exit the program, but only if a corresponding unconditional module call is provided.
Input Checks in Dialog Modules
PROGRAM demo_dynpro_field_chain.
DATA: ok_code TYPE sy-ucomm,
input1 TYPE i, input2 TYPE i, input3 TYPE i,
input4 TYPE i, input5 TYPE i, input6 TYPE i,
sum TYPE i.
CALL SCREEN 100.
MODULE init_screen_100 OUTPUT.
CLEAR: input1, input2, input3, input4, input5, input6.
SET PF-STATUS 'STATUS_100'.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE module_1 INPUT.
IF input1 < 50.
MESSAGE e888(sabapdocu) WITH text-001 '50' text-002.
ENDIF.
ENDMODULE.
MODULE module_2 INPUT.
IF input2 < 100.
MESSAGE e888(sabapdocu) WITH text-001 '100' text-002.
ENDIF.
ENDMODULE.
MODULE module_3 INPUT.
IF input3 < 150.
MESSAGE e888(sabapdocu) WITH text-001 '150' text-002.
ENDIF.
ENDMODULE.
MODULE chain_module_1 INPUT.
IF input4 < 10.
MESSAGE e888(sabapdocu) WITH text-003 '10' text-002.
ENDIF.
ENDMODULE.
MODULE chain_module_2 INPUT.
CLEAR sum.
sum = sum + : input4, input5, input6.
IF sum <= 100.
MESSAGE e888(sabapdocu) WITH text-004 '100' text-002.
ENDIF.
ENDMODULE.
MODULE execution INPUT.
MESSAGE i888(sabapdocu) WITH text-005.
ENDMODULE.
The static next dynpro number of dynpro 100 is 100. It has the following layout:
The dynpro fields input1 through input6 are assigned to the input fields. The function code of the pushbutton is EXECUTE.
In the GUI status STATUS_100, the icon
(F12) is active with function code CANCEL and function type E. Furthermore, the function key F8 is assigned to the function code EXECUTE with the function type <blank>.
The screen flow logic is as follows:
PROCESS BEFORE OUTPUT.
MODULE init_screen_100.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
FIELD input1 MODULE module_1.
FIELD input2 MODULE module_2.
FIELD input3 MODULE module_3.
CHAIN.
FIELD input4.
MODULE chain_module_1.
FIELD input5.
FIELD input6 MODULE chain_module_2.
ENDCHAIN.
MODULE EXECUTION.
This program demonstrates how input fields can be checked in dialog modules.
The fields input1 through input 3 are checked independently of each other in the modules module _1 through module _3. As long as the user does not enter a corresponding value, the screen is repeatedly displayed with the appropriate field ready for input.
The fields input 4 through input 6 are checked together in the processing chain. If input 4 does not satisfy the condition in chain_ module_1, all three fields are again ready for input. The same applies if the three fields do not satisfy the condition in chain_module_2.
The EXECUTION module, from which an information message is displayed, is not executed until all six fields satisfy the appropriate conditions.