SAP 搜索帮助
SAP一个很强大的功能就是无所不在的搜索帮助,如果使用系统的标准字段如MATNR AUFNR 等,都会有相应的搜索帮助,但是对于自建的表格,就得自己制作搜索帮助了,下面简单介绍制作基本搜索帮助
1.SE11 进入创建页面 点击搜索帮助 输入要创建的名字,如ZTEST_SERHCH_HELP
点击创建 选择基本索引搜索帮助 进去后会有两个页签 其中 ATTRIBUTE 页签基本可以不去关注 这里主要看一下definition页签 下面介绍下definition页签的几个重要属性
1.SELECTION METHOD 这里填的就是取数据的表
2.对话类型 有A C D三个选项 A和C 都是先弹出选择界面 然后在弹出选择列表 D是跳过选择界面直接弹出选择列表 这里使用C
3.SERCH HELP EXIT 只是系统留下的出口,可以在这里进行数据控制,比如限制选择条件,权限检查等等
4.搜索帮助参数 就是要显示出来的字段 IMP就是输入字段 EXP就是输出字段 必须指定所在列
这样一个简单的搜索帮助就完成了
1.如果想要把搜索帮助设为某个数据元素的默认搜索帮助,进入到要设置的数据元素中去,在第三个页签中输入想要关联的搜索帮助名字,PARAMETERS 为要和关联字段(搜索帮助参数中的字段)
2.如果在屏幕上想要使用自己创建的搜索帮助,可以使用下面语句
PARAMETERS:P_MATNR TYPE MARA-MATNR MATCHCODE OBJECT ZTEST_SERHCH_HELP .
3.如果先要对搜索帮助进行一些限制 可以在SERCH HELP EXIT中编程 首先复制系统标准函数 F4IF_SHLP_EXIT_EXAMPLE 到自己要创建的函数(函数和函数组的创建这里就不介绍了),改函数里面有详细的使用介绍,只要英文还行基本都可以看得懂,这里就不多说了,这里举一个例子简单说明,该例子是限制物料编号
DATA:lw_line TYPE ddshselopt.
"设置默认的筛选条件
IF callcontrol-step = 'SELECT'.
lw_line-shlpname = 'Z3768_TEST'. "搜索帮助名字
lw_line-shlpfield = 'MATNR'. "要进行条件限制的字段
lw_line-sign = 'I'.
lw_line-option = 'EQ'.
lw_line-low = '178'.
APPEND lw_line TO shlp-selopt.
ENDIF.
lw_line-shlpname = 'Z3768_TEST'. "搜索帮助名字
lw_line-shlpfield = 'MATNR'. "要进行条件限制的字段
lw_line-sign = 'I'.
lw_line-option = 'EQ'.
lw_line-low = '178'.
APPEND lw_line TO shlp-selopt.
ENDIF.
*下面转自老白的博客
REPORT ztest.
TYPES: shlp_descr_t TYPE shlp_descr .
DATA: BEGIN OF itab OCCURS 0 ,
matnr LIKE mara-matnr ,
maktx LIKE makt-maktx ,
END OF itab.
DATA: return_tab TYPE ddshretval OCCURS 0 .
PARAMETERS: p_matnr LIKE itab-matnr ,
p_maktx LIKE itab-maktx .
INITIALIZATION.
SELECT matnr maktx INTO TABLE itab FROM makt UP TO 20 ROWS
WHERE spras = '1'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr .
PERFORM f4.
*&---------------------------------------------------------------------*
*& Form f4
*&---------------------------------------------------------------------*
FORM f4.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_MATNR'
value_org = 'S'
callback_program = sy-repid
callback_form = 'CB_FORM'
TABLES
value_tab = itab
return_tab = return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDFORM. "f4
*&---------------------------------------------------------------------*
*& Form cb_form
*&---------------------------------------------------------------------*
FORM cb_form TABLES record_tab STRUCTURE seahlpres
CHANGING shlp TYPE shlp_descr_t
callcontrol LIKE ddshf4ctrl.
DATA: interface LIKE LINE OF shlp-interface.
READ TABLE shlp-interface INTO interface INDEX 1.
interface-shlpfield+4(1) = '2'.
interface-valfield = 'P_MAKTX'.
APPEND interface TO shlp-interface.
ENDFORM. "bo_callback_form
REPORT ztest.
TYPES: shlp_descr_t TYPE shlp_descr .
DATA: BEGIN OF itab OCCURS 0 ,
matnr LIKE mara-matnr ,
maktx LIKE makt-maktx ,
END OF itab.
DATA: return_tab TYPE ddshretval OCCURS 0 .
PARAMETERS: p_matnr LIKE itab-matnr ,
p_maktx LIKE itab-maktx .
INITIALIZATION.
SELECT matnr maktx INTO TABLE itab FROM makt UP TO 20 ROWS
WHERE spras = '1'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr .
PERFORM f4.
*&---------------------------------------------------------------------*
*& Form f4
*&---------------------------------------------------------------------*
FORM f4.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_MATNR'
value_org = 'S'
callback_program = sy-repid
callback_form = 'CB_FORM'
TABLES
value_tab = itab
return_tab = return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDFORM. "f4
*&---------------------------------------------------------------------*
*& Form cb_form
*&---------------------------------------------------------------------*
FORM cb_form TABLES record_tab STRUCTURE seahlpres
CHANGING shlp TYPE shlp_descr_t
callcontrol LIKE ddshf4ctrl.
DATA: interface LIKE LINE OF shlp-interface.
READ TABLE shlp-interface INTO interface INDEX 1.
interface-shlpfield+4(1) = '2'.
interface-valfield = 'P_MAKTX'.
APPEND interface TO shlp-interface.
ENDFORM. "bo_callback_form