5 1 1 1 1 1 Rating 100% (3 Votes)
During creation of selection screen or normal screen for your program you declare some fields and you want to use with them standard search help but with some modification like putting values to one of the search help parameters or making the SHLP parameter readonly then structure DDSHIFACE and FM F4IF_START_VALUE_REQUEST comes with a help. DDSHIFACE as you can see do not has much fields and for us the most interesting will be SHLPFIELD, VALFIELD, VALUE and DISPFIELD. In SHLPFIELD we will store the name of the SHLP parameter (names you can check in SE11), VALFIELD if filled will tell FM that value of this SHLP parameter should be returned to the user (value isn't important in our case so i'll put 'X' ). VALUE if filled set the value of SHLP parameter before showing the results of F4 call so we can directly restrict searched range with some data. Finally DISPFIELD if set makes the parameter on SHLP display only .
 
 
So now lets go to the code. To be able to reuse it please create a method or FM with following code:
 
Importing:

value( I_DISPLAY_ONLY )TYPE ABAP_BOOL  DEFAULT SPACE
value( I_MAX_RECORDS ) TYPE I  DEFAULT SPACE
value( I_SHLP_NAME ) TYPE SHLPNAME -> Name of a Search Help
value( IT_DDSHIFACES ) TYPE DDSHIFACES -> Complete Interface of Search Help for Screen

Exporting:

ET_VALUESTYPE TFW_DDSHRETVAL_TAB -> Return Selected Values

Implementation:

method f4_with_customized_params.
*This is the code from http://abapblog.com.
  field-symbols<iface> type ddshiface,
                 <sface> type ddshiface.
  dataf_shlp type shlp_descr.
  dataf_rc type sy-subrc.
  call function 'F4IF_GET_SHLP_DESCR'
    exporting
      shlpname i_shlp_name
      shlptype 
'SH'
    importing
      shlp     f_shlp.

  loop at it_ddshifaces assigning <iface>.
    read table f_shlp-interface[] with key shlpfield <iface>-shlpfield assigning <sface>.
    if sy-subrc eq 0.
      move-corresponding <iface> to <sface>.
    endif.

  endloop.

  call function 'F4IF_START_VALUE_REQUEST'
    exporting
      shlp          f_shlp
      disponly      
i_display_only
      maxrecords    
i_max_records
      multisel      
space
*     CUCOL         = SY-CUCOL
*     CUROW         = SY-CUROW
    importing
      rc            f_rc
    
tables
      return_values et_values.

endmethod.

Example of use:

report  zab_customized_f4.
*This is the code from http://abapblog.com.
parametersp_carrid type sflight-carrid .
parametersp_connid type sflight-connid .


at selection-screen on value-request for p_connid.
  perform customized_f4.

*&---------------------------------------------------------------------*
*&      Form  customized_f4
*&---------------------------------------------------------------------*
form customized_f4.

  dataft_values type standard table of ddshretval.
  dataft_interfaces type ddshifaces.
  datafs_interface type ddshiface.
  field-symbols<val> type ddshretval.

  clear fs_interface.
  fs_interface-shlpfield 'CARRID'.
  fs_interface-valfield  'X'.
  fs_interface-value     p_carrid.
*  fs_interface-dispfield = 'X'.
  append fs_interface to ft_interfaces.

  clear fs_interface.
  fs_interface-shlpfield 'CONNID'.
  fs_interface-valfield  'X'.
  fs_interface-value     '*'.
  append fs_interface to ft_interfaces.


  zcl_abapblog_com=>f4_with_customized_params(
    exporting
      i_display_only space
      i_max_records  
space
      i_shlp_name    
'H_SPFLI'
      it_ddshifaces  ft_interfaces
    
importing
      et_values      ft_values
         
).

  read table ft_values with key fieldname 'CONNID' assigning <val>.
  if sy-subrc eq 0.
    move <val>-fieldval to p_connid.
  endif.

  read table ft_values with key fieldname 'CARRID' assigning <val>.
  if sy-subrc eq 0.
    move <val>-fieldval to p_carrid.
  endif.

  "send dummy ok_code to refresh screen data
  call function 'SAPGUI_SET_FUNCTIONCODE'
    exporting
      functioncode           'DUMMY'
    exceptions
      function_not_supported 1
      others                 2.
  if sy-subrc <> 0.
* Implement suitable error handling here
  endif.


endform.                    "customized_f4

That it looks like if you do not put anything into Airline field.

 
And this is how it looks like if you put value in Airline field and also the parameter dispfield is set for this field in customized F4.
Enjoy!