1.在销售发票抬头表中增加增强字段
2.创建处理程序
主程序SAPMV60A中的所有包含文件都是以MV60AF打头的,所以我们创建一个独立的程序 SE38(ZSDU0001) 来存放所有的处理代码
创建屏幕9001,确保屏幕类型为子屏幕
屏幕字段可从VBRK表中获取
*&---------------------------------------------------------------------* *& Module PBO_9001 OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE pbo_9001 OUTPUT.CASE sy-ucomm.WHEN 'VF03'.LOOP AT SCREEN.screen-input = '0'.MODIFY SCREEN.ENDLOOP.ENDCASE. ENDMODULE.
ZSDU0001报表程序代码参考
*&---------------------------------------------------------------------* *& Report ZSDU0001 *&---------------------------------------------------------------------* *&作者:HW *&日期:20240329 *&描述:销售发票屏幕增强程序 *&---------------------------------------------------------------------* REPORT zsdu0001.DATA:badi_active TYPE sap_bool.FORM cust_head_activate USING fvbrk TYPE vbrkfvbuk TYPE vbukfxvbpa TYPE va_vbpavb_tCHANGING fcaption TYPE char40fprogram TYPE sy-repidfdynpro TYPE sy-dynnrftab TYPE char40.PERFORM frm_check_badi_active.CHECK:badi_active EQ abap_false.fcaption = '抬头增强字段'. "页签名称fprogram = 'ZSDU0001'. fdynpro = '9001'.ftab = fcaption.LOOP AT SCREEN.IF screen-name EQ 'TABSTRIP_TAB06'.screen-active = 1.screen-invisible = 0.MODIFY SCREEN.ENDIF.ENDLOOP.ENDFORM. FORM cust_head_set_data USING f_vbrk TYPE vbrkft180 TYPE t180CHANGING fxvbpa TYPE va_vbpavb_tfxyvbrk TYPE vbrkvb_tfxvbrk TYPE vbrkvb_tfrv60a TYPE rv60afxyvbadr TYPE shp_sadrvb_tfxvbadr TYPE shp_sadrvb_tfxyvbpa TYPE va_vbpavb_tfxvbrp TYPE vbrpvb_tfxyvbrp TYPE vbrpvb_tfvbrk TYPE vbrk.PERFORM frm_check_badi_active.CHECK:badi_active EQ abap_false.ENDFORM. FORM cust_head_pass_fcode USING ffcode_same_page TYPE fcodeffcode TYPE fcode.PERFORM frm_check_badi_active.CHECK:badi_active EQ abap_false.ENDFORM. FORM cust_head_get_data USING ft180 TYPE t180CHANGING fvbrk TYPE vbrkfxvbpa TYPE va_vbpavb_tfxyvbrk TYPE vbrkvb_tfxvbrk TYPE vbrkvb_tfrv60a TYPE rv60afxyvbadr TYPE shp_sadrvb_tfxvbadr TYPE shp_sadrvb_tfxyvbpa TYPE va_vbpavb_tfxvbrp TYPE vbrpvb_tfxyvbrp TYPE vbrpvb_tffcode TYPE fcode.PERFORM frm_check_badi_active.CHECK:badi_active EQ abap_false.ENDFORM. *&---------------------------------------------------------------------* *& Module PBO_9001 OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE pbo_9001 OUTPUT.CASE sy-ucomm.WHEN 'VF03'.LOOP AT SCREEN.screen-input = '0'.MODIFY SCREEN.ENDLOOP.ENDCASE. ENDMODULE. *&---------------------------------------------------------------------* *& Form frm_check_badi_active *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_check_badi_active.INCLUDE wb2_param_control_global.DATA:lr_badi TYPE REF TO if_ex_badi_sd_cust_head.CALL FUNCTION 'GET_HANDLE_SD_CUST_HEAD'IMPORTINGhandle = lr_badiactive = badi_active.IF badi_active EQ abap_true.IF cl_wb2_check_add_on_active=>a_gtm_active EQ abap_false.badi_active = abap_false.ENDIF.IF cl_wb2_check_add_on_active=>a_enhance NE addon_all_active.badi_active = abap_false.ENDIF.ENDIF. ENDFORM.
3.屏幕增强
在主程序SAPMV60A 的 屏幕6001中 双击 CUST_HEAD_ACTIVATE 直到对应的FORM
显示隐式增强->创建实施->使用 PERFORM … IN PROGRAM … IF FOUND 创建增强
FORM涉及详细的逻辑代码,在ZSDU0001程序中编写,在上边
ENHANCEMENT 1 ZE_SAPMV60A. "active version PERFORM cust_head_activate IN PROGRAM zsdu0001 IF FOUNDUSING vbrk vbuk xvbpa[]CHANGING gs_cust_tab-head_captiongs_cust_tab-head_programgs_cust_tab-head_dynprotabstrip_tab06. ENDENHANCEMENT.
业务加载项BADI_SD_CUST_HEAD的另外三个方法是用在屏幕6101中,建议不管当前是否有使用到,都应当进行增强到程序ZMV60AFZCUST_HEAD中以预留将来可以方便的修改,所有的增强实施都应当使用同一个名称ZE_SAPMV60A,这样我们可以方便地使用SE20查看所有的增强
perform cust_head_set_data->(FORM涉及详细的逻辑代码,在ZSDU0001程序中编写,在上边)
ENHANCEMENT 2 ZE_SAPMV60A. "active versionPERFORM cust_head_set_data IN PROGRAM zsdu0001 IF FOUNDUSING vbrk t180CHANGING xvbpa[]yvbrk[]xvbrk[]rv60ayvbadr[]xvbadr[]yvbpa[]xvbrp[]yvbrp[]vbrk. ENDENHANCEMENT.
perform cust_head_pass_fcode
ENHANCEMENT 3 ZE_SAPMV60A. "active versionPERFORM cust_head_pass_fcode IN PROGRAM ZSDU0001 IF FOUNDUSING fcode_gleiche_seitefcode. ENDENHANCEMENT.
perform cust_head_get_data
ENHANCEMENT 4 ZE_SAPMV60A. "active version PERFORM cust_head_get_data IN PROGRAM zsdu0001 IF FOUNDUSING t180CHANGING vbrkxvbpa[]yvbrk[]xvbrk[]rv60ayvbadr[]xvbadr[]yvbpa[]xvbrp[]yvbrp[]fcode. ENDENHANCEMENT.
用VF02修改发票凭证,转到抬头–>抬头增强字段,填写相关的数据并保存,然后检查表VBRK发现增强字段已经保存成功
用VF03查看发票凭证,发现页签是只读格式,创建增强字段成功
以上为抬头屏幕增强,行项目增强在6002屏幕上
可参考链接:屏幕增强 - 3.为发票凭证VF01/2/3增加自定义选项卡 - 《ABAP 开发笔记》 - 极客文档 (geekdaxue.co)
行项目屏幕增强同以上方法,可参考链接:VF01/VF02/VF03销售发票屏幕增强实例_vf01屏幕增强-CSDN博客