近期接到需求,为VF02做屏幕增强,在抬头加一个子屏幕
1、为主表(VBRK)增加一个附加字段
2、创建一个函数组或程序来存放相关增强代码
3、创建6001屏幕(6001为抬头,6002为行项目)
4、编写PBO逻辑代码
PROCESS BEFORE OUTPUT.
MODULE STATUS_6001.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_6002.
MODULE status_6001 OUTPUT.
IF sy-tcode EQ 'VF03'.
LOOP AT SCREEN.
screen-input = '0'.
MODIFY SCREEN .
ENDLOOP.
ENDIF.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
5、主程序SAPMV60A中进行增强
抬头为6001,且与6101相关联(行项目为6002,与6102关联)
添加相关增强
下图为增强的创建方式
若隐式增强不显示则需:选择菜单编辑–>增强操作->显示隐式增强选项。(补一张图)
PERFORM cust_head_active IN PROGRAM saplzfico_mv60a1 IF FOUND
USING vbrp vbrk vbuk
CHANGING gs_cust_tab-item_caption
gs_cust_tab-item_program
gs_cust_tab-item_dynpro
gs_cust_tab-item_caption.
TABSTRIP_TAB06 = gs_cust_tab-item_caption. "必须要加,不加VF02不显示增强
在自建的函数组包含文件中写FORM逻辑
FORM cust_head_active USING fvbrp TYPE vbrp
fvbrk TYPE vbrk
fvbuk TYPE vbuk
CHANGING
fcaption TYPE char40
fprogram TYPE syrepid
fdynpro TYPE sydynnr
ftab TYPE char40 .
PERFORM check_badi_activate.
CHECK badi_activate EQ abap_false .
fcaption = '金税发票号'(c01).
fprogram = 'SAPLZFICO_MV60A1'.
fdynpro = '6001'.
ftab = fcaption.
LOOP AT SCREEN.
IF screen-name EQ 'TABSTRIP_TAB06' .
screen-active = 1.
screen-invisible = 0 .
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDFORM .
业务加载项BADI_SD_CUST_HEAD的另外三个方法是用在屏幕6101中,建议不管当前是否有使用到,都应当进行增强到函数组ZFICO_MV60A1中以预留将来可以方便的修改,所有的增强实施都应当使用同一个名称ZEFICO_SAPMV60A1,这样我们可以方便地使用SE20查看所有的增强。
cust_head_set_data
PERFORM cust_head_set_data IN PROGRAM saplzfico_mv60a1 IF FOUND
USING vbrk
vbrp
xvbrp_tabix
t180
CHANGING rv60a
yvbadr[]
xvbadr[]
xvbpa[]
yvbrk[]
xvbrk[]
yvbpa[]
xvbrp[]
yvbrp[]
vbrk.
GS_CUST_TAB-HEAD_PROGRAM = 'SAPLZFICO_MV60A1'.
GS_CUST_TAB-HEAD_DYNPRO = '6001'.
* 发票数据到子屏幕
FORM cust_head_set_data USING f_vbrk TYPE vbrk
f_vbrp TYPE vbrp
f_tabix TYPE sytabix
ft180 TYPE t180
CHANGING
frv60a TYPE rv60a
fxyvbadr TYPE shp_sadrvb_t
fxvbadr TYPE shp_sadrvb_t
fxvbpa TYPE va_vbpavb_t
fxyvbrk TYPE vbrkvb_t
fxvbrk TYPE vbrkvb_t
fxyvbpa TYPE va_vbpavb_t
fxvbrp TYPE vbrpvb_t
fxyvbrp TYPE vbrpvb_t
fvbrk TYPE vbrk.
PERFORM check_badi_activate.
CHECK badi_activate EQ abap_false .
vbrk = a_vbrk = f_vbrk.
a_vbrkvb = f_vbrk.
vbrp = a_vbrp = f_vbrp.
ENDFORM.
cust_head_pass_fcode
PERFORM cust_head_pass_code IN PROGRAM saplzfico_mv60a1 IF FOUND
USING fcode_gleiche_seite fcode.
FORM cust_head_pass_code USING ffcode_same_page TYPE fcode
ffcode TYPE fcode .
PERFORM check_badi_activate.
CHECK badi_activate EQ abap_false .
* check ADD ON active
* check not a_gtm_active is initial.
* check enhancement active
* check a_enhance = 2 or not a_cc_active is initial.
* Fcode setzen
CALL FUNCTION 'WB2_TRADE_PASS_FCODE_ITEM'
EXPORTING
i_fcode = ffcode.
ENDFORM.
cust_head_get_data
PERFORM cust_head_get_data IN PROGRAM saplzfico_mv60a1 IF FOUND
USING t180
CHANGING vbrk
vbrp
rv60a
xvbpa[]
yvbrk[]
xvbrk[]
yvbadr[]
xvbadr[]
yvbpa[]
xvbrp[]
yvbrp[]
fcode.
* 子屏幕到发票数据
FORM cust_head_get_data USING
ft180 TYPE t180
CHANGING
fvbrk TYPE vbrk
fvbrp TYPE vbrp
frv60a TYPE rv60a
fxvbpa TYPE va_vbpavb_t
fxyvbrk TYPE vbrkvb_t
fxvbrk TYPE vbrkvb_t
fxyvbadr TYPE shp_sadrvb_t
fxvbadr TYPE shp_sadrvb_t
fxyvbpa TYPE va_vbpavb_t
fxvbrp TYPE vbrpvb_t
fxyvbrp TYPE vbrpvb_t
ffcode TYPE fcode.
PERFORM check_badi_activate.
CHECK badi_activate EQ abap_false .
CALL FUNCTION 'WB2_TRADE_DATA_GET_HEADER'
IMPORTING
e_header_data = a_vbrk.
* Get fcode
CALL FUNCTION 'WB2_TRADE_FETCH_FCODE'
IMPORTING
e_fcode = ffcode.
* get status
CALL FUNCTION 'WB2_PROCESS_IV_GET_STATUS'
EXCEPTIONS
status_error = 1
OTHERS = 2.
* status ok
CHECK sy-subrc = 0.
* set data
fvbrk = a_vbrk.
CALL FUNCTION 'WB2_PROCESS_SERVICE_IV_FREE'.
ENDFORM.
check_badi_activate
FORM check_badi_activate .
INCLUDE wb2_param_control_global.
DATA:lr_badi TYPE REF TO if_ex_badi_sd_cust_item .
CALL FUNCTION 'GET_HANDLE_SD_CUST_ITEM'
IMPORTING
handle = lr_badi
active = badi_activate.
IF badi_activate EQ 'X'.
IF cl_wb2_check_add_on_active=>a_gtm_active EQ ' '.
badi_activate = 'X' .
ENDIF.
IF cl_wb2_check_add_on_active=>a_enhance NE addon_all_active.
badi_activate = ' ' .
ENDIF.
ENDIF.
ENDFORM.
LZFICO_MV60A1TOP(部分变量没用上,懒得删了)
FUNCTION-POOL zfico_mv60a1. "MESSAGE-ID ..
* INCLUDE LZFICO_MV60A1D... " Local class definition
TABLES:vbrk,vbrp.
DATA:badi_activate TYPE abap_bool.
DATA: a_gtm_active TYPE abap_bool,
a_enhance TYPE abap_bool,
a_cc_active TYPE abap_bool.
DATA: a_vbrk TYPE vbrk,
* a_vbrkvb TYPE vbrk,
a_vbrkvb TYPE vbrkvb,
a_vbrp TYPE vbrp.
DATA a_actyp TYPE aktyp.