Show TOC

Input Checks in Dialog ModulesLocate this document in the navigation structure

Use

You cannot perform input checks in PAI modules of programs until you have transported the contents of the input fields to the ABAP program. You can then use logical expressions to check the values that the user entered. You should then allow the user to correct any wrong entries before calling further modules.

You can do this by sending warning (type W) or error (type E) messages from PAI modules that are called in conjunction with the statements FIELD and CHAIN .

Checking Single Fields

If you send a warning or error message from a module mod that you called using a FIELD statement as follows:

FIELD f MODULE mod .

the corresponding input field on the current screen is made ready for input again, allowing the user to enter a new value. If the field is only checked once, the 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 … that you 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 screen that belong to the processing chain are made ready for input again -including those that are in FIELD statements after the MODULE statement. All the other fields are not 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 -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 at the CHAIN statement, and the preceding modules are not called again.

Controlling Input and Data Transport

If you use the FIELD statement outside a processing chain, only a single field is made ready for input when a warning or error message is displayed. If you use FIELD statements 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 any changes made to the field contents before the message become visible on the screen. This also applies to sending information messages where no fields are made ready for input.

Checking Fields Repeatedly

You may sometimes need to specify the same field in more than one FIELD or CHAIN statement. If one of the corresponding 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 corresponding 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 at the first FIELD or CHAIN statement containing one or more of the fields in which the error occurred and that the user changed 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 at 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 will be ready for input when the screen is redisplayed, although not all of the fields will have been transported.

If a warning or error message occurs in a module that is not linked with 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 next screen (statically defined) for screen 100 is 100. It has the following layout:

The screen 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 you can check input fields 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.