Hi folks,
my F4 help
implementations are going on. Slowly. In a previous post i have shown
how to enable F4 help for a field in your ALV grid.
Here is the implementation of the F4 help in coding using function F4IF_FIELD_VALUE_REQUEST.
To pass the values to the search help the easiest way in OO programming is to use the parameter "callback_method"
Doing so is tricky if you use a local class design. this is because the callback method of function F4IF_FIELD_VALUE_REQUEST is called from a function pool program. Local classes of your program do not exist in the function pool.
This means that if you pass a reference to your local class to the funcion pool when it is dereferenced you get a dump.
This means you have to implement a global class (se24) in order to catch the callback method.
The callback_method parameter is acutally a reference to an interface object of the type IF_F4CALLBACK_VALUE_REQUEST
The steps to implement it therefore are:
1) Declare the interface in your global class class
2) Implement the interface method in your global class
3) Call the F4 F4IF_FIELD_VALUE_REQUEST
function specifying the callback "method" ( reference object) in your
F4 callback method. In my case this is the method called from the event
handler object.
METHOD : on_f4.
DATA lt_ret TYPE TABLE OF ddshretval.
CASE e_fieldname.
WHEN 'FAMSA'.
data lr_f4_cb type ref to Z_CL_F4_CALLBACK.
create object lr_f4_cb.
lr_f4_cb->a_pernr = a_pernr.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = 'P0021'
fieldname = 'FAMSA'
* callback_program = sy-repid
* callback_form = 'CALLB_VALUE_REQUEST'
callback_method = lr_f4_cb
* SELECTION_SCREEN = ' '
* IMPORTING
* USER_RESET =
TABLES
return_tab = lt_ret
EXCEPTIONS
OTHERS = 5 .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
er_event_data->m_event_handled = 'X'.
WHEN OTHERS.
ENDCASE.
ENDMETHOD. ":