1.在销售发票抬头表中增加增强字段
2.创建处理程序
主程序SAPMV60A中的所有包含文件都是以MV60AF打头的,所以我们创建一个独立的程序 SE38(ZSDU0001) 来存放所有的处理代码
创建屏幕9001,确保屏幕类型为子屏幕
屏幕字段可从VBRK表中获取
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
*&---------------------------------------------------------------------* *& Module PBO_9001 OUTPUT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* MODULE pbo_9001 OUTPUT. CASE sy-ucomm. WHEN 'VF03'. LOOP AT SCREEN. screen-input = '0'. MODIFY SCREEN. ENDLOOP. ENDCASE. ENDMODULE.
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
ZSDU0001报表程序代码参考
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
*&---------------------------------------------------------------------* *& Report ZSDU0001 *&---------------------------------------------------------------------* *&作者:HW *&日期:20240329 *&描述:销售发票屏幕增强程序 *&---------------------------------------------------------------------* REPORT zsdu0001. DATA:badi_active TYPE sap_bool. FORM cust_head_activate USING fvbrk TYPE vbrk fvbuk TYPE vbuk fxvbpa TYPE va_vbpavb_t CHANGING fcaption TYPE char40 fprogram TYPE sy-repid fdynpro TYPE sy-dynnr ftab 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 vbrk ft180 TYPE t180 CHANGING fxvbpa TYPE va_vbpavb_t fxyvbrk TYPE vbrkvb_t fxvbrk TYPE vbrkvb_t frv60a TYPE rv60a fxyvbadr TYPE shp_sadrvb_t fxvbadr TYPE shp_sadrvb_t fxyvbpa TYPE va_vbpavb_t fxvbrp TYPE vbrpvb_t fxyvbrp TYPE vbrpvb_t fvbrk TYPE vbrk. PERFORM frm_check_badi_active. CHECK:badi_active EQ abap_false. ENDFORM. FORM cust_head_pass_fcode USING ffcode_same_page TYPE fcode ffcode TYPE fcode. PERFORM frm_check_badi_active. CHECK:badi_active EQ abap_false. ENDFORM. FORM cust_head_get_data USING ft180 TYPE t180 CHANGING fvbrk TYPE vbrk fxvbpa TYPE va_vbpavb_t fxyvbrk TYPE vbrkvb_t fxvbrk TYPE vbrkvb_t frv60a TYPE rv60a 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 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' IMPORTING handle = lr_badi active = 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.
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
3.屏幕增强
在主程序SAPMV60A 的 屏幕6001中 双击 CUST_HEAD_ACTIVATE 直到对应的FORM
显示隐式增强->创建实施->使用 PERFORM … IN PROGRAM … IF FOUND 创建增强
FORM涉及详细的逻辑代码,在ZSDU0001程序中编写,在上边
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
ENHANCEMENT 1 ZE_SAPMV60A. "active version PERFORM cust_head_activate IN PROGRAM zsdu0001 IF FOUND USING vbrk vbuk xvbpa[] CHANGING gs_cust_tab-head_caption gs_cust_tab-head_program gs_cust_tab-head_dynpro tabstrip_tab06. ENDENHANCEMENT.
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
业务加载项BADI_SD_CUST_HEAD的另外三个方法是用在屏幕6101中,建议不管当前是否有使用到,都应当进行增强到程序ZMV60AFZCUST_HEAD中以预留将来可以方便的修改,所有的增强实施都应当使用同一个名称ZE_SAPMV60A,这样我们可以方便地使用SE20查看所有的增强
perform cust_head_set_data->(FORM涉及详细的逻辑代码,在ZSDU0001程序中编写,在上边)
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
ENHANCEMENT 2 ZE_SAPMV60A. "active version PERFORM cust_head_set_data IN PROGRAM zsdu0001 IF FOUND USING vbrk t180 CHANGING xvbpa[] yvbrk[] xvbrk[] rv60a yvbadr[] xvbadr[] yvbpa[] xvbrp[] yvbrp[] vbrk. ENDENHANCEMENT.
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
perform cust_head_pass_fcode
ENHANCEMENT 3 ZE_SAPMV60A. "active version PERFORM cust_head_pass_fcode IN PROGRAM ZSDU0001 IF FOUND USING fcode_gleiche_seite fcode. ENDENHANCEMENT.
perform cust_head_get_data
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
ENHANCEMENT 4 ZE_SAPMV60A. "active version PERFORM cust_head_get_data IN PROGRAM zsdu0001 IF FOUND USING t180 CHANGING vbrk xvbpa[] yvbrk[] xvbrk[] rv60a yvbadr[] xvbadr[] yvbpa[] xvbrp[] yvbrp[] fcode. ENDENHANCEMENT.
![复制代码](https://assets.cnblogs.com/images/copycode.gif)
用VF02修改发票凭证,转到抬头–>抬头增强字段,填写相关的数据并保存,然后检查表VBRK发现增强字段已经保存成功
用VF03查看发票凭证,发现页签是只读格式,创建增强字段成功
以上为抬头屏幕增强,行项目增强在6002屏幕上
可参考链接:屏幕增强 - 3.为发票凭证VF01/2/3增加自定义选项卡 - 《ABAP 开发笔记》 - 极客文档 (geekdaxue.co)
行项目屏幕增强同以上方法,可参考链接:VF01/VF02/VF03销售发票屏幕增强实例_vf01屏幕增强-CSDN博客
BAPI中如何传参
"声明对象 CREATE DATA lr_header_bapi_ext. lo_bapi_mapping = cl_cfd_bapi_mapping=>get_instance( ). "赋值 LOOP AT billingdatain. lv_vgbel = billingdatain-ref_doc. lv_vgpos = billingdatain-ref_item. lv_key = lv_vgbel && lv_vgpos. lr_header_bapi_ext->key = lv_key. lr_header_bapi_ext->data-zzyggh = iv_zzyggh. lr_header_bapi_ext->data-zzygxm = iv_zzygxm. lr_header_bapi_ext->data-zzjspzt = iv_zzjspzt. "传入增强字段 CALL METHOD lo_bapi_mapping->map_to_bapiparex_single EXPORTING ir_source_structure = lr_header_bapi_ext CHANGING ct_bapiparex = extensionin1. ENDLOOP. CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE' EXPORTING creatordatain = creatordatain testrun = testrun posting = posting TABLES billingdatain = billingdatain conditiondatain = conditiondatain ccarddatain = ccarddatain textdatain = textdatain errors = errors return = return success = success extensionin = extensionin1 partnerdatain = partnerdatain nfmetallitms = nfmetallitms. FREE MEMORY ID 'ZBAPI_BILLINGDOC_CREATE'.
FORM userexit_fill_vbrk_vbrp. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form USEREXIT_FILL_VBRK_VBRP, Start A *$*$-Start: (1)---------------------------------------------------------------------------------$*$* ENHANCEMENT 1 ZEN_VBRK_YG. "active version vbrk-zzyggh = xkomfkgn-zzyggh. vbrk-zzygxm = xkomfkgn-zzygxm. vbrk-zzjspzt = xkomfkgn-zzjspzt. ENDENHANCEMENT. *$*$-End: (1)---------------------------------------------------------------------------------$*$* * Example: change Tax country * VBRK-LANDTX = T001-LAND1. DATA:iv_kurrf TYPE kurrf. IMPORT iv_kurrf = iv_kurrf FROM MEMORY ID 'ZBAPI_BILLINGDOC_CREATE'. IF iv_kurrf IS NOT INITIAL. * FREE MEMORY ID 'ZBAPI_BILLINGDOC_CREATE'. vbrk-kurrf = iv_kurrf. CLEAR iv_kurrf. ENDIF. ENDFORM.标签:VF01,VF02,VF03,cust,head,active,vbrk,TYPE,&--------------------------------- From: https://www.cnblogs.com/ap-ad-java-abap/p/18356881