MM06E005 EXIT_SAPMM06E_013 更新客户采购文件中的数据
业务需求:修改PO行项次交货日期联动更改其对应PR的交货日期
1 *&--------------------------------------------------------------------- 2 *& 包括 ZXM06U44 3 *&--------------------------------------------------------------------- 4 5 IF sy-tcode = 'ME22N' OR sy-tcode = 'ZMMT01'. 6 7 IF i_ekko-bukrs = '7888' AND i_ekko-bsart = 'NB'. 8 DATA:return LIKE TABLE OF bapiret2 WITH HEADER LINE, 9 pritem LIKE TABLE OF bapimereqitemimp WITH HEADER LINE, 10 pritemx LIKE TABLE OF bapimereqitemx WITH HEADER LINE. 11 DATA wa TYPE zpopr_date. "记录更改记录(自建表) 12 DATA dats TYPE eindt. "po时间 13 IF NOT xekpo[] IS INITIAL OR NOT yekpo[] IS INITIAL. 14 LOOP AT xekpo WHERE loekz = 'L'. "删除标志 15 CLEAR:pritem[],pritem,pritemx[],pritemx,dats,wa. 16 SELECT SINGLE eindt INTO dats FROM eket WHERE ebeln = xekpo-ebeln AND ebelp = xekpo-ebelp. "po交货日期 17 SELECT SINGLE lfdat INTO wa-prdata FROM eban WHERE banfn = xekpo-banfn AND bnfpo = xekpo-bnfpo. "pr交货日期 18 IF sy-subrc = 0. 19 IF dats <> wa-prdata. 20 pritem-deliv_date = dats. 21 pritem-preq_item = xekpo-bnfpo. 22 pritemx-preq_item = xekpo-bnfpo. 23 pritemx-deliv_date = 'X'. 24 APPEND:pritem,pritemx. 25 26 CALL FUNCTION 'BAPI_PR_CHANGE' 27 EXPORTING 28 number = xekpo-banfn 29 TABLES 30 return = return 31 pritem = pritem 32 pritemx = pritemx. 33 READ TABLE return WITH KEY type = 'E'. 34 IF sy-subrc = 0. 35 CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 36 MESSAGE return-message TYPE 'E'. 37 ELSE. 38 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 39 EXPORTING 40 wait = 'X'. 41 wa-ebeln = xekpo-ebeln. 42 wa-ebelp = xekpo-ebelp. 43 wa-banfn = xekpo-banfn. 44 wa-bnfpo = xekpo-bnfpo. 45 wa-prdata_new = dats. 46 wa-zerdt = sy-datum. 47 wa-uzeit = sy-uzeit. 48 wa-uname = sy-uname. 49 INSERT into zpopr_date values wa. 50 ENDIF. 51 ELSE. 52 CONTINUE. 53 ENDIF. 54 ELSE. 55 CONTINUE. 56 ENDIF. 57 ENDLOOP. 58 ENDIF. 59 ENDIF. 60 ENDIF.