Current Poll
Overview of various different options to implement the ABAP F4 help which is Value request for any given field using SALV, ALV, F4 std FMs.
Using SALV to show F4 in Popup
CLASS lcl_f4 DEFINITION. PUBLIC SECTION. CLASS-METHODS: msgnr_salv RETURNING value(rv_msgnr) TYPE t100-msgnr. PRIVATE SECTION. TYPES: BEGIN OF lty_t100, msgnr TYPE t100-msgnr, text TYPE t100-text, END OF lty_t100. CLASS-DATA: t_t100 TYPE STANDARD TABLE OF lty_t100. ENDCLASS. "lcl_f4 DEFINITION * CLASS lcl_f4 IMPLEMENTATION. METHOD msgnr_salv. DATA: o_salv_f4 TYPE REF TO cl_salv_table. DATA: lo_functions TYPE REF TO cl_salv_functions_list. DATA: lo_selections TYPE REF TO cl_salv_selections. DATA: lt_rows TYPE salv_t_row, lv_row TYPE i. DATA: ls_t100 LIKE LINE OF t_t100. SELECT msgnr text INTO TABLE t_t100 FROM t100 UP TO 10 ROWS WHERE arbgb = '00' AND sprsl = sy-langu. cl_salv_table=>factory( IMPORTING r_salv_table = o_salv_f4 CHANGING t_table = t_t100 ). * lo_functions = o_salv_f4->get_functions( ). lo_functions->set_default( 'X' ). lo_selections = o_salv_f4->get_selections( ). lo_selections->set_selection_mode( if_salv_c_selection_mode=>single ). * ALV as Popup o_salv_f4->set_screen_popup( start_column = 80 end_column = 140 start_line = 3 end_line = 10 ). * Display o_salv_f4->display( ). * Get the result lt_rows = lo_selections->get_selected_rows( ). READ TABLE lt_rows INTO lv_row INDEX 1. IF sy-subrc EQ 0. READ TABLE t_t100 INTO ls_t100 INDEX lv_row. rv_msgnr = ls_t100-msgnr. ENDIF. ENDMETHOD. "msgnr_salv ENDCLASS. "lcl_f4 IMPLEMENTATION
Using ALV Popup
CLASS-METHODS: msgnr_alv RETURNING value(rv_msgnr) TYPE t100-msgnr. *** METHOD msgnr_alv. TYPE-POOLS: slis. DATA: lt_fcat TYPE STANDARD TABLE OF slis_fieldcat_alv. DATA: ls_fcat TYPE slis_fieldcat_alv. DATA: ls_tabix TYPE slis_selfield. DATA: ls_t100 LIKE LINE OF t_t100. SELECT msgnr text INTO TABLE t_t100 FROM t100 UP TO 10 ROWS WHERE arbgb = '00' AND sprsl = sy-langu. ls_fcat-fieldname = 'MSGNR'. ls_fcat-tabname = 'T_T100'. ls_fcat-reptext_ddic = 'Message'. ls_fcat-outputlen = '10'. APPEND ls_fcat TO lt_fcat. ls_fcat-fieldname = 'TEXT'. ls_fcat-tabname = 'T_T100'. ls_fcat-reptext_ddic = 'Message Text'. ls_fcat-outputlen = '50'. APPEND ls_fcat TO lt_fcat. CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT' EXPORTING i_title = 'Popup To Select' i_allow_no_selection = 'X' i_zebra = 'X' i_tabname = 'T_T100' it_fieldcat = lt_fcat IMPORTING es_selfield = ls_tabix TABLES t_outtab = t_t100. IF ls_tabix IS NOT INITIAL. READ TABLE t_t100 INTO ls_t100 INDEX ls_tabix-tabindex. rv_msgnr = ls_t100-msgnr. ENDIF. ENDMETHOD. "msgnr_alv
Using FM F4IF_INT_TABLE_VALUE_REQUEST
CLASS-METHODS: msgnr_f4fm RETURNING value(rv_msgnr) TYPE t100-msgnr. *** METHOD msgnr_f4fm. SELECT msgnr text INTO TABLE t_t100 FROM t100 UP TO 10 ROWS WHERE arbgb = '00' AND sprsl = sy-langu. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'MSGNR' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = 'P_MSGNR' window_title = 'Select Value' value_org = 'S' display = ' ' TABLES value_tab = t_t100 EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDMETHOD. "msgnr_f4FM
Using FM F4IF_INT_TABLE_VALUE_REQUEST with one column table
CLASS-METHODS: msgnr_f4fm_column RETURNING value(rv_msgnr) TYPE t100-msgnr. *** METHOD msgnr_f4fm_column. SELECT msgnr text INTO TABLE t_t100 FROM t100 UP TO 10 ROWS WHERE arbgb = '00' AND sprsl = sy-langu. TYPES: BEGIN OF lty_char100, value TYPE char100, END OF lty_char100. DATA: lt_values TYPE STANDARD TABLE OF lty_char100. DATA: ls_values LIKE LINE OF lt_values. DATA: ls_t100 LIKE LINE OF t_t100. DATA: lt_ftab TYPE STANDARD TABLE OF dfies , ls_ftab LIKE LINE OF lt_ftab. DATA: lt_ret_tab TYPE STANDARD TABLE OF ddshretval, ls_ret_tab LIKE LINE OF lt_ret_tab. LOOP AT t_t100 INTO ls_t100. ls_values = ls_t100-msgnr. APPEND ls_values TO lt_values. ls_values = ls_t100-text. APPEND ls_values TO lt_values. ENDLOOP. CALL FUNCTION 'DDIF_FIELDINFO_GET' EXPORTING tabname = 'T100' TABLES dfies_tab = lt_ftab EXCEPTIONS not_found = 1 internal_error = 2 OTHERS = 3. IF sy-subrc <> 0. ENDIF. DELETE lt_ftab WHERE fieldname NE 'MSGNR' AND fieldname NE 'TEXT'. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'MSGNR' dynpprog = sy-repid dynpnr = sy-dynnr * dynprofield = 'P_MSGNR' window_title = 'Select Value' value_org = 'C' display = ' ' TABLES value_tab = lt_values field_tab = lt_ftab return_tab = lt_ret_tab EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. READ TABLE lt_ret_tab INTO ls_ret_tab INDEX 1. rv_msgnr = ls_ret_tab-fieldval. ENDMETHOD. "msgnr_f4FM_Column
HELP_START
There is a wrapper FM HELP_START which calls various FMs based on the parameters being passed. Since there are many different variants, I’m not gonna mention it here. If you have already some existing code base, let me know, I can update this post.
Demo Call
PARAMETERS: p_msgnr TYPE t100-msgnr OBLIGATORY. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_msgnr. p_msgnr = lcl_f4=>msgnr_salv( ). "p_msgnr = lcl_f4=>msgnr_alv( ). "p_msgnr = lcl_f4=>msgnr_f4FM( ). "p_msgnr = lcl_f4=>msgnr_f4fm_column( ).
Do you have a Code Snippet which you want to share, Submit Code Snippet here
Hey, thank you for the compilation.
Regarding SALV, there is a big glitch in SAP standard: If you don’t use a dictionary structure for the table displayed but a local type with fields with dictionary reference ( defined as field TYPE tabname-fieldname), you won’t get F1 or F4 Help even as the F4 dropdown symbol is displayed.
I think in 99 % of all applications you won’t have to define your own F4 code – SAP standard provides it.
Use this code to activate it (Though it does not work for domain fixed values):
Enable F1 and F4 in SALV
Call the method after initiating the SALV object before call of method DIDPLAY( ).
I’m still looking for a simple method enabling F4 for domain fixed values.
Regards, Clemens