SAP ABAP当修改销售订单抬头时,更新销售订单行项目
有时候在更新销售订单抬头的时候,需要根据抬头的字段来修改行项目的值。
增强点在程序MV45AFZZ里的FORM:userexit_save_document_prepare。代码如下图所示:
DATA: LS_YVBAP LIKE YVBAP.
IF SY-TCODE = 'VA02'. "当修改的时候
LOOP AT XVBAP.
IF XVBAP-UPDKZ EQ SPACE.
* Save unchanged version of xvbap to yvbap
LS_YVBAP = XVBAP.
APPEND LS_YVBAP TO YVBAP.
XVBAP-UPDKZ = CHARU.
UPD_VBAP = CHARU.
ENDIF.
XVBAP-GSBER = VBAK-ZGSBER.
MODIFY XVBAP.
ENDLOOP.
ENDIF.
IF SY-TCODE <> 'VA03'.
LOOP AT XVBAP.
XVBAP-GSBER = VBAK-ZGSBER.
MODIFY XVBAP.
ENDLOOP.
ENDIF.