物料查询F4帮助增强(添加筛选条件…

需求:

1、通过F4快捷按钮查询物料主数据时,在查询界面增加已删除/冻结物料点选按钮(如上图)

2、系统默认不点选已删除/冻结物料,查询结果不包括已删除和已冻结物料;当用户点选已删除/冻结物料时,查询结果包括已删除和已冻结物料。

3、当物料主数据MARA-MATNR的跨工厂物料状态MARA-MSTAE为非空时表示该物料已经冻结

4、当物料主数据MARA-MATNRMARA-LVORM字段为“X”表示该物料已删除

物料查询F4帮助增强(添加筛选条件)

实现:

首先找到帮助

MM01下,F1查看计算设置

物料查询F4帮助增强(添加筛选条件)

物料查询F4帮助增强(添加筛选条件)

找到帮助MAT1
物料查询F4帮助增强(添加筛选条件)


 

双击帮助MAT1

默认:

物料查询F4帮助增强(添加筛选条件)


 

点击查找物料编号的帮助     MAT1_A

物料查询F4帮助增强(添加筛选条件)

物料查询F4帮助增强(添加筛选条件)

物料查询F4帮助增强(添加筛选条件)

物料查询F4帮助增强(添加筛选条件)


进入编辑状态,需要basis提供key

物料查询F4帮助增强(添加筛选条件)

点击table field

物料查询F4帮助增强(添加筛选条件)

勾选需要的字段点击复制

物料查询F4帮助增强(添加筛选条件)

返回到上一层,将需要的字段添加进去:

物料查询F4帮助增强(添加筛选条件)

激活后如下:
物料查询F4帮助增强(添加筛选条件)

上面的方法其实是修改了标准视图,其实不是很建议

可以自己建帮助,然后配置的时候把自建的帮助添加进去,修改应该是最小的,如下:

为了达到最开始的目的,冻结和删除在一个框中确定,需要自己写代码


首先创建帮助

物料查询F4帮助增强(添加筛选条件)

这个FM的参数是固定的,可以从其他地方copy(有时候写上FM名字直接双击就能自动创建,我的系统双击没反应,所以从别的地方copy过来的)

物料查询F4帮助增强(添加筛选条件)

物料查询F4帮助增强(添加筛选条件)

里面初始代码页是固定的

我自己添加的:

物料查询F4帮助增强(添加筛选条件)

对这个函数不是很熟悉

通过debug发现把 删除标记 值赋给了Shlp-selopt

              最大显示数量 赋值给了callcontrol-maxrecords

物料查询F4帮助增强(添加筛选条件)

 

然后配置自建帮助,需要basiskey

物料查询F4帮助增强(添加筛选条件)
MAT1_A是物料查询时各个页签的帮助
物料查询F4帮助增强(添加筛选条件)
点进去

在MAT1_A中添加自建帮助

物料查询F4帮助增强(添加筛选条件)
添加完后

进入编辑模式,分配参数
物料查询F4帮助增强(添加筛选条件)
一般会有默认的,推荐字段,可以修改,比如仅仅保留物料,也可以直接点击复制按钮
物料查询F4帮助增强(添加筛选条件)

然后激活

激活后执行如下:

物料查询F4帮助增强(添加筛选条件)


附:FM内代码

FUNCTION zcom_se_f4_help_exit.

*"--------------------------------------------------------------------

*"*"本地接口:

*"  TABLES

*"      SHLP_TAB TYPE  SHLP_DESCT

*"      RECORD_TAB STRUCTURE  SEAHLPRES

*"  CHANGING

*"     REFERENCE(SHLP) TYPE  SHLP_DESCR

*"     REFERENCE(CALLCONTROL) TYPE  DDSHF4CTRL

*"--------------------------------------------------------------------


  DATA:

        BEGIN OF str_help,

          maktg TYPE  maktg  ,

          spras TYPE  spras  ,

          matnr TYPE  matnr  ,

          lvorm TYPE  lvorm  ,

          mstae TYPE  mstae  ,

       END OF str_help.


  DATA:

        l_it_show LIKE TABLE OF str_help WITH HEADER LINE.

************************************************************************

* This function module is designed to be used as a Search Help Exit

* within Search Help definitions in the ABAP dictionary.

*

* The function module incorporates a generic integration of the Search

* Engine Service (SES) into the F4 Search Help concept. Thus the F4

* Search Help integration for TREX-based searching can be done just by

* declaration, without further programming.

*

* Please read (click on!) "Function Module Documentation"

*

* Used template: F4IF_SHLP_EXIT_EXAMPLE (for more docu read there)

************************************************************************



*"----------------------------------------------------------------------

* 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'.


* Note:

* 'SELONE' is not processed for nested collective searchhelps.

* Therefore form STEP_SELONE is processed as well at 'PRESEL1'.

* There, obsolete elementary search helps can still be deactivated,

* although the actual search help is already an elementary one.


  IF callcontrol-step =  'SELONE'  OR

     callcontrol-step =  'PRESEL1'.

** Generic function module for F4 search help exit

** Delete inactive ESH search helps

*    CALL FUNCTION 'ESH_F4_HELP_EXIT'

*      TABLES

*        shlp_tab    = shlp_tab

*        record_tab  = record_tab

*      CHANGING

*        shlp        = shlp

*        callcontrol = callcontrol.

*

**                                      Don't process additional STEP. ..

*    RETURN.

  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'.

  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'.


    DATA:

          l_lvorm LIKE LINE OF shlp-selopt.

    CLEAR l_lvorm.

    READ TABLE shlp-selopt INTO l_lvorm INDEX 1.


    IF shlp-selopt IS NOT INITIAL.

      SELECT

      makt~maktx

      makt~spras

      mara~matnr

      mara~lvorm

      mara~mstae

      FROM mara

      INNER JOIN makt ON ( makt~matnr = mara~matnr )

      UP TO callcontrol-maxrecords ROWS

      INTO TABLE l_it_show

      WHERE lvorm = l_lvorm-low

          OR mstae <> space.


    ELSE.

      SELECT

      makt~maktx

      makt~spras

      mara~matnr

      mara~lvorm

      mara~mstae

      FROM mara

      INNER JOIN makt ON ( makt~matnr = mara~matnr )

      UP TO callcontrol-maxrecords ROWS

      INTO TABLE l_it_show

      WHERE lvorm = ''

          and mstae = space.

    ENDIF.



    CALL FUNCTION 'F4UT_RESULTS_MAP'

      TABLES

        shlp_tab          = shlp_tab[]

        record_tab        = record_tab[]

        source_tab        = l_it_show

      CHANGING

        shlp              = shlp

        callcontrol       = callcontrol

      EXCEPTIONS

        illegal_structure = 1

        OTHERS            = 2.


    IF li_show[] IS NOT INITIAL.

      callcontrol-step = 'DISP'.

    ELSE.

      callcontrol-step = 'SELECT'.

    ENDIF.


**          Don't process additional STEP. ..

*    RETURN.

  ENDIF.


ENDFUNCTION.




http://blog.sina.com.cn/sapliumeng
原文地址:https://www.cnblogs.com/senlinmu110/p/3802150.html