码迷,mamicode.com
首页 > 其他好文 > 详细

SAP 计划行审核是自动修改,产生MD04需求

时间:2016-06-08 13:57:27      阅读:756      评论:0      收藏:0      [点我收藏+]

标签:

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

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

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

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

 

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

IF ( i_stonO = 20 AND i_stonN = 30 ).
       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 = 05.
                  GX_VBEP-BDART = 05.
                  GX_VBEP-PLART = 0.
                  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 = 05.
                    GW_VBBE-PLART = 0.
                    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 = 0.
                       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 = 05.
                  GX_VBEP-BDART = 05.
                  GX_VBEP-PLART = 0.
                  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 = 05.
                    GW_VBBE-PLART = 0.
                    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 = 0.
                       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 = 0.
              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 = 05.
                  GX_VBEP-BDART = 05.
                  GX_VBEP-PLART = 0.
                  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 = 05.
                    GW_VBBE-PLART = 0.
                    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 = 0.
                       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 = 05.
                  GX_VBEP-BDART = 05.
                  GX_VBEP-PLART = 0.
                  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 = 05.
                    GW_VBBE-PLART = 0.
                    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 = 0.
                       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.

 

SAP 计划行审核是自动修改,产生MD04需求

标签:

原文地址:http://www.cnblogs.com/sapSB/p/5569636.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!