业务要求场景,在CN22创建预留List新增一列并且有搜索帮助多个标签
一、创建两个基本搜索帮助(拿其中一个为例)
因为我这个需求是根据多张表关联获取搜索帮助数据,所以选择方法为空
1、根据值集合的对话:如果数据量大于100条就不会直接展示数据,会先展示一个筛选界面
2、 立即显示值:就是立即展示数据源表中的全部数据
3、 具有值限制的对话:搜索帮助一开始不会将数据表中的全部数据展示出了,会给个筛选条件
搜索帮助出口:通过SE37 参考函数F4IF_SHLP_EXIT_EXAMPLE拷贝新建一个常规函数
代码如下:
FUNCTION yx_f4if_shlp_exit_ccid.
*"----------------------------------------------------------------------
*"*"本地接口:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCT
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------
DATA: ls_thead TYPE thead.
DATA: lt_thead TYPE TABLE OF thead.
DATA: lt_text_headers TYPE TABLE OF thead,
lt_text_table TYPE text_lh.
DATA: s_ccid TYPE RANGE OF yemm_ccidbh,
s_ccidms TYPE RANGE OF yemm_ccidms.
DATA: BEGIN OF ls_ktab,
ccid TYPE yemm_ccidbh,
ccidms TYPE yemm_ccidms,
END OF ls_ktab,
lt_ktab LIKE TABLE OF ls_ktab.
* 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.
CLEAR: record_tab[].
LOOP AT shlp-selopt INTO DATA(ls_selopt).
CASE ls_selopt-shlpfield.
WHEN 'YCCIDBH'.
APPEND INITIAL LINE TO s_ccid ASSIGNING FIELD-SYMBOL(<s_ccid>).
MOVE-CORRESPONDING ls_selopt TO <s_ccid>.
WHEN 'YCCIDMS'.
APPEND INITIAL LINE TO s_ccid ASSIGNING FIELD-SYMBOL(<s_ccidms>).
MOVE-CORRESPONDING ls_selopt TO <s_ccidms>.
ENDCASE.
ENDLOOP.
IF callcontrol-maxrecords IS INITIAL.
callcontrol-maxrecords = 9999999.
ENDIF.
SELECT ccidbh,ccidms
FROM ytmm_mrdm_ccid
WHERE ccidbh IN @s_ccid
INTO TABLE @DATA(lt_ccid).
SELECT wrkst AS ccidbh
FROM mara
WHERE wrkst IN @s_ccid
APPENDING TABLE @lt_ccid.
IF sy-subrc EQ 0."获取描述
REFRESH:lt_thead,lt_text_headers.
"1、批量放入ID
LOOP AT lt_ccid INTO DATA(ls_ccid) WHERE ccidms IS INITIAL.
ls_thead-tdobject = 'MATERIAL'.
ls_thead-tdname = ls_ccid-ccidbh.
ls_thead-tdid = 'GRUN'.
ls_thead-tdspras = 1.
* APPEND ls_thead TO lt_thead.
ls_thead-tdspras = 'Z1'.
APPEND ls_thead TO lt_thead.
CLEAR ls_thead.
ENDLOOP.
lt_text_headers = CORRESPONDING #( lt_thead[] ).
"2、批量读取长文本数据
IF lt_thead[] IS NOT INITIAL.
CALL FUNCTION 'READ_TEXT_TABLE'
IMPORTING
text_table = lt_text_table
TABLES
text_headers = lt_text_headers
EXCEPTIONS
wrong_access_to_archive = 1.
IF sy-subrc EQ 0.
"3、生成需要需要的长文本
LOOP AT lt_ccid ASSIGNING FIELD-SYMBOL(<fs_ccid>).
LOOP AT lt_text_table INTO DATA(ls_text_table) WHERE header-tdname EQ <fs_ccid>-ccidbh.
LOOP AT ls_text_table-lines ASSIGNING FIELD-SYMBOL(<ls_line>).
<fs_ccid>-ccidms = <fs_ccid>-ccidms && <ls_line>-tdline.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
SORT lt_ccid BY ccidbh.
DELETE ADJACENT DUPLICATES FROM lt_ccid COMPARING ccidbh.
IF s_ccid[] IS NOT INITIAL.
DELETE lt_ccid WHERE ccidms NOT IN s_ccid.
ENDIF.
DESCRIBE TABLE lt_ccid LINES DATA(lv_lin).
IF lv_lin < 1.
RETURN.
ENDIF.
LOOP AT lt_ccid INTO ls_ccid
FROM 1 TO callcontrol-maxrecords.
record_tab-string(48) = ls_ccid-ccidbh.
record_tab-string+49(200) = ls_ccid-ccidms.
APPEND record_tab.
CLEAR: record_tab.
ENDLOOP.
IF record_tab[] IS NOT INITIAL.
callcontrol-step = 'DISP'.
ENDIF.
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.
ENDIF.
ENDFUNCTION.
类似在创建一个基本搜索帮助2
二、创建集中搜索帮助(注意点一定要要点击分配 不然一切都正常就是没办法把选择的数据带到页面上
三、绑定(也可以绑定表的元素里面)我这面是在dialog页面里面
如果在创建过程中有问题欢迎大家评论区留言一块讨论一块提高,感谢查看 希望对您有帮助