Entering content frame

Reading Function Codes Locate the document in its SAP Library structure

In each PAI event that a user triggers by choosing either a pushbutton on the screen or an element in a GUI status, the corresponding function code is placed into the system field syst-ucomm or sy-ucomm and placed in the OK_CODE field (as long as the function code is not empty). Empty function codes are placed in neither the sy-ucomm field nor the OK_CODE field.

This graphic is explained in the accompanying text

In your ABAP programs, you should work with the OK_CODE field instead of sy-ucomm. There are two reasons for this: Firstly, the ABAP program has full control over fields declared within it, and secondly, you should never change the value of an ABAP system field. However, you should also always initialize the OK_CODE field in an ABAP program for the following reason:

In the same way that the OK_CODE field in the ABAP program and the system field sy-ucomm receive the contents of the corresponding screen fields in the PAI event, their contents are also assigned to the OK_CODE screen field and system field syst-ucomm in the PBO event. Therefore, you must clear the OK_CODE field in the ABAP program to ensure that the function code of a screen  is not already filled in the PBO event with an unwanted value. This is particularly important when the next PAI event can be triggered with an empty function code (for example, using ENTER). An empty function code does not influence the fields and the old content is transferred. 

In your application programs, the first step in PAI processing should be to save the function code in an auxiliary variable and then initialize the OK_CODE field. You can then read the function code from the auxiliary variable (for example, using a CASE structure), and control the program flow from there.

The OK_CODE field can have a different name on each screen. However, common practice is to use the same name for the field on each screen of an ABAP program. You then only need one field in the ABAP program, with the same name, into which the function code is placed, and from which you can read it.

Example

Global data declarations:

DATA: ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm.

Your ABAP program must contain a field with the same name as the OK_CODE field on the screen. To specify the type, you should refer to the system field sy-ucomm, since this always corresponds to the type of the OK_CODE field on the screen. At the same time, you should declare an appropriate auxiliary variable.

PAI module:

MODULE user_command_100 INPUT.

  save_ok = ok_code.
  CLEAR ok_code.

  CASE save_ok.
    
WHEN...
   ...
  ENDCASE.

ENDMODULE.

In the first PAI module, you should assign the contents of the OK_FIELD to the auxiliary variable and then clear the OK_CODE field and carry on working with the auxiliary variable.

 

 

 

Leaving content frame