sapdev logo background
sapdev logo sapdev logo
Comments

Search Help exit- Used to enhance search helps by adding new fields or functionality




The search help exit allows you to modify functionality of search help. If you are creating you own search help exit first copy function module F4IF_SHLP_EXIT_EXAMPLE into your own function group and modify it appropriately. For example if you add a new field to the parameter list that is not contained on the selection method you can manually populate it within the search help exit. Another use for the search help exit would be to allow user to enter search string in any case and return all matching results irrespective for case.

This would be performed within the 'STEP DISP' section. Once within this section all search help data has been retrieved and is stored in table RECORD_TAB (record_tab-string) as one long string value. Therefore you need to read table SHLP in-order to locate position of value within string.

Example:
To find position of personnel number (PERNR) within elemenory search
help M_PREMN you would use the following code:

data: it_shlp type SHLP_DESCR-fielddescr,
      wa_shlp like line of it_shlp.

Loop at record_tab.
	read table shlp-fielddescr into wa_shlp
                                   with key tabname   = 'M_PREMN'
                                            fieldname = 'PERNR'.

You could then use this information in the following way, for
example, to find a persons organisation unit:

Also please note this offset value is not always correct, i have had it return a value double that that was required,
so had to simply divide returned value by 2. Not sure why!!


      select  orgeh endda
        up to 1 rows
        from pa0001
        into (ld_orgeh,ld_endda)
       where pernr eq record_tab-string+wa_shlp-offset(8)
                                                  "pernr length is 8
       order by endda descending.
      endselect.

      select single orgtx
        from t527x
        into ld_orgtxt
       where orgeh eq ld_orgeh and
             sprsl eq sy-langu and
           ( endda ge sy-datum and
             begda le sy-datum ).


If you have added a new field to the end of the parameters list
the next step is to populate it by adding this data to the end of
the record_tab string: 

  concatenate record_tab-string ld_orgtxt into record_tab-string.
  modify record_tab.
endloop.




comments powered by Disqus