I created a Search Help which has 2 fields: id
and description
I want to add new row into the results which don't come from the source table. I heard that we can do it via a Search Help Exit, but I don't know how to do that.
I want to add this row:
ID Description
00004 "For all users"
Context: my Search Help was created in the BackEnd and I appended it to an assignment block on my CRM WEBUI component and it works good. But, now I need to add new value into my F4, only one new row.
By default, a Search Help displays the contents of a database table or view ("selection method"), all columns or only specific columns defined in the search help.
If you wish to display different data either by building it from scratch (empty "selection method") or by adapting the data read from that "selection method", you need to use a Search Help Exit.
A search help exit is a function module to be assigned to the search help, called at different moments (called "steps") during the execution of the search help, which can modify the behavior and contents of the search help. The most important steps are:
Steps to create a Search Help Exit :
F4IF_SHLP_EXIT_EXAMPLE
) :
CHANGING VALUE(SHLP) TYPE SHLP_DESCR VALUE(CALLCONTROL) LIKE DDSHF4CTRL TABLES SHLP_TAB TYPE SHLP_DESCT RECORD_TAB LIKE SEAHLPRES.
callcontrol-step
.RECORD_TAB
; to change them, use an intermeidate internal table that you manually type to match the columns selected for the "hit list output" in the search help (order of columns is not important, because the logic of F4UT_*
function modules hereafter is based on column names). To transfer RECORD_TAB to your internal table you call the function module F4UT_PARAMETER_VALUE_GET
(one column at a time, call it repeatedly for several columns), and to transfer your internal table to RECORD_TAB you call the function module F4UT_RESULTS_MAP
.SHLP-SELOPT
.For more information, read the SAP Library about Search Help Exits, the F4UT_*
function modules are provided with some documentation in your system, and there are demos in your system like the search help SFLIGHT.
In your very specific case, I advise you to not define a "selection method" and use a search help exit with this code:
DATA source_tab TYPE TABLE OF zyourtable.
IF callcontrol-step = 'SELECT'.
SELECT * FROM zyourtable INTO TABLE source_tab.
APPEND value ty_source( ID = '00004' Description = 'For all users' ) TO source_tab.
CALL FUNCTION 'F4UT_RESULTS_MAP' " transfer of source_tab to record_tab
TABLES
SHLP_TAB = shlp_tab
RECORD_TAB = record_tab
SOURCE_TAB = source_tab
CHANGING
SHLP = shlp
CALLCONTROL = callcontrol.
ENDIF.