业务需求:在VA05报表界面增强两个字段(BELNR1/BELNR2).
第一步:扩展VA05相关表结构
由于新增的字段是按照销售订单行维度展示的,所以本篇加在VBAP表里(不扩展表字段,直接写增强,会DUMP).
第二步:代码增强
增强点->SE18->BADI_SDOC_WRAPPER
METHOD if_badi_sdoc_wrapper~adapt_result_comp.INSERT VALUE #( table = 'VBAP' field = 'ZBELNR1' name = 'ZBELNR1' text = '收入凭证编号' ) INTO TABLE ct_result_comp.INSERT VALUE #( table = 'VBAP' field = 'ZBELNR2' name = 'ZBELNR2' text = '成本凭证编号' ) INTO TABLE ct_result_comp.ENDMETHOD.
METHOD if_badi_sdoc_wrapper~post_processing.DATA : lv_xref1_hd TYPE char20 .ASSIGN COMPONENT 'VBELN' OF STRUCTURE cs_result TO FIELD-SYMBOL(<fs_vbeln>).ASSIGN COMPONENT 'POSNR' OF STRUCTURE cs_result TO FIELD-SYMBOL(<fs_posnr>).ASSIGN COMPONENT 'ZBELNR1' OF STRUCTURE cs_result TO FIELD-SYMBOL(<fs_belnr1>).ASSIGN COMPONENT 'ZBELNR2' OF STRUCTURE cs_result TO FIELD-SYMBOL(<fs_belnr2>).lv_xref1_hd = <fs_vbeln> && <fs_posnr> .SELECT SINGLE * FROM bkpf INTO @DATA(ls_bkpf) WHERE xref1_hd = @lv_xref1_hd .IF ls_bkpf IS NOT INITIAL .SELECT SINGLE COUNT(*) FROM bseg WHERE belnr = ls_bkpf-belnr AND koart = 'D' .IF sy-subrc = 0 .<fs_belnr1> = ls_bkpf-belnr .ENDIF .IF ls_bkpf-belnr <> <fs_belnr1> .<fs_belnr2> = ls_bkpf-belnr .ENDIF .ENDIF .ENDMETHOD.
这样字段就加好了