0
点赞
收藏
分享

微信扫一扫

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

waaagh 2022-10-17 阅读 210

货铺QQ群号:834508274

进群统一修改群名片,例如BJ_ABAP_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合
不修改昵称会被不定期踢除,谢谢配合


需求:

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

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

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

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


物料查询F4帮助增强(添加筛选条件)----方式二_sed


这是几年前的实现方式,不知道现在是否有更多办法,仅供参考


首先创建帮助

物料查询F4帮助增强(添加筛选条件)----方式二_主数据_02

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

物料查询F4帮助增强(添加筛选条件)----方式二_sed_03


物料查询F4帮助增强(添加筛选条件)----方式二_微信_04

里面初始代码页是固定的


自己添加的:

物料查询F4帮助增强(添加筛选条件)----方式二_sed_05

对这个函数不是很熟悉


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


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

物料查询F4帮助增强(添加筛选条件)----方式二_sed_06

然后配置自建帮助 

物料查询F4帮助增强(添加筛选条件)----方式二_微信_07

MAT1_A是物料查询时各个页签的帮助

物料查询F4帮助增强(添加筛选条件)----方式二_sed_08

点进去


在MAT1_A中添加自建帮助

物料查询F4帮助增强(添加筛选条件)----方式二_sed_09

添加完后


进入编辑模式,分配参数

物料查询F4帮助增强(添加筛选条件)----方式二_sed_10

然后激活

激活后执行如下

物料查询F4帮助增强(添加筛选条件)----方式二_主数据_11

参考代码

附: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.

举报

相关推荐

0 条评论