当前位置: 代码迷 >> 综合 >> SAP-ABAP-搜索帮助,及搜索帮助出口
  详细解决方案

SAP-ABAP-搜索帮助,及搜索帮助出口

热度:56   发布时间:2023-12-13 04:19:24.0

1.创建搜索帮助

2.使用说明

 2.1选择方法:指定搜索帮助表数据来源

2.2对话类型

2.2.1根据值集合的对话:如果数据量大于100条就不会直接展示数据,会先展示一个筛选界面

2.2.2立即显示值:就是立即展示数据源表中的全部数据

2.2.3具有值限制的对话:搜索帮助一开始不会将数据表中的全部数据展示出了,会给个筛选条件

2.3输入字段的建议搜索帮助:如果勾选该字段则不需要调用搜索帮助,在输入字段中直接输入与该字段同名的搜索帮助的输入参数的值,系统会根据你输入的内容在下方显示筛选结果.如果数据量大,或者搜索帮助附加字段太多了不建议使用

 2.4多列全文搜索;容错全文本搜索的精确值

        不使用搜索,而使用输入时,会将输入的数据按照字符串搜索表数据,按照搜索的精确值来显示最终数据。不建议使用,比较影响运行速度

2.5搜索帮助出口:可在创建的function中写入代码控制搜索帮助的数据。后面详细说明

2.6搜索帮助参数:展示出来的数据有哪些字段

2.7 IMP : 导入参量,用这些参量,从输入模板或处理屏幕的模板池中得到的值能复制给输入帮助处理。

2.8 EXP: 导出参量,用这些参量,从输入帮助处理得到的值能返回给输入模板。

2.9列表:该参数字段在命中列表的位置

2.10选择:该字段在选择屏幕中位置

2.11 选择:该参数的内容将告知用户该限制,但是无法更改该限制,这是可取的例如当该参数是导入参数或它有一个默认值。

2.12数据元素:参数字段对应的数据元素,必输

2.13已修改:如果一开始的搜索帮助变更了,此处勾会勾上,与使用用户无关

2.14缺省值:控制数据的默认值,默认值只能输入三种类型,a系统参数,如SY-DATUM;b内存get参数,如公司代码的内存参数BUK;c真正的默认值,需要用单引号包起来。

3.搜索帮助出口,SE37复制function--F4IF_SHLP_EXIT_EXAMPLE。注意命名和函数组,函数组要用Z开头的函数组,复制出来的名字建议按照ZFI_SH_CAR_TYPE_F4_EXIT类似命名,否则可能不让修改

复制完成的搜索帮助不会控制任何东西,在选择一次搜索帮助时会调用四次出口,用参数CALLCONTROL-STEP来控制是第几次

第一次:CALLCONTROL-STEP = 'SELONE'.
第一次的调用仅用于复合搜索帮助,在这次调用中它可以被使用以减少在SHLP_TAB中给出的基本搜索帮助的数量。

第二次:CALLCONTROL-STEP = 'PRESEL'.

第二次的调用我们可以修改一下限制条件,或者为了完全跳过对话框。

第三次:CALLCONTROL-STEP = 'SELECT'.

这一步可以用来完全取代数据选择。

第四次:CALLCONTROL-STEP = 'DISP'.

第四次调用之后前台将展示表RECORD_TAB的数据,我们可以在这次调用中增减这个表的数据来影响最终展示数据

附上某个例子的代码

FUNCTION zfi_sh_car_type_f4_exit.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     VALUE(SHLP) TYPE  SHLP_DESCR
*"     VALUE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
*"----------------------------------------------------------------------* EXIT immediately, if you do not want to handle this stepIF callcontrol-step <> 'SELONE' ANDcallcontrol-step <> 'SELECT' AND" AND SO ONcallcontrol-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'.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.DATA ls_tab TYPE seahlpres .CLEAR : record_tab,record_tab[].SELECT S~SIGN ,S~OPTION,S~LOW,S~HIGH FROM @SHLP-SELOPT AS S INTO TABLE @DATA(S_CAR) .SELECT  series_and_development_cod FROM zcar_type INTO TABLE @DATA(lt_car) WHERE series_and_development_cod IN @S_CAR.SORT lt_car BY series_and_development_cod .DELETE ADJACENT DUPLICATES FROM lt_car COMPARING ALL FIELDS .LOOP AT lt_car INTO DATA(ls_car).ls_tab-string+192(50) = ls_car-series_and_development_cod . ""字段SERIES_AND_DEVELOPMENT_COD在表ZCAR_TYPE中是第193的位置,所以新增行只能插入到这里ls_tab-string+242(22) = ls_car-series_and_development_cod .ls_tab-string(50) = ls_car-series_and_development_cod .ls_tab-string+50(22) = ls_car-series_and_development_cod .INSERT INITIAL LINE  INTO  record_tab INDEX 1 ASSIGNING FIELD-SYMBOL(<fs_tab>).<fs_tab> = ls_tab .ENDLOOP."    RECORD_TAB[ 1 ] = LS_TAB ."    SELECT SINGLE SERIES_AND_DEVELOPMENT_COD FROM ZCAR_TYPE INTO @DATA(LV_CAR) .ls_tab-string+192(50) = '通用车型' .ls_tab-string+242(22) = '通用车型' .ls_tab-string(50) = '通用车型' .ls_tab-string+50(22) = '通用车型' .INSERT INITIAL LINE  INTO  record_tab INDEX 1 ASSIGNING <fs_tab>.<fs_tab> = ls_tab .EXIT.ENDIF.
ENDFUNCTION.