How To Program the F4 Help

Linking F4 Help to Fields.

Here we will deal with the linking of F4 help to fields. It is easy. As usual, define, implement and register the event “onf4” at proper places in your code. For F4 help, you must register the fields whose F4 request will trigger the “onf4” event. 

For this you must prepare a table of type “LVC_T_F4” and register this table using the method “register_f4_for_fields”. While preparing table you must include a line for each field which will trigger F4 event. For each field in the structure;

1) Pass the fieldname to ‘FIELDNAME’.
2) Set ‘REGISTER’ to make the field registered.
3) Set ‘GETBEFORE’ to provide field content transport before F4 in editable mode.
4) Set ‘CHNGEAFTER’ to make the data changed after F4 in editable mode.

Preparing table for the fields to be registered to trigger F4 event.

DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE .
.. ..
lt_f4-fieldname = 'PRICE'.
lt_f4-register = 'X' .
lt_f4-getbefore = 'X' .
APPEND lt_f4 .
CALL METHOD gr_alvgrid->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[] .

A sample “onf4” method implementation.

METHOD handle_on_f1 .
PERFORM f4_help USING e_fieldname es_row_no .
er_event_data->m_event_handled = 'X' .
ENDMETHOD .

Again, we set the attribute “er_event_data->m_event_handled” to prevent further processing of standard F4 help.

Also, check these standard programs for coding samples:

BCALV_GRID_F4_HELP_APPLICATION
BCALV_GRID_F4_HELPM01
BCALV_TEST_GRID_F4_HELP

See Also:
Brain Dump ABAP Questions and Answers

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.