This document describes how to use module pool programming to create dynamic help for fields in ABAP. It discusses flow logic events like PROCESS ON VALUE-REQUEST that allow calling modules associated with fields. The modules can then call functions to open selection screens for finding values for those fields. Code examples are provided to demonstrate looking up carrier and connection codes dynamically from a database table.
This document describes how to use module pool programming to create dynamic help for fields in ABAP. It discusses flow logic events like PROCESS ON VALUE-REQUEST that allow calling modules associated with fields. The modules can then call functions to open selection screens for finding values for those fields. Code examples are provided to demonstrate looking up carrier and connection codes dynamically from a database table.
After the PROCESS ON VALUE-REQUEST statement, you can only use the MODULE statement together with the FIELD statement. When the user chooses F4 for a field <f>, the system calls the module <mod> belonging to the FIELD <f> statement. If there is more than one FIELD statement for the same field <f>, only the first is executed. FLOW LOGIC EVENTS
The module <mod> is defined in the ABAP program
like a normal PAI module.
However, the contents of the screen field <f> are not
available, since it is not transported by the FIELD statement during the PROCESS ON HELP-REQUEST event. Code TYPES: BEGIN OF VALUES, CARRID TYPE SPFLI-CARRID, CONNID TYPE SPFLI-CONNID, END OF VALUES. DATA: CARRIER(3) TYPE C, CONNECTION(4) TYPE C. DATA: PROGNAME LIKE SY-REPID, DYNNUM LIKE SY-DYNNR, DYNPRO_VALUES TYPE TABLE OF DYNPREAD, FIELD_VALUE LIKE LINE OF DYNPRO_VALUES, VALUES_TAB TYPE TABLE OF VALUES. CALL SCREEN 100. Code MODULE INIT OUTPUT. PROGNAME = SY-REPID. DYNNUM = SY-DYNNR. CLEAR: FIELD_VALUE, DYNPRO_VALUES. FIELD_VALUE-FIELDNAME = 'CARRIER'. APPEND FIELD_VALUE TO DYNPRO_VALUES. ENDMODULE.
EXPORTING DYNAME = PROGNAME DYNUMB = DYNNUM TRANSLATE_TO_UPPER = 'X' TABLES DYNPFIELDS = DYNPRO_VALUES. READ TABLE DYNPRO_VALUES INDEX 1 INTO FIELD_VALUE. Code SELECT CARRID CONNID FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE VALUES_TAB WHERE CARRID = FIELD_VALUE-FIELDVALUE Code CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING RETFIELD = 'CONNID' DYNPPROG = PROGNAME DYNPNR = DYNNUM DYNPROFIELD = 'CONNECTION' VALUE_ORG = 'S' TABLES VALUE_TAB = VALUES_TAB. ENDMODULE. Layout
The next screen (statically defined) for screen 100 is
itself. It has the following layout: Code
PROCESS BEFORE OUTPUT.
MODULE INIT. PROCESS AFTER INPUT. MODULE CANCEL AT EXIT-COMMAND. PROCESS ON VALUE-REQUEST. FIELD CARRIER MODULE VALUE_CARRIER. FIELD CONNECTION MODULE VALUE_CONNECTION.