Providing multiple selection options in Search help By Virendra Soni, Zaffera Softwares This document specifies how to include multiple select options for the given fields in the search help. For example below we can see that for material we have single selection possible.
So to convert it in the select option we need to follow certain steps. We need to create a “Search Help Exit” in search help. Search help exit is a function module with the same interface like “F4IF_SHLP_EXIT_EXAMPLE”.
Double click in the search help exit name and paste the following code lines: DATA:type_info LIKE dfies. callcontrol-no_maxdisp = 'X'. IF callcontrol-step EQ 'SELECT'. callcontrol-step = 'DISP'. ENDIF. CHECK: callcontrol-step EQ 'DISP'. CALL FUNCTION 'TABCONTROL_VISIBLE' EXPORTING visible = 'F' tab_id = 1. SUBMIT zmat_search VIA SELECTION-SCREEN AND RETURN. IMPORT record_tab TO record_tab FROM MEMORY ID 'REC1'. READ TABLE shlp-fielddescr INDEX 1 INTO type_info. type_info-leng = 18. CLEAR type_info-offset . MODIFY shlp-fielddescr INDEX 1 FROM type_info TRANSPORTING leng offset. callcontrol-step = 'RETURN'. Create a executable program and paste code lines like this: REPORT zmat_search. TABLES: mara,makt. TYPE-POOLS: slis. DATA: gs_fcat TYPE slis_fieldcat_alv
,
gt_fcat TYPE STANDARD TABLE OF slis_fieldcat_alv gs_layout TYPE slis_layout_alv .
,
DATA: record_tab TYPE STANDARD TABLE OF seahlpres, gs_record TYPE seahlpres. DATA:BEGIN OF gs_output, matnr TYPE matnr, brand_id TYPE mara-brand_id, saiso TYPE mara-saiso, saisj TYPE mara-saisj, saity TYPE mara-saity, maktx TYPE makt-maktx, chk TYPE c, END OF gs_output, gt_output LIKE STANDARD TABLE OF gs_output. SELECT-OPTIONS:matkl FOR mara-matkl matchcode object wwg1, brand FOR mara-brand_id, saiso FOR mara-saiso NO INTERVALS NO-EXTENSION, saisj FOR mara-saisj NO INTERVALS NO-EXTENSION, saity FOR mara-saity NO INTERVALS NO-EXTENSION. START-OF-SELECTION. SELECT mara~matnr mara~matkl mara~brand_id mara~saiso mara~saisj mara~saity makt~maktx FROM mara INNER JOIN makt ON mara~matnr = makt~matnr AND makt~spras EQ sylangu INTO CORRESPONDING FIELDS OF TABLE gt_output WHERE mara~matkl IN matkl AND mara~brand_id IN brand AND mara~saiso IN saiso AND mara~saisj IN saisj AND mara~saity IN saity . PERFORM build_fcat USING :
'MATNR' 'Article' 'X' , 'BRAND_ID' 'Brand Id' '' , 'SAISO' 'Season Category' '' 'SAISJ' 'Season Year' '' , 'SAITY' 'Rollout' '' , 'MAKTX' 'Description' '' .
gs_layout-box_fieldname = 'CHK'. gs_layout-colwidth_optimize = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING
,
i_callback_program = sy-repid i_callback_pf_status_set = 'PF_STATUS_ALV' i_callback_user_command = 'USER_COMMAND_ALV' is_layout = gs_layout it_fieldcat = gt_fcat TABLES t_outtab = gt_output EXCEPTIONS program_error = 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. *&---------------------------------------------------------------------* *& Form build_fcat *&-------------------------------------------------------------------FORM build_fcat YPE c us_seltext_m TYPE c us_key TYPE c. gs_fcat-fieldname = us_fieldname gs_fcat-seltext_l = us_seltext_m gs_fcat-key = us_key APPEND gs_fcat TO gt_fcat CLEAR gs_fcat .
. . . .
" build_fcat
ENDFORM.
*&---------------------------------------------------------------------* *& Form pf_status_alv *&------------------------------------------------------------------FORM pf_status_alv USING rt_extab TYPE slis_t_extab. SET PF-STATUS 'YSTANDARD' EXCLUDING rt_extab. ENDFORM. "pf_status_alv *&---------------------------------------------------------------------* *& Form user_command_alv *&------------------------------------------------------------------FORM user_command_alv USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. CASE r_ucomm. WHEN 'EXC'. LOOP AT gt_output INTO gs_output WHERE chk EQ 'X'. WRITE gs_output-matnr TO gs_record-string(18). APPEND gs_record TO record_tab.
USING us_fieldname T
ENDLOOP. EXPORT record_tab TO MEMORY ID 'REC1'. LEAVE PROGRAM. WHEN '&IC1'. READ TABLE gt_output INTO gs_output INDEX rs_selfield-tabindex. IF sy-subrc EQ 0. WRITE gs_output-matnr TO gs_record-string(18). APPEND gs_record TO record_tab. EXPORT record_tab TO MEMORY ID 'REC1'. LEAVE PROGRAM. ENDIF. WHEN '&FB03'. SET SCREEN 0 . LEAVE SCREEN. ENDCASE. ENDFORM.
"user_command_alv
Save and activate both Search help and Search help exit and run the search help. Screen – 1
Press enter, Screen – 2
Press Enter. Screen - 3
Give the selection values and press F8. Output will show in ALV. Select any line and find the values in the corresponding selection box.
This search help can be attached to the standard search help say MATNR search help in MM01. BASIS will perform this action.