Create a search help using search help exit or function module

Go to SE37 create a function module





Go to the tables parameter enter the following table and structure parameters



SHLP_TAB (type SHLP_DESCT): Contain the description details of search help like search help name etc





RECORD_TAB (type SEAHLPRES): Contain the result of this search help

Go to the changing parameter and enter the following parameters  


SHLP (type SHLP_DESCR) : Same as above
CALLCONTROLL (type DDSHF4CTRL) Control Structure for F4 Process with Search Help Exit



Go the source code tab





Write the code for this search exit.
We are taking a join from MARA (material master )and MAKT
(Material Descriptions)
From MARA table :


From MAKT table:
Code in .txt



FUNCTION z_search_help_exit.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     REFERENCE(SHLP) TYPE  SHLP_DESCR
*"     REFERENCE(CALLCONTROL) TYPE  DDSHF4CTRL
*"----------------------------------------------------------------------

  TYPES:
    BEGIN OF ty_mara,
    matnr   TYPE matnr, "Material Number
    ersda   TYPE ersda, "Created On
    mtart TYPE mtart, "Material Type
    maktx  TYPE maktx  ,"Material Description (Short Text)
    spras   TYPE spras,"Language Key
   END OF ty_mara.

  DATA :l_t_mara TYPE STANDARD TABLE OF ty_mara.

  CHECK callcontrol-step = 'DISP'.
  CLEAR l_t_mara.

  SELECT
    a~matnr   "Material Number
    a~ersda   "Created On
    a~mtart  "Material Type
    b~maktx  "Material Description (Short Text)
    b~spras   "Language Key
   INTO TABLE l_t_mara
    UP TO callcontrol-maxrecords ROWS "Row rescriction from user input
     FROM mara AS a INNER JOIN makt AS b
    ON a~matnr =  b~matnr
    WHERE a~ersda = sy-datum
    AND  a~mtart EQ 'LEIH'
      AND b~spras  EQ sy-langu. "System language.

  IF sy-subrc = 0.
    CALL FUNCTION 'F4UT_RESULTS_MAP'
      EXPORTING
*   SOURCE_STRUCTURE         =
        apply_restrictions       = 'X'
       TABLES
         shlp_tab                 = shlp_tab
         record_tab               = record_tab
         source_tab               = l_t_mara
       CHANGING
         shlp                     = shlp
         callcontrol              = callcontrol
      EXCEPTIONS
        illegal_structure        = 1
        OTHERS                   = 2
               .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.
  FREE l_t_mara.ENDFUNCTION. 


Enter the following field into the search help
MANDT
MARA

MATNR
MARA

ERSDA
MARA

MTART
MARA

SPRAS
MAKT

MAKTX
MAKT




*


Activate and execute


Now check with debugging:
Go to the Z_SEARCH_HELP_EXIT and put a break point and execute the search help
RECORD_TAB has 11 records.


Protected by Copyscape Web Copyright Checker

1 comments:

  1. Hi'
    I've created a similar search-help-exit, and it works just fine, but the type-ahead functionality is not working along the exit-FM.
    Do you know how to get this working?
    regards Peter

    ReplyDelete

/*Newer Post*/ Older Post Home