1
文档说明
之前发表过BP客户主数据的页签增强,本篇文档介绍BP供应商主数据公司视图下新增页签增强
BP客户主数据新增页签增强
斌将军,公众号:斌将军BP新增页签增强与上篇文章相比,因为在公司视图下新增,代码有些区别,本篇文章也只介绍代码方面的实现,配置方面仍可以参考《BP客户主数据新增页签增强》中的配置,只要注意区分客户和供应商即可,本文章不在赘述。
除此之外,在屏幕中画输入框时,放弃使用全局结构GS_LFB1-ZXX定义,而是参照了表LFB1-ZXX进行定义,将表字段对应的域值也显示为搜索帮助,更加方便使用。
2
实现过程
增强字段
ZMM19_PBO
"--------------------@斌将军--------------------
FUNCTION zmm19_pbo.
*"-----------------------
*"*"本地接口:
*"-----------------------
DATA:lt_lfb1 TYPE TABLE OF lfb1,
lv_lifnr TYPE lfb1-lifnr,
lv_bukrs TYPE lfb1-bukrs.
lv_lifnr = cvi_bdt_adapter=>get_current_vendor( ).
lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
IF lv_bukrs IS INITIAL.
CLEAR:lfb1.
ELSE.
cvi_bdt_adapter=>data_pbo(
EXPORTING
i_table_name = table_name_lfb1
IMPORTING
e_data_table = lt_lfb1[]
).
READ TABLE lt_lfb1 INTO lfb1 WITH KEY lifnr = lv_lifnr bukrs = lv_bukrs.
IF sy-subrc EQ 0.
gs_lfb1 = lfb1.
ELSE.
CLEAR:gs_lfb1,lfb1.
ENDIF.
ENDIF.
ENDFUNCTION.
"--------------------@斌将军--------------------
ZMM19_PAI
"--------------------@斌将军--------------------
FUNCTION zmm19_pai.
*"----------------------
*"*"本地接口:
*"----------------------
DATA: lt_lfb1 TYPE TABLE OF lfb1,
lv_lifnr TYPE lfb1-lifnr,
lv_bukrs TYPE lfb1-bukrs.
FIELD-SYMBOLS: LIKE LINE OF lt_lfb1.
CHECK cvi_bdt_adapter=>is_direct_input_active( ) = false.
CHECK cvi_bdt_adapter=>get_current_company_code( ) IS NOT INITIAL.
"公司代码
lv_lifnr = cvi_bdt_adapter=>get_current_vendor( ).
lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
cvi_bdt_adapter=>get_current_bp_data(
EXPORTING
i_table_name = table_name_lfb1
IMPORTING
e_data_table = lt_lfb1[]
).
IF lt_lfb1[] IS INITIAL.
IF lfb1 IS NOT INITIAL.
lfb1-lifnr = lv_lifnr.
lfb1-bukrs = lv_bukrs.
IF lfb1-lifnr IS NOT INITIAL AND lfb1-bukrs IS NOT INITIAL.
APPEND lfb1 TO lt_lfb1.
ENDIF.
ENDIF.
ELSE.
READ TABLE lt_lfb1 ASSIGNING WITH KEY lifnr = lv_lifnr bukrs = lv_bukrs.
IF sy-subrc EQ 0.
<lfb1>-zgmp = lfb1-zgmp.
ENDIF.
ENDIF.
cvi_bdt_adapter=>data_pai(
i_table_name = table_name_lfb1
i_data_new = lt_lfb1[]
i_validate = false
).
ENDFUNCTION.
"--------------------@斌将军--------------------
ZMM19_EVENT_DSAVB
"--------------------@斌将军--------------------
FUNCTION zmm19_event_dsavb.
*"-----------------------
*"*"本地接口:
*"-----------------------
DATA:lt_lfb1 TYPE TABLE OF lfb1,
ls_lfb1 TYPE lfb1,
ls_lfb1_temp TYPE lfb1,
lv_lifnr TYPE lfb1-lifnr,
lv_bukrs TYPE lfb1-bukrs.
lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
ls_lfb1 = lfb1.
CHECK ls_lfb1 IS NOT INITIAL.
MOVE-CORRESPONDING gs_lfb1 TO ls_lfb1_temp.
ls_lfb1_temp-bukrs = lv_bukrs.
ls_lfb1_temp-zgmp = lfb1-zgmp."
APPEND ls_lfb1_temp TO lt_lfb1.
CALL FUNCTION 'CVIV_BUPA_LFB1_COLLECT'
EXPORTING
i_subname = 'ZMMS_LFB1' "附加结构
TABLES
t_lfb1 = lt_lfb1.
lv_lifnr = cvi_bdt_adapter=>get_current_vendor( ).
READ TABLE lt_lfb1 INTO ls_lfb1 WITH KEY lifnr = lv_lifnr bukrs = lv_bukrs.
IF sy-subrc EQ 0.
lfb1 = ls_lfb1.
gs_lfb1 = lfb1.
ENDIF.
ENDFUNCTION.
"--------------------@斌将军--------------------
ZMM19_EVENT_ISDAT
"--------------------@斌将军--------------------
FUNCTION zmm19_event_isdat.
*"---------------------
*"*"本地接口:
*"---------------------
CALL FUNCTION 'CVIV_BUPA_LFB1_GET'
IMPORTING
e_lfb1 = gs_lfb1.
lfb1-zgmp = gs_lfb1-zgmp. "增强字段赋值
ENDFUNCTION.
"--------------------@斌将军--------------------
ZMM19_EVENT_XCHNG
"--------------------@斌将军--------------------
FUNCTION zmm19_event_xchng.
*"------------------------
*"*"本地接口:
*" EXPORTING
*" REFERENCE(E_XCHNG) TYPE BOOLE_D
*"------------------------
IF gs_lfb1-zgmp <> lfb1-zgmp.
e_xchng = 'X'.
ENDIF.
ENDFUNCTION.
"--------------------@斌将军--------------------
ZMM19_EVENT_DLVE1
"--------------------@斌将军--------------------
FUNCTION zmm19_event_dlve1.
*"---------------------------
*"*"本地接口:
*"---------------------------
CLEAR:gs_lfb1,lfb1.
ENDFUNCTION.
"--------------------@斌将军--------------------
创建屏幕
此处参照表LFB1画输入框,可以自动将字段的域值作为搜索帮助
屏幕流
"--------------------@斌将军--------------------
*&--------------------------------------------
*& Module STATUS_9001 OUTPUT
*&--------------------------------------------
*&
*&--------------------------------------------
MODULE status_9001 OUTPUT.
CALL FUNCTION 'BUS_PBO'.
DATA:lv_bukrs TYPE lfb1-bukrs.
lv_bukrs = cvi_bdt_adapter=>get_current_company_code( ).
LOOP AT SCREEN.
IF screen-name+0(4) = 'LFB1'.
IF lv_bukrs = '3060'."
screen-active = '1'.
ELSE.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDMODULE.
*&--------------------------------------------
*& Module USER_COMMAND_9001 INPUT
*&--------------------------------------------
* text
*---------------------------------------------
MODULE user_command_9001 INPUT.
CALL FUNCTION 'BUS_PAI'.
ENDMODULE.
"--------------------@斌将军--------------------
—— 希望本篇文章对您有所帮助 ——