Hi folks,
today i'll try to implement the F4 help in my ALV grid using a drop down list box (DDLB).
Here the steps
1) In the fieldcatalogue of the field set f4availabl = 'X'
2) Fill the F4 table lt_f4 TYPE lvc_t_f4 at least setting "register = 'X'
3) Register the F4 table calling method register_f4_for_fields
4) Fill the dropdown table :lt_dropdown TYPE lvc_t_drop
5) call method set_drop_down_table
No need to register the on_f4 callback.
Of course you have to make sure that the dropdown handle you pass in the fieldcatalogue for the fields corresponds to the entries you want in the dropdown table.
In my case it is the handle "1". Just look at the sample it is clear enough.
In the real world this useless intricacy of the handle and triple registration might be hidden behind an interface method that accepts the table with the values and takes care of generating the handles and collecting the table entries in order to avoid mismatches and mistakes that might happen when multple developers hackon the same piece grid.
Here the result in the grid
Here the coding of the method to enable the DDLB as shown
METHOD: set_famsa_ddlb.
DATA :lt_dropdown TYPE lvc_t_drop.
DATA :ls_dropdown TYPE lvc_s_drop.
DATA: ls_f4 TYPE lvc_s_f4,
lt_f4 TYPE lvc_t_f4.
ps_fcat-drdn_hndl = '1'.
ps_fcat-outputlen = 20.
ps_fcat-f4availabl = 'X'.
REFRESH lt_f4.
ls_f4-fieldname = ps_fcat-fieldname.
ls_f4-register = 'X'.
ls_f4-getbefore = 'X'.
ls_f4-chngeafter = 'X'.
APPEND ls_f4 TO lt_f4.
*These methods shall be called outside. The purpose is test only
CALL METHOD register_f4_for_fields
EXPORTING
it_f4 = lt_f4.
*Shall read t591a or use search help... at least in real life
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Son'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Wife'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Granny'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Sister'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Brother'.
APPEND ls_dropdown TO lt_dropdown.
*These methods shall be called outside. The purpose is test only
CALL METHOD me->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown[].
ENDMETHOD. "set_famsa_ddlb
DATA :lt_dropdown TYPE lvc_t_drop.
DATA :ls_dropdown TYPE lvc_s_drop.
DATA: ls_f4 TYPE lvc_s_f4,
lt_f4 TYPE lvc_t_f4.
ps_fcat-drdn_hndl = '1'.
ps_fcat-outputlen = 20.
ps_fcat-f4availabl = 'X'.
REFRESH lt_f4.
ls_f4-fieldname = ps_fcat-fieldname.
ls_f4-register = 'X'.
ls_f4-getbefore = 'X'.
ls_f4-chngeafter = 'X'.
APPEND ls_f4 TO lt_f4.
*These methods shall be called outside. The purpose is test only
CALL METHOD register_f4_for_fields
EXPORTING
it_f4 = lt_f4.
*Shall read t591a or use search help... at least in real life
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Son'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Wife'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Granny'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Sister'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'Brother'.
APPEND ls_dropdown TO lt_dropdown.
*These methods shall be called outside. The purpose is test only
CALL METHOD me->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown[].
ENDMETHOD. "set_famsa_ddlb
A lot of coding for a little tiny result IMHO. Anyway hope you enjoy.
Cheers