0% found this document useful (0 votes)
10 views11 pages

F4 Value Request in Module Pool

This document describes how to program flow logic events in ABAP to provide dynamic dropdown lists for fields. It includes an example using modules to call functions like F4IF_FIELD_VALUE_REQUEST and F4IF_INT_TABLE_VALUE_REQUEST when the user presses F4 in certain fields to populate other dependent fields from database tables. The modules are attached to fields using the FIELD statement within a PROCESS ON VALUE-REQUEST event.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

F4 Value Request in Module Pool

This document describes how to program flow logic events in ABAP to provide dynamic dropdown lists for fields. It includes an example using modules to call functions like F4IF_FIELD_VALUE_REQUEST and F4IF_INT_TABLE_VALUE_REQUEST when the user presses F4 in certain fields to populate other dependent fields from database tables. The modules are attached to fields using the FIELD statement within a PROCESS ON VALUE-REQUEST event.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module Pool Programming

Flow Logic Events


Flow Logic Events

Process on Value Request


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.

MODULE CANCEL INPUT.


LEAVE PROGRAM.
ENDMODULE.
Code
MODULE VALUE_CARRIER INPUT.
CALL FUNCTION
'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
TABNAME = 'DEMOF4HELP'
FIELDNAME = 'CARRIER1'
DYNPPROG = PROGNAME
DYNPNR = DYNNUM
DYNPROFIELD = 'CARRIER'.
ENDMODULE.
Code
MODULE VALUE_CONNECTION INPUT.

CALL FUNCTION 'DYNP_VALUES_READ'


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.

Common questions

Powered by AI

The program's initialization process, carried out by the 'MODULE INIT OUTPUT.', sets up the environment for user interactions by preparing necessary variables and structures, such as setting the program name and screen number. 'FIELD_VALUE' and 'DYNPRO_VALUES' are also cleared and prepared to handle dynamic field values efficiently. This preparatory step is essential as it defines the initial state of the screen fields, ensuring that user interactions like help requests (F4) are processed with the correct context and state, thereby improving interaction reliability and predictability .

In the ABAP program, the DATA and TYPES declarations set up the necessary variables and data structures needed for handling value-request events. For instance, 'TYPES: BEGIN OF VALUES...' defines a structure for storing carrier and connection IDs, while 'DATA: CARRIER(3) TYPE C...' declares variables to hold specific pieces of data, such as carrier and connection codes. These declarations prepare the program to manage and utilize the input and output during user interactions .

During PROCESS ON VALUE-REQUEST events in an ABAP program, the FIELD statement is used with MODULE to specify which module should be called when the user initiates a help request, like pressing F4. The MODULE defined reads and processes relevant field values, such as using 'F4IF_FIELD_VALUE_REQUEST' to fetch or provide possible values for the specified field. This allows the program to effectively manage and handle user input for value assistance .

The layout for screen handling in the ABAP sample is defined to have a process flow that specifies modules to execute before and after user inputs. It includes 'PROCESS BEFORE OUTPUT' with 'MODULE INIT' and 'PROCESS AFTER INPUT' with 'MODULE CANCEL AT EXIT-COMMAND'. This arrangement helps the program manage the screen lifecycle effectively, calling appropriate modules at each step to handle initialization and user exit events, ensuring a smooth user experience .

The module CANCEL plays a crucial role in handling user inputs related to exiting the program. Executed as part of 'PROCESS AFTER INPUT', it contains the command 'LEAVE PROGRAM', which terminates the program flow when the user chooses to exit. This orderly exit mechanism ensures that the program releases resources and concludes user sessions cleanly, preventing any abrupt stops or data integrity issues that could arise from an incomplete shutdown process .

The 'DYNP_VALUES_READ' function is utilized in the ABAP program to read dynamic values from the screen. It is executed within the module VALUE_CONNECTION, exporting the program name and screen number, with an option to translate the values to upper case. This function collects field values currently displayed on the screen into the table 'DYNPRO_VALUES'. By reading these values, the program can handle dynamic modifications and ensure consistency between what the user sees and what the program processes, essential for accurate data management .

The module VALUE_CARRIER in the ABAP program manages user inputs by calling the function 'F4IF_FIELD_VALUE_REQUEST'. This function is executed when the user triggers a value request on the 'CARRIER' field. It exports necessary parameters such as 'TABNAME', 'FIELDNAME', 'DYNPPROG', 'DYNPNR', and 'DYNPROFIELD'. These parameters inform the program about which screen, field, and program context the request refers to, enabling the function to provide appropriate selection options, enhancing the user's input experience by facilitating data entry .

If there are multiple FIELD statements for the same field in an ABAP program's flow logic, only the first FIELD statement is executed. This means that when a user action like pressing F4 is performed for that field, the logic associated with the first FIELD statement takes precedence, effectively ignoring subsequent FIELD statements for the same field. This ensures a deterministic response path within the program's logic .

The module VALUE_CONNECTION supports retrieval of field values during screen processing by calling 'DYNP_VALUES_READ' to read the current values on the screen into 'DYNPRO_VALUES'. Then it uses 'READ TABLE DYNPRO_VALUES INDEX 1 INTO FIELD_VALUE' to access specific field data. Subsequently, it performs a 'SELECT' operation to fetch data matching these field values into the internal table 'VALUES_TAB'. This module thus facilitates dynamic field value retrieval and ensures related data is available for user selections, bolstering interactive capabilities in the screen processing .

The MODULE statement in conjunction with the FIELD statement after the PROCESS ON VALUE-REQUEST is used to handle user interactions such as pressing F4 for a field. The system calls the module associated with the FIELD statement of that field. If there are multiple FIELD statements for the same field, only the first FIELD statement is executed. This allows the programmer to define specific logic for user-initiated help requests, enabling a controlled response within the ABAP program .

You might also like