Creating Dynamic F4 Help based on currently populated fields
Sometimes, we get the requirement to display F4 Help based on the fields already populated on the current selection screen. Values in the fields populated on the selected screen do not get stored in the parameter/select-option variable until and unless we submit the input in any way (by pressing enter or executing by F8). In these cases, we need to first get the user-entered values from the selection screen, find the corresponding allowable values for the field for which we want to display F4 and display the F4 with only those allowable values. The steps are as follows:
1. Create the selection screen with the parameters as required. For example, here, we will display F4 Help for ‘Print Parameter’ based on the values populated in the fields Warehouse and Plant.
2. Create value help for the print parameter p_prntp:
3. In f4_for_prntp, create a table of type dynpread and insert the parameter field names of warehouse and plant (from which we want to read values).
4. Call the function module DYNP_VALUES_READ passing the li_dynpfields table as well as the program name and screen.
5. Read the table li_dynpfields using the parameter field names to get the currently entered values for them on the selection screen.
6. Get all the allowable corresponding values of print parameters for the obtained warehouse and plant in an internal table.
7. Call the function module ‘F4IF_INT_TABLE_VALUE_REQUEST’ passing the internal table above in the previous step, an internal table of type ddshretval along with the field for which the F4 is to be provided and the field in which the selected values is to be returned (in this case, both are P_PRNTP). Value_org determines if the value returned is Cell by cell (‘C’) or Structured (‘S’).
8. Store the values of the user-selected row in the print parameter p_prntp by reading the first line of the obtained table li_return.
The ZUK_TEST_TABLE table holds the print parameters for a particular combination of Warehouse number & Plant as:
For this demo, the values in the table are maintained as shown above.
After filling the Warehouse (AAA) and the Plant (AA02), the F4 help for the Print Parameter field will be displayed according to the entered Warehouse and Plant as shown below:
Thus, Dynamic F4 Help is obtained.