不知道业务怎么配置的,创建销售单时,一堆计划行类别,什么CN,DN。。。都有,但是审核后需要计划行变更为CP,这样在MD04才能看到需求。

原有逻辑是弄个后台程序,审核后调一下,更新一下计划行,这样是会有需求的。。。

但是,业务有个习惯喜欢VA02直接审,或者是交货后还来修改等等。。。这时候就需要在VA02里做增强。,

原本的开发还是调程序。。。这就产生了很多问题。后来我自己写增强审核的时候自动修改计划行类别,巴特,不产生需求。。。这特么鬼,后来各种找,各种DEBUG,找到根源了。。。

Now,来个增强,实现:MV45AFZZ  USEREXIT_SAVE_DOCUMENT_PREPARE

IF ( i_stonO = '' AND i_stonN = '' ).
LOOP AT XVBEP INTO GX_VBEP.
LY_I = SY-TABIX.
CASE VBAK-AUART.
WHEN 'ZOR' .
IF GX_VBEP-ETTYP <> 'CP' AND GX_VBEP-ETTYP <> 'ZD'.
GX_VBEP-ETTYP = 'CP'.
IF SY-TCODE = 'VA01'.
ELSEIF SY-TCODE = 'VA02'.
GX_VBEP-UPDKZ = 'U'.
GX_VBEP-BEDSD = 'X'.
GX_VBEP-BDAALT = ''.
GX_VBEP-BDART = ''.
GX_VBEP-PLART = ''.
IF XVBBE[] IS INITIAL.
GW_VBBE-MANDT = SY-MANDT.
GW_VBBE-VBELN = GX_VBEP-VBELN.
GW_VBBE-POSNR = GX_VBEP-POSNR.
GW_VBBE-ETENR = GX_VBEP-ETENR.
GW_VBBE-MBDAT = GX_VBEP-EDATU.
GW_VBBE-VBTYP = 'C'.
GW_VBBE-BDART = ''.
GW_VBBE-PLART = ''.
GW_VBBE-UPDKZ = 'I'.
GW_VBBE-OMENG = GX_VBEP-LMENG.
GW_VBBE-VMENG = GX_VBEP-BMENG.
GW_VBBE-MEINS = GX_VBEP-VRKME.
GW_VBBE-PZMNG = GX_VBEP-LMENG.
GW_VBBE-AUART = XVBAK-AUART.
GW_VBBE-KUNNR = XVBAK-KUNNR.
READ TABLE XVBAP INTO GX_VBAP WITH KEY POSNR = GX_VBEP-POSNR.
IF SY-SUBRC = .
LY_J = SY-TABIX.
GX_VBAP-SUMBD = 'A'.
GX_VBAP-UPDKZ = 'U'.
GX_VBAP-BEDUP = 'X'. MODIFY XVBAP FROM GX_VBAP INDEX LY_J TRANSPORTING SUMBD UPDKZ BEDUP.
GW_VBBE-MATNR = GX_VBAP-MATNR.
GW_VBBE-WERKS = GX_VBAP-WERKS.
GW_VBBE-LGORT = GX_VBAP-LGORT.
GW_VBBE-CHARG = GX_VBAP-CHARG.
GW_VBBE-AWAHR = GX_VBAP-AWAHR.
GW_VBBE-VPZUO = GX_VBAP-VPZUO.
ENDIF.
INSERT GW_VBBE INTO XVBBE INDEX GX_VBEP-ETENR.
ENDIF.
ENDIF.
ENDIF.
WHEN 'ZKB' .
IF GX_VBEP-ETTYP <> 'E1'.
GX_VBEP-ETTYP = 'E1'.
IF SY-TCODE = 'VA01'.
ELSEIF SY-TCODE = 'VA02'.
GX_VBEP-UPDKZ = 'U'.
GX_VBEP-BEDSD = 'X'.
GX_VBEP-BDAALT = ''.
GX_VBEP-BDART = ''.
GX_VBEP-PLART = ''.
IF XVBBE[] IS INITIAL.
GW_VBBE-MANDT = SY-MANDT.
GW_VBBE-VBELN = GX_VBEP-VBELN.
GW_VBBE-POSNR = GX_VBEP-POSNR.
GW_VBBE-ETENR = GX_VBEP-ETENR.
GW_VBBE-MBDAT = GX_VBEP-EDATU.
GW_VBBE-VBTYP = 'C'.
GW_VBBE-BDART = ''.
GW_VBBE-PLART = ''.
GW_VBBE-UPDKZ = 'I'.
GW_VBBE-OMENG = GX_VBEP-LMENG.
GW_VBBE-VMENG = GX_VBEP-BMENG.
GW_VBBE-MEINS = GX_VBEP-VRKME.
GW_VBBE-PZMNG = GX_VBEP-LMENG.
GW_VBBE-AUART = XVBAK-AUART.
GW_VBBE-KUNNR = XVBAK-KUNNR.
READ TABLE XVBAP INTO GX_VBAP WITH KEY POSNR = GX_VBEP-POSNR.
IF SY-SUBRC = .
LY_J = SY-TABIX.
GX_VBAP-SUMBD = 'A'.
GX_VBAP-UPDKZ = 'U'.
GX_VBAP-BEDUP = 'X'. MODIFY XVBAP FROM GX_VBAP INDEX LY_J TRANSPORTING SUMBD UPDKZ BEDUP.
GW_VBBE-MATNR = GX_VBAP-MATNR.
GW_VBBE-WERKS = GX_VBAP-WERKS.
GW_VBBE-LGORT = GX_VBAP-LGORT.
GW_VBBE-CHARG = GX_VBAP-CHARG.
GW_VBBE-AWAHR = GX_VBAP-AWAHR.
GW_VBBE-VPZUO = GX_VBAP-VPZUO.
ENDIF.
INSERT GW_VBBE INTO XVBBE INDEX GX_VBEP-ETENR.
ENDIF.
ENDIF.
ENDIF.
WHEN 'ZSP' .
READ TABLE XVBAP INTO GX_VBAP WITH KEY POSNR = GX_VBEP-POSNR.
IF SY-SUBRC = .
IF GX_VBAP-PSTYV = 'ZSNN' AND GX_VBEP-ETTYP <> 'ZN'.
GX_VBEP-ETTYP = 'ZN'.
IF SY-TCODE = 'VA01'.
ELSEIF SY-TCODE = 'VA02'.
GX_VBEP-UPDKZ = 'U'.
GX_VBEP-BEDSD = 'X'.
GX_VBEP-BDAALT = ''.
GX_VBEP-BDART = ''.
GX_VBEP-PLART = ''.
IF XVBBE[] IS INITIAL.
GW_VBBE-MANDT = SY-MANDT.
GW_VBBE-VBELN = GX_VBEP-VBELN.
GW_VBBE-POSNR = GX_VBEP-POSNR.
GW_VBBE-ETENR = GX_VBEP-ETENR.
GW_VBBE-MBDAT = GX_VBEP-EDATU.
GW_VBBE-VBTYP = 'C'.
GW_VBBE-BDART = ''.
GW_VBBE-PLART = ''.
GW_VBBE-UPDKZ = 'I'.
GW_VBBE-OMENG = GX_VBEP-LMENG.
GW_VBBE-VMENG = GX_VBEP-BMENG.
GW_VBBE-MEINS = GX_VBEP-VRKME.
GW_VBBE-PZMNG = GX_VBEP-LMENG.
GW_VBBE-AUART = XVBAK-AUART.
GW_VBBE-KUNNR = XVBAK-KUNNR.
READ TABLE XVBAP INTO GX_VBAP WITH KEY POSNR = GX_VBEP-POSNR.
IF SY-SUBRC = .
LY_J = SY-TABIX.
GX_VBAP-SUMBD = 'A'.
GX_VBAP-UPDKZ = 'U'.
GX_VBAP-BEDUP = 'X'. MODIFY XVBAP FROM GX_VBAP INDEX LY_J TRANSPORTING SUMBD UPDKZ BEDUP.
GW_VBBE-MATNR = GX_VBAP-MATNR.
GW_VBBE-WERKS = GX_VBAP-WERKS.
GW_VBBE-LGORT = GX_VBAP-LGORT.
GW_VBBE-CHARG = GX_VBAP-CHARG.
GW_VBBE-AWAHR = GX_VBAP-AWAHR.
GW_VBBE-VPZUO = GX_VBAP-VPZUO.
ENDIF.
INSERT GW_VBBE INTO XVBBE INDEX GX_VBEP-ETENR.
ENDIF.
ENDIF.
ELSEIF GX_VBAP-PSTYV = 'ZSAN' AND GX_VBEP-ETTYP <> 'CP'.
GX_VBEP-ETTYP = 'CP'.
IF SY-TCODE = 'VA01'.
ELSEIF SY-TCODE = 'VA02'.
GX_VBEP-UPDKZ = 'U'.
GX_VBEP-BEDSD = 'X'.
GX_VBEP-BDAALT = ''.
GX_VBEP-BDART = ''.
GX_VBEP-PLART = ''.
IF XVBBE[] IS INITIAL.
GW_VBBE-MANDT = SY-MANDT.
GW_VBBE-VBELN = GX_VBEP-VBELN.
GW_VBBE-POSNR = GX_VBEP-POSNR.
GW_VBBE-ETENR = GX_VBEP-ETENR.
GW_VBBE-MBDAT = GX_VBEP-EDATU.
GW_VBBE-VBTYP = 'C'.
GW_VBBE-BDART = ''.
GW_VBBE-PLART = ''.
GW_VBBE-UPDKZ = 'I'.
GW_VBBE-OMENG = GX_VBEP-LMENG.
GW_VBBE-VMENG = GX_VBEP-BMENG.
GW_VBBE-MEINS = GX_VBEP-VRKME.
GW_VBBE-PZMNG = GX_VBEP-LMENG.
GW_VBBE-AUART = XVBAK-AUART.
GW_VBBE-KUNNR = XVBAK-KUNNR.
READ TABLE XVBAP INTO GX_VBAP WITH KEY POSNR = GX_VBEP-POSNR.
IF SY-SUBRC = .
LY_J = SY-TABIX.
GX_VBAP-SUMBD = 'A'.
GX_VBAP-UPDKZ = 'U'.
GX_VBAP-BEDUP = 'X'. MODIFY XVBAP FROM GX_VBAP INDEX LY_J TRANSPORTING SUMBD UPDKZ BEDUP.
GW_VBBE-MATNR = GX_VBAP-MATNR.
GW_VBBE-WERKS = GX_VBAP-WERKS.
GW_VBBE-LGORT = GX_VBAP-LGORT.
GW_VBBE-CHARG = GX_VBAP-CHARG.
GW_VBBE-AWAHR = GX_VBAP-AWAHR.
GW_VBBE-VPZUO = GX_VBAP-VPZUO.
ENDIF.
INSERT GW_VBBE INTO XVBBE INDEX GX_VBEP-ETENR.
ENDIF.
ENDIF.
ENDIF .
ENDIF.
WHEN OTHERS.
ENDCASE.
MODIFY XVBEP FROM GX_VBEP.
ENDLOOP.
ENDIF.
05-10 20:24