The search help exit allows you to modify functionality of search help. If you are creating you own search help exit you need
to base it on fmodule F4IF_SHLP_EXIT_EXAMPLE. Then add your own functionality into the various sections in-order to
get it to do what you want. The below code is basically what is contained within this Function module, i have add any helpfull
comments in blue.
Also one thing to note is that when working within the search help exit you need to exit all the way out of
transaction se11 and come back in before changes take effect when testing.
FUNCTION F4IF_SHLP_EXIT_EXAMPLE. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *" TABLES *" SHLP_TAB TYPE SHLP_DESCT *" RECORD_TAB STRUCTURE SEAHLPRES *" CHANGING *" VALUE(SHLP) TYPE SHLP_DESCR *" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL *"---------------------------------------------------------------------- * EXIT immediately, if you do not want to handle this step IF CALLCONTROL-STEP <> 'SELONE' AND CALLCONTROL-STEP <> 'SELECT' AND " AND SO ON CALLCONTROL-STEP <> 'DISP'. EXIT. ENDIF. *"---------------------------------------------------------------------- * STEP SELONE (Select one of the elementary searchhelps) *"---------------------------------------------------------------------- * This step is only called for collective searchhelps. It may be used * to reduce the amount of elementary searchhelps given in SHLP_TAB. * The compound searchhelp is given in SHLP. * If you do not change CALLCONTROL-STEP, the next step is the * dialog, to select one of the elementary searchhelps. * If you want to skip this dialog, you have to return the selected * elementary searchhelp in SHLP and to change CALLCONTROL-STEP to * either to 'PRESEL' or to 'SELECT'. IF CALLCONTROL-STEP = 'SELONE'. * PERFORM SELONE ......... EXIT. ENDIF. *"---------------------------------------------------------------------- * STEP PRESEL (Enter selection conditions) *"---------------------------------------------------------------------- * This step allows you, to influence the selection conditions either * before they are displayed or in order to skip the dialog completely. * If you want to skip the dialog, you should change CALLCONTROL-STEP * to 'SELECT'. * Normaly only SHLP-SELOPT should be changed in this step. IF CALLCONTROL-STEP = 'PRESEL'. * PERFORM PRESEL .......... EXIT. ENDIF. *"---------------------------------------------------------------------- * STEP SELECT (Select values) *"---------------------------------------------------------------------- * This step may be used to overtake the data selection completely. * To skip the standard seletion, you should return 'DISP' as following * step in CALLCONTROL-STEP. * Normally RECORD_TAB should be filled after this step. * Standard function module F4UT_RESULTS_MAP may be very helpfull in this * step. IF CALLCONTROL-STEP = 'SELECT'. * PERFORM STEP_SELECT TABLES RECORD_TAB SHLP_TAB * CHANGING SHLP CALLCONTROL RC. * IF RC = 0. * CALLCONTROL-STEP = 'DISP'. * ELSE. * CALLCONTROL-STEP = 'EXIT'. * ENDIF.
Here you can manipulate the select options fields which are used to restrict data within the search help.
For example if a user populates a field to restrict on you could remove this info here so that
the search help retrieves all data. You could also add values to a sepecifc field. Also Check out
the remove case exmaple to see how this is used.
This code will add the value '00001' to the search help field 'PERNR', therefore will restrict
result table to only those pernr's
wa_shlpselop-shlpfield = 'PERNR'. wa_shlpselop-low = '00001'. wa_shlpselop-sign = 'I'. wa_shlpselop-option = 'EQ'. append wa_shlpselop to shlp-selopt. EXIT. "Don't process STEP DISP additionally in this call. ENDIF. *"---------------------------------------------------------------------- * STEP DISP (Display values) *"---------------------------------------------------------------------- * This step is called, before the selected data is displayed. * You can e.g. modify or reduce the data in RECORD_TAB * according to the users authority. * If you want to get the standard display dialog afterwards, you * should not change CALLCONTROL-STEP. * If you want to overtake the dialog on you own, you must return * the following values in CALLCONTROL-STEP: * - "RETURN" if one line was selected. The selected line must be * the only record left in RECORD_TAB. The corresponding fields of * this line are entered into the screen. * - "EXIT" if the values request should be aborted * - "PRESEL" if you want to return to the selection dialog * Standard function modules F4UT_PARAMETER_VALUE_GET and * F4UT_PARAMETER_RESULTS_PUT may be very helpfull in this step. IF CALLCONTROL-STEP = 'DISP'. * PERFORM AUTHORITY_CHECK TABLES RECORD_TAB SHLP_TAB * CHANGING SHLP CALLCONTROL.
In this section you have access to the final results table (RECORD_TAB) just before it is displayed to the user. At this point you can add entries to it or delete entries from it. Check out the remove case exmaple to see how this is used. Also see this search help exit example to see how to manipulate existing entries in this table.
loop at RECORD_TAB. endloop. EXIT. ENDIF.