Copyright 2020 - BV TallVision IT

To connect the menu painter to the screen painter, a special code field will have to be declared in the ABAP. The last field of a DYNPRO is a reserved field, that embodies the link to the menu painter, the The OKCODE. If you do not link it (by giving it a name), the DYNPRO will not be able to pass on the chosen menu actions from the menu painter. Result: no user interaction possible via the menu. Simply fill in OKCODE for this last field of a DYNPRO's field list (menu: from Screen painter: jump => field list). 

In ABAP: Connecting your DYNPRO to the menu-painter

The (ok)code is used to pass on function codes of actions that are recieved from the end user in an menu. If the end-user selects a function (via the menu or a button), this function code is put in the OKCODE field. The ABAP programmer can choose a different name for the OKCODE e.g. FCODE, but it should always be defined as DATA okcode like SY-UCOMM.. While the program is being processed, the OKCODE has to be initiated continuously after every action in the ABAP program. If this is not done, beware of unexpected menu actions.

In flow logic: Respond to a menu action

Like interactive reporting, the system passes a value for the OKCODE field to be handled by the program. What needs to be done for that is creating a screen module that handles these menu actions. A proposed name would be MODULE D900_MENU_RESPONS., the last module in the Process After Input of the screen. If you've not seen PBO and PAI yet, please skip this for now.

Here's an example of a very short PAI module that handles the menu action:


    WHEN 'SAVE'.
    WHEN 'DEL'.
    WHEN 'STOP'.
      SET SCREEN 0.


Function types - in the menu painter

Menu processing can be dealt with per group of menu option in themenu painter. An overview of preset function codes and their descriptioncan be found in the menu of the menu painter. The fifth column "type"may contain a character; an overview of possible characters:

E Exit command Executes PROCESS AFTER INPUT module <..> AT EXIT COMMAND. (elaborated in the example)
H Help Executes the modules related to ON HELP REQUEST
S System function Executes a system command that shows up as a function code in the functionlist; e.g. a function-code "O" with "S" as "functiontype" field has the following result: When selecting menu option code"O" the system function "/O" (a list with modi) isexecuted. Another example: if the menu option code has the value "NEND",the system will be shut down when selecting menu option code.
T Transaction The function type "T" processes the function code as a transactioncode, as if the end-user would type: "/NTRAN" for the transactioncode "TRAN". Processing is equal to processing an area menu
X Default Empty OKCODE

Function types "C" and "N" are also available.

As example, the steps for grouping function codes as "exit commands". For thisexample, an application has the three buttons for "exit" (green arrow, yellowarrow and red cross) and another button called "Quit". Just to make sure theend user can get out of this application. The "Quit" button is actually not inthe appliccation toolbar but somewhere in the DYNPRO itself. Now the idea isto create a single module that is called whenever one of the function codes fromthe "exit commands" group is choosen.

Example: Function types in the screen painter

Proces on event

Besides PBO and PAI, other events can be handled as well:
PROCESS ON HELP-REQUEST. "(F1), help on fields
PROCESS ON VALUE-REQUEST. "(F4), possible values on fields

A double click in a LOOP

Double clicking in a step LOOPcan be very useful for DYNPRO-based drill downs. How should double clicks be handled though ? Here's what you need to do:

  • Make sure your menu (status) includes a function code for F2, thiscode is reserved for double clicks or rather: selection. Use function codePICKfor example.
  • When handling the menu response of your screen, the OKCODE shouldpick up the code for selection (PICK) and do the following:
  • Use the GET CURSORstatement to find out information about wherethe cursor is:
        GET CURSOR FIELD field_name VALUE field_value LINE loop_position.
  • That's all !

Buttons in a step-loop

This one is really nice: the screen painter allows you to add a pushbutton to a step loop line. Thus your screen would have a pushbutton for every line displayed. Pressing the button would pass on the button's functioncode (as defined in the attributes of the screen field) to the program. However, how can you find out which button has been pressed !? Here's SAP's answer, as described in the help text from the FctCodefield in the screen-painter's attributes popup.

The function code for a button that is defined in a LOOP should end with the special character %. This character will be replaced with the step-loop's number at run time. Thus when the button is pressed on the third line on the screen, the function code PI%% will be passed on to the program as PI03. Back to you, chief development !