1.MIGO前台增强:
1.SE18找到增强点:MB_GOODSMOVEMENT
2.找到相应的BADI:右键创建实施
3.找到重写的方法
4.收货及冲销增强代码
LOOP AT xmkpf INTO ls_mkpf. LOOP AT xmseg INTO ls_mseg WHERE mblnr = ls_mkpf-mblnr AND mjahr = ls_mkpf-mjahr. IF ls_mseg-ebeln IS INITIAL OR ( ls_mseg-bwart <> '101' AND ls_mseg-bwart <> '123' ). CONTINUE. ENDIF. CLEAR:ls_zsdt008. SELECT SINGLE * INTO ls_zsdt008 FROM zsdt008 WHERE objkey = ls_mseg-ebeln AND objtype = 'PO' AND canum = '0010'. """查询订单订单流程 IF sy-subrc <> 0. CONTINUE. ENDIF. SELECT SINGLE * FROM zsdt014 INTO ls_zsdt014 WHERE zzrfcid = ls_zsdt008-zrfcid AND canum = '0010'."zrfcid = lv_zjylx AND canum = '0010' AND bsart = lv_bsart. IF sy-subrc <> 0. CONTINUE. ENDIF. lv_zjylx = ls_zsdt014-zrfcid. * SELECT * INTO TABLE lt_zsdt008 FROM zsdt008 WHERE zrfc_logid = lv_zrfc_logid AND objtype = 'PO'. * DELETE lt_zsdt008 WHERE objkey = ls_mseg-ebeln. * CLEAR:ls_ekko,ls_ekpo. * SELECT SINGLE * INTO ls_ekko FROM ekko WHERE ebeln = ls_zsdt008-objkey. * SELECT SINGLE * INTO ls_ekpo FROM ekpo WHERE ebeln = ls_zsdt008-objkey AND ebelp = ls_mseg-ebelp. CLEAR:ls_zsdt012. lv_zposnr = lv_zposnr + 10. ls_zsdt012-ebeln = ls_mseg-ebeln. ls_zsdt012-ebelp = ls_mseg-ebelp. ls_zsdt012-budat = ls_mkpf-budat. ls_zsdt012-bldat = ls_mkpf-bldat. ls_zsdt012-zocdqty = ls_mseg-menge. ls_zsdt012-charg = ls_mseg-charg. ls_zsdt012-mblnr = ls_mseg-mblnr. ls_zsdt012-mjahr = ls_mseg-mjahr. ls_zsdt012-zeile = ls_mseg-zeile. ls_zsdt012-xblnr = ls_mkpf-xblnr. ls_zsdt012-zrfcid = lv_zjylx. ls_zsdt012-zposnr = lv_zposnr. APPEND ls_zsdt012 TO lt_zsdt012. ENDLOOP. ENDLOOP. IF lt_zsdt012[] IS NOT INITIAL. * CALL FUNCTION 'ZMMFU002' IN BACKGROUND TASK * EXPORTING * iv_zjylx = lv_zjylx * TABLES * it_zsdt012 = lt_zsdt012[]. CALL FUNCTION 'ZMMFU010' EXPORTING iv_zjylx = lv_zjylx TABLES it_zsdt012 = lt_zsdt012[]. ENDIF. DATA:lv_posnr TYPE posnr. DATA:lv_zmblnr TYPE zsdt013-zmblnr, lv_mblnr TYPE mseg-mblnr, ls_zsdt023 TYPE zsdt023, ls_zsdt022 TYPE zsdt022, lt_zsdt022 TYPE TABLE OF zsdt022, lv_rfc_log_id TYPE zrfc_logid. LOOP AT xmkpf INTO ls_mkpf. CLEAR:lv_zmblnr,lv_mblnr,ls_zsdt023,ls_zsdt022,lt_zsdt022,lv_rfc_log_id. LOOP AT xmseg INTO ls_mseg WHERE mblnr = ls_mkpf-mblnr AND mjahr = ls_mkpf-mjahr AND ( bwart = '102' OR bwart = '122' ). CLEAR:lv_zjylx. * lv_zjylx = 'BUSP012'. SELECT SINGLE * INTO @DATA(ls_zsdt013_2) FROM zsdt013 WHERE mblnr = @ls_mseg-lfbnr "冲销的物料凭证 AND mjahr = @ls_mseg-lfbja. SELECT SINGLE * FROM zsdt023 INTO ls_zsdt023 WHERE zzrfcid = ls_zsdt013_2-zrfcid AND canum = '0010'. IF sy-subrc = 0. IF ls_zsdt013_2-zmblnr IS NOT INITIAL. lv_posnr = lv_posnr + 10. ls_zsdt022-zposnr = lv_posnr. ls_zsdt022-mblnr = ls_mseg-mblnr. ls_zsdt022-zeile = ls_mseg-lfpos. "add by 20221124 * ls_zsdt022-zeile = ls_mseg-zeile. ls_zsdt022-mjahr = ls_mseg-mjahr. ls_zsdt022-budat = ls_mkpf-budat. ls_zsdt022-xblnr = ls_mkpf-xblnr. ls_zsdt022-bwart = ls_mseg-bwart. ls_zsdt022-menge = ls_mseg-menge. ls_zsdt022-grund = ls_mseg-grund. ls_zsdt022-zmblnr = ls_zsdt013_2-zmblnr. SELECT SINGLE ebeln ebelp matnr lgort charg werks INTO ( ls_zsdt022-ebeln, ls_zsdt022-ebelp, ls_zsdt022-matnr, ls_zsdt022-lgort, ls_zsdt022-charg, ls_zsdt022-werks ) FROM mseg WHERE mblnr = ls_zsdt013_2-zmblnr AND mjahr = ls_mseg-lfbja AND zeile = ls_mseg-lfpos. APPEND ls_zsdt022 TO lt_zsdt022. CLEAR:ls_zsdt022. ENDIF. ENDIF. ENDLOOP. IF lt_zsdt022 IS NOT INITIAL. * CALL FUNCTION 'ZMMFU003' IN BACKGROUND TASK * EXPORTING * iv_zjylx = ls_zsdt023-zrfcid * TABLES * it_zsdt022 = lt_zsdt022[]. CALL FUNCTION 'ZMMFU009' EXPORTING iv_zjylx = ls_zsdt023-zrfcid TABLES it_zsdt022 = lt_zsdt022[]. ENDIF. CLEAR:ls_mkpf,lv_posnr.
2.MIGO BAPI增强:
1.SE19:创建BADI实施:
2.BAPI收货及冲销代码:
DATA:ls_mseg TYPE mseg. DATA:ls_mkpf TYPE mkpf. DATA:ls_zsdt014 TYPE zsdt014. DATA:ls_zsdt012 TYPE zsdt012, lt_zsdt012 TYPE TABLE OF zsdt012. DATA:lv_zjylx TYPE zrfcid. DATA:ls_zsdt008 TYPE zsdt008. DATA:lv_zposnr TYPE zsdt012-zposnr. IF sy-tcode = 'MIGO'. ls_mkpf = is_mkpf. LOOP AT it_mseg INTO ls_mseg WHERE mblnr = ls_mkpf-mblnr AND mjahr = ls_mkpf-mjahr. IF ls_mseg-ebeln IS INITIAL OR ( ls_mseg-bwart <> '101' AND ls_mseg-bwart <> '123' ). CONTINUE. ENDIF. CLEAR:ls_zsdt008. SELECT SINGLE * INTO ls_zsdt008 FROM zsdt008 WHERE objkey = ls_mseg-ebeln AND objtype = 'PO' AND canum = '0010'. """查询订单订单流程 IF sy-subrc <> 0. CONTINUE. ENDIF. SELECT SINGLE * FROM zsdt014 INTO ls_zsdt014 WHERE zzrfcid = ls_zsdt008-zrfcid AND canum = '0010'."zrfcid = lv_zjylx AND canum = '0010' AND bsart = lv_bsart. IF sy-subrc <> 0. CONTINUE. ENDIF. lv_zjylx = ls_zsdt014-zrfcid. CLEAR:ls_zsdt012. lv_zposnr = lv_zposnr + 10. ls_zsdt012-ebeln = ls_mseg-ebeln. ls_zsdt012-ebelp = ls_mseg-ebelp. ls_zsdt012-budat = ls_mkpf-budat. ls_zsdt012-bldat = ls_mkpf-bldat. ls_zsdt012-zocdqty = ls_mseg-menge. ls_zsdt012-charg = ls_mseg-charg. ls_zsdt012-mblnr = ls_mseg-mblnr. ls_zsdt012-mjahr = ls_mseg-mjahr. ls_zsdt012-zeile = ls_mseg-zeile. ls_zsdt012-xblnr = ls_mkpf-xblnr. ls_zsdt012-zrfcid = lv_zjylx. ls_zsdt012-zposnr = lv_zposnr. APPEND ls_zsdt012 TO lt_zsdt012[]. ENDLOOP. IF lt_zsdt012[] IS NOT INITIAL AND lv_zjylx IS NOT INITIAL. CALL FUNCTION 'ZMMFU002' IN BACKGROUND TASK EXPORTING iv_zjylx = lv_zjylx TABLES it_zsdt012 = lt_zsdt012[]. ENDIF. ENDIF. * ENDIF. * IF sy-uname = 'BASIS2'. IF sy-tcode = 'MIGO'. DATA:lv_posnr TYPE posnr. ls_mkpf = is_mkpf. LOOP AT it_mseg INTO ls_mseg WHERE mblnr = ls_mkpf-mblnr AND mjahr = ls_mkpf-mjahr AND ( bwart = '102' OR bwart = '122' ). CLEAR:lv_zjylx. * lv_zjylx = 'BUSP012'. DATA:lv_zmblnr TYPE zsdt013-zmblnr, lv_mblnr TYPE mseg-mblnr, ls_zsdt023 TYPE zsdt023, ls_zsdt022 TYPE zsdt022, lt_zsdt022 TYPE TABLE OF zsdt022, lv_rfc_log_id TYPE zrfc_logid. SELECT SINGLE * INTO @DATA(ls_zsdt013_2) FROM zsdt013 WHERE mblnr = @ls_mseg-lfbnr "冲销的物料凭证 AND mjahr = @ls_mseg-lfbja. SELECT SINGLE * FROM zsdt023 INTO ls_zsdt023 WHERE zzrfcid = ls_zsdt013_2-zrfcid AND canum = '0010'. IF sy-subrc = 0. IF ls_zsdt013_2-zmblnr IS NOT INITIAL. lv_posnr = lv_posnr + 10. ls_zsdt022-zposnr = lv_posnr. ls_zsdt022-mblnr = ls_mseg-mblnr. ls_zsdt022-zeile = ls_mseg-zeile. ls_zsdt022-mjahr = ls_mseg-mjahr. ls_zsdt022-budat = ls_mkpf-budat. ls_zsdt022-xblnr = ls_mkpf-xblnr. ls_zsdt022-bwart = ls_mseg-bwart. ls_zsdt022-menge = ls_mseg-menge. ls_zsdt022-grund = ls_mseg-grund. ls_zsdt022-zmblnr = ls_zsdt013_2-zmblnr. SELECT SINGLE ebeln ebelp matnr lgort charg werks INTO ( ls_zsdt022-ebeln, ls_zsdt022-ebelp, ls_zsdt022-matnr, ls_zsdt022-lgort, ls_zsdt022-charg, ls_zsdt022-werks ) FROM mseg WHERE mblnr = ls_zsdt013_2-zmblnr AND mjahr = ls_mseg-lfbja AND zeile = ls_mseg-lfpos. APPEND ls_zsdt022 TO lt_zsdt022. CLEAR:ls_zsdt022. ENDIF. ENDIF. ENDLOOP. IF lt_zsdt022 IS NOT INITIAL. CALL FUNCTION 'ZMMFU003' IN BACKGROUND TASK EXPORTING iv_zjylx = ls_zsdt023-zrfcid TABLES it_zsdt022 = lt_zsdt022[]. ENDIF. * READ TABLE it_mseg INTO ls_mseg WITH KEY bwart = '102'. * IF sy-subrc = 0. * SELECT SINGLE zrfcid INTO lv_zjylx FROM zsdt013 WHERE mblnr = ls_mseg-smbln AND mjahr = ls_mseg-sjahr. * SELECT SINGLE * FROM zsdt023 INTO ls_zsdt023 WHERE zzrfcid = lv_zjylx AND canum = '0010'. * IF sy-subrc = 0. * IF lv_zmblnr IS NOT INITIAL. * ls_zsdt022-budat = is_mkpf-budat. * ls_zsdt022-mblnr = lv_zmblnr. * ls_zsdt022-mjahr = is_mkpf-mjahr. * ls_zsdt022-zrfcid = ls_zsdt023-zrfcid. * ls_zsdt022-zmblnr = ls_mseg-smbln. * APPEND ls_zsdt022 TO lt_zsdt022. * * * CALL FUNCTION 'ZMMFU003' IN BACKGROUND TASK * EXPORTING * iv_zjylx = ls_zsdt023-zrfcid * TABLES * it_zsdt022 = lt_zsdt022[]. * ENDIF. * ENDIF. * ENDIF. ENDIF.
标签:lv,收货,mseg,zsdt012,MIGO,zsdt022,ABAP,ls,mkpf From: https://www.cnblogs.com/ap-ad-java-abap/p/16955482.html