Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Search help exit code example?

Former Member
0 Likes
1,772

I need to develop an authorization check in the search help exit that will drop certain fields from the display based on a user's authorization. It appears that the delivered search help function module provides a result table (as a string). I would just like to blank out characters in the string. The function modules does tell me what the search help name is and the structure but I am in a bind pulling it altogether. Has anyone had any experience doing this? Any good code examples?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,072

Can have a look into this

Search Help exit(Add new field)

The search help exit allows you to modify functionality of search help. 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.

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:

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:

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.

Thanks & Reagrds,

Judith.

4 REPLIES 4
Read only

Former Member
0 Likes
1,073

Can have a look into this

Search Help exit(Add new field)

The search help exit allows you to modify functionality of search help. 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.

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:

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:

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.

Thanks & Reagrds,

Judith.

Read only

Former Member
0 Likes
1,072

hi,

based on your authorization check you can filter the output of your search help by modifying the three things namely the field description SHLP-FIELDDESCR, field properties SHLP-FIELDPROP and the recordtab RECORD_TAB.

Basically the search help runs for various CALLCONTROL-STEP values like 'SELECT', 'DISP', 'RETURN' etc. Indeed for step value DISP it fetches data from database and displays it. at this venture one can change the record_tab based on the fielddescrip and fieldprop.

in the below code i have just added a new field to the current field setup and defined its field prop and latter selected the required data for the new field.

*"----


  • The following search help exit is used to modify the existing search

  • help Y_EQUI and so the required customized fields which are not there

  • in the search help can be added and also the output can be alligned.

*"----


  • Check whether the STEP value is DISPLAY as at this point the

  • RECORD_TAB has data being fetched from Database.

  • ----------------------------------------------------------------------

if callcontrol-step eq 'DISP'.

  • Add the new field DEVLOC along with the existing search help fields by

  • specifying the required offset and length.

  • ----------------------------------------------------------------------

clear wa_fielddescr.

wa_fielddescr-tabname = 'EGERH'.

wa_fielddescr-fieldname = 'DEVLOC'.

wa_fielddescr-domname = 'DEVLOC'.

wa_fielddescr-position = '1'.

wa_fielddescr-offset = '18'.

wa_fielddescr-headlen = '30'.

wa_fielddescr-scrlen1 = '30'.

wa_fielddescr-scrlen2 = '35'.

wa_fielddescr-scrlen3 = '40'.

wa_fielddescr-lfieldname = 'DEVLOC'.

wa_fielddescr-leng = '30'.

wa_fielddescr-outputlen = '18'.

wa_fielddescr-intlen = '30'.

wa_fielddescr-datatype = 'CHAR'.

wa_fielddescr-INTTYPE = 'C'.

wa_fielddescr-fieldtext = 'Device Location'.

append wa_fielddescr to shlp-fielddescr.

  • Set the fieldproperty for the new field DEVLOC included

  • ----------------------------------------------------------------------

wa_fieldprop-fieldname = 'DEVLOC'.

wa_fieldprop-shlpinput = 'X'.

wa_fieldprop-shlplispos = '02'.

append wa_fieldprop to shlp-fieldprop.

  • Pass the RECORD_TAB to an internal table and refresh its contents. now

  • select the required data as per the new serach help fields and allign

  • them back to the RECORD_TAB as per the offset being defined in the

  • field description.

  • ----------------------------------------------------------------------

refresh i_recordtab.

i_recordtab[] = record_tab[].

refresh record_tab.

loop at i_recordtab.

ws_equnr = i_recordtab-string+3(18).

refresh i_egerh.

select * into table i_egerh

from egerh

where equnr = ws_equnr

and ab le sy-datum

and bis ge sy-datum.

loop at i_egerh.

clear wa_record.

concatenate sy-mandt

ws_equnr

i_egerh-devloc

into wa_record-string.

append wa_record to record_tab.

endloop.

endloop.

endif.

Regards,

Jagath.

Read only

0 Likes
1,072

It is not recommended to work the way proposed above (see SAP note 736293). There you can also find the names of function modules that can be used to manipulate the table of results.

If you really want to have the number of displayed columns user-dependent I would rather suggest to have all columns defined as search help parameters and then change their properties in the shlp-fieldprop-table when necessary. (Unfortunately there is no F4UT_-function module to perform this action).

This way is much more robust against changes that may be made in SAPs coding.

Read only

0 Likes
1,072

Thank you very much. I appreciate all the answers. I hope I awarded points correctly for all responders.