Adding F4 help to a field on MODULE POOL Programming
In order to add F4 help to a field in module pool follow these steps:-
- First, go to SE11 and create your own search help (if you don't know how to create a search help please feel free to ask me, it is very easy).
- Now in your module pool program go to the layout of your screen.
- Now when you see the attributes of this field in the Dict tab you will find the field Search Help. Now here you can specify the name of the search help you created in SE11.
There is also another method to create the dynamic search help. eg:- in a posted document data get the Document nos related to that company code.
The sample code is like this:-
First of all, declare the module below in the flow logic of your screen then create it in your main program.
You declare the module in the PROCESS ON VALUE-REQUEST.
PROCESS ON VALUE-REQUEST.
FIELD TXT_DOCNO MODULE VALUE_BELNR.
You also need to create an internal table where you wil store results of the select query fired below in the module.
here you will get an F4 help on the filed Document Number (TXT_DOCNO) based on the field Company code (TXT_CODCO)
MODULE VALUE_BELNR INPUT.
progname = sy-repid.
dynnum = sy-dynnr.
CLEAR: field_value, dynpro_values.
field_value-fieldname = 'TXT_CODCO'.
APPEND field_value TO dynpro_values.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = 'BKPF'
fieldname = 'BUKRS'
dynpprog = progname
dynpnr = dynnum
dynprofield = 'TXT_CODCO'.
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.
SELECT BUKRS BELNR
FROM BKPF
INTO CORRESPONDING FIELDS OF TABLE it_doc1
WHERE BUKRS = field_value-fieldvalue.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BELNR'
dynpprog = progname
dynpnr = dynnum
dynprofield = 'TXT_BELNR'
value_org = 'S'
TABLES
value_tab = it_doc1.
ENDMODULE. " VALUE_BELNR INPUT