场景:
SAP参考销售订单开票,在创建完销售订单后,SAP会生成开票索引VKDFS,也就是VF04看到的开票清单,本文讨论此时SAP生成开票索引的关键实现过程。
相关程序:
FORM INDEX_VKDFS_AUFBAUEN
销售订单更新VKDFS开票索引的条件
if ( lvbup-fksaa ca 'AB'
and auft_cust_index ne '0' )
or ( auft_cust_index eq '1' ).
写入索引表VKDFS动作: INSERT VKDFS FROM TABLE XVKDFS ACCEPTING DUPLICATE KEYS.
IF SY-SUBRC NE 0.
LOOP AT VKDFSTAB WHERE VBELN NE SPACE.
DELETE FROM VKDFS WHERE VBELN = VKDFSTAB-VBELN.
ENDLOOP.
INSERT VKDFS FROM TABLE SAVE_VKDFS ACCEPTING DUPLICATE KEYS.
EXIT.
ENDIF.
VKDFS赋值过程关键性代码摘抄:
CLEAR VKDFS. "HP_386396
VKDFS-MANDT = SY-MANDT.
VKDFS-FKTYP = 'A'.
IF LVBAK-KNUMA IS INITIAL.
VKDFS-FKTYP = 'A'.
ELSE.
VKDFS-FKTYP = 'B'.
ENDIF.
VKDFS-VKORG = LVBAK-VKORG.
VKDFS-FKDAT = LVBKD-FKDAT.
VKDFS-KUNNR = KUNNR_AG.
VKDFS-ADRNR = ADRNR_AG.
VKDFS-FKART = LVBAK-FKARA.
VKDFS-LLAND = LAND1_WE_POS.
VKDFS-VBELN = LVBAK-VBELN.
VKDFS-VBTYP = LVBAK-VBTYP.
VKDFS-FAKSK = LVBAK-FAKSK.VKDFS-VTWEG = LVBAK-VTWEG.
VKDFS-SPART = LVBAK-SPART.
VKDFS-VSTEL = GF_VSTEL.
IF LVBAP-KOWRR IS INITIAL.
VKDFS-NETWR = LVBAP-NETWR.
ENDIF.
VKDFS-WAERK = LVBAK-WAERK.
IF NOT LVBKD-FPLNR IS INITIAL AND
( LVBAP-FKREL EQ 'I' OR "n_573632
LVBAP-VBELN IS INITIAL ) AND "n_576805
LVBKD-FPLNR EQ LFPLT-FPLNR.
IF LVBAP-KOWRR IS INITIAL.
VKDFS-NETWR = LFPLT-FAKWR.
ENDIF.
VKDFS-FKDAT = LFPLT-AFDAT.
IF NOT LVBAP-FAKSP IS INITIAL.
VKDFS-FAKSK = LVBAP-FAKSP.
ENDIF.
IF NOT LFPLT-FAKSP IS INITIAL.
VKDFS-FAKSK = LFPLT-FAKSP.
ENDIF.
IF NOT LFPLT-FKARV IS INITIAL.
VKDFS-FKART = LFPLT-FKARV.
ENDIF.
ENDIF.