BAPI 更改交货单 & 更改捡配 'BAPI_OUTB_DELIVERY_CHANGE'

REPORT  z_delivery_pccf.


TABLES likp.
PARAMETERS p_del LIKE likp-vbeln DEFAULT ''.


DATA:
str_header_data LIKE bapiobdlvhdrchg,
str_header_control LIKE bapiobdlvhdrctrlchg.


DATA it_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
DATA it_header_deadlines TYPE STANDARD TABLE OF bapidlvdeadln
WITH HEADER LINE.


DATA :item_data LIKE bapiobdlvitemchg OCCURS 0 WITH HEADER LINE,
       item_control LIKE bapiobdlvitemctrlchg OCCURS 0 WITH HEADER LINE,
       wa_lips LIKE lips OCCURS 0 WITH HEADER LINE.


DATA: v_16(16) TYPE c.


DATA v_del LIKE bapiobdlvhdrchg-deliv_numb.
SELECT SINGLE * FROM likp WHERE vbeln = p_del.
CONCATENATE sy-datum sy-uzeit INTO v_16.




*str_HEADER_DATA-GROSS_WT
*UNIT_OF_WT_ISO
*VOLUMEUNIT_ISO


str_header_data-unload_pt = likp-ablad.
str_header_data-unit_of_wt = likp-gewei.
str_header_data-incoterms1 = likp-inco1.
str_header_data-incoterms2 = likp-inco2.
str_header_data-door = likp-lgtor.
str_header_data-dlv_block = likp-lifsk.
str_header_data-dlv_prio = likp-lprio.
str_header_data-net_weight = likp-ntgew.
str_header_data-route = likp-route.
str_header_data-deliv_numb = likp-vbeln.
str_header_data-volumeunit = likp-voleh.
str_header_data-volume = likp-volum.
str_header_data-ship_cond = likp-vsbed.


v_del = likp-vbeln.
str_header_data-deliv_numb = likp-vbeln.
str_header_control-gdsi_date_flg = 'X'.
it_header_deadlines-timetype = 'WSHDRWADTI'.
it_header_deadlines-timestamp_utc = v_16.
APPEND it_header_deadlines.


SELECT  * INTO wa_lips FROM lips WHERE vbeln = p_del.
   item_data-deliv_numb = wa_lips-vbeln.
   item_data-deliv_item = wa_lips-posnr.
   item_data-material = wa_lips-matnr.
   item_data-batch = wa_lips-charg.
   item_data-dlv_qty = 2.
   item_data-dlv_qty_imunit = 2.
   item_data-fact_unit_nom = wa_lips-umvkz.
   item_data-fact_unit_denom = wa_lips-umvkn.
   item_data-conv_fact = wa_lips-umref.
   item_data-gross_wt = wa_lips-brgew.
   item_data-net_weight = wa_lips-ntgew.
   item_data-unit_of_wt = wa_lips-gewei.
   item_data-volumeunit = wa_lips-voleh.
   item_data-sales_unit = wa_lips-vrkme.
   item_data-base_uom = wa_lips-meins.
   item_data-stock_type = wa_lips-insmk.
   item_data-val_type = wa_lips-bwtar.
   item_data-insplot = wa_lips-qplos.
   item_data-volume = wa_lips-volum.
  APPEND item_data.


   item_control-deliv_numb = wa_lips-vbeln.
   item_control-deliv_item = wa_lips-posnr.
   item_control-chg_delqty = 'X'.
  APPEND item_control.
ENDSELECT.




CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
  EXPORTING
     header_data       = str_header_data
     header_control    = str_header_control
     delivery          = v_del
  TABLES
     header_deadlines = it_header_deadlines
     item_data         = item_data
     item_control      = item_control
    return           = it_return.
COMMIT WORK.




*& 更改拣配数量
DATA:vbkok_wa TYPE vbkok,
      vbpok_tab TYPE vbpok OCCURS 0 WITH HEADER LINE,
      xlips TYPE lips OCCURS 0 WITH HEADER LINE .
CLEAR: vbkok_wa, vbpok_tab, xlips.
REFRESH: vbpok_tab, xlips.


vbkok_wa-vbeln_vl = p_del.




SELECT * FROM lips INTO TABLE xlips
WHERE vbeln = vbkok_wa-vbeln_vl.


LOOP AT xlips.
   CLEAR: vbpok_tab.
   vbpok_tab-vbeln_vl = xlips-vbeln.
   vbpok_tab-posnr_vl = xlips-posnr.
   vbpok_tab-vbeln = xlips-vbeln.
   vbpok_tab-posnn = xlips-posnr.
*vbpok_tab-vbtyp_n = 'Q'.
   vbpok_tab-pikmg = xlips-lfimg.
   vbpok_tab-meins = xlips-meins.
   vbpok_tab-ndifm = 0.
   vbpok_tab-taqui = ' '.
   vbpok_tab-charg = xlips-charg.
   vbpok_tab-matnr = xlips-matnr.
   vbpok_tab-orpos = 0.
  APPEND vbpok_tab.
ENDLOOP.


CALL FUNCTION 'SD_DELIVERY_UPDATE_PICKING'
EXPORTING
vbkok_wa = vbkok_wa
synchron = 'X'
* NO_MESSAGES_UPDATE = ' '
* NICHT_SPERREN = ' '
* AUFRUFER_T = ' '
* IF_ERROR_MESSAGES_SEND = 'X'
TABLES
vbpok_tab = vbpok_tab
.


COMMIT WORK AND WAIT.

你可能感兴趣的:(BAPI 更改交货单 & 更改捡配 'BAPI_OUTB_DELIVERY_CHANGE')