abapsap-crm

New record for custom F4


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.


Solution

  • 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 :

    1. Create the function module with the following signature (you may copy the template function module F4IF_SHLP_EXIT_EXAMPLE) :
      CHANGING
         VALUE(SHLP) TYPE SHLP_DESCR
         VALUE(CALLCONTROL) LIKE DDSHF4CTRL
      TABLES
         SHLP_TAB TYPE SHLP_DESCT
         RECORD_TAB LIKE SEAHLPRES.
      
    2. Add the ABAP code in your function module to build or filter the data:
      • The step name is the parameter callcontrol-step.
      • The records are in the parameter 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.
      • If you need them, the eventual data selections are in the parameter SHLP-SELOPT.
    3. Edit the Search Help (transaction code SE11), and enter the name of your function module in the screen field "Search help exit".

    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.