Create outbound delivery with different shipping address

2k Views Asked by At

I've searched for days and found nothing. My problem is, that I have to create a return delivery out of an QM-Report. Everything works fine.

However, the customer wants to change the delivery address manually.

Flow: QM02 (QM-Report) => Return order with BAPI_PO_CREATE1 (different address works fine) => Delivery with BAPI_OUTB_DELIVERY_CREATE_STO (different address from PO not working)

My question: Is there a possibility to change the delivery address of the outbound delivery? Do I have to implement a BADI or is there a simple solution?

If anything is missing, I will update the question.

2

There are 2 best solutions below

4
On

Function BAPI_OUTB_DELIVERY_CREATE_STO allows you to create deliveries from PO but you can't handle many of the delivery fields.

After you have created the deliveries, you should use WS_DELIVERY_UPDATE_2 function to update any field.

This is not a BAPI, and consequently it is not well documented, but is widely used for these changes.

Best regards

UPDATE

Here's a snippet:

ls_vbkok-vbeln_vl = <delivery number>.
ls_partners-vbeln_vl = ls_vbkok-vbeln_vl.
ls_partners-parvw = 'WE'.
ls_partners-parnr = <partner number>.
ls_partners-updkz_par = 'U'.
ls_partners-stras = <new street address>.
append ls_partners to lt_partners.

call function 'WS_DELIVERY_UPDATE_2'
  exporting
    vbkok_wa          = ls_vbkok
    synchron          = 'X'
    commit            = 'X'
    delivery          = ls_vbkok-vbeln_vl
  tables
    vbpok_tab         = lt_vbpok
    it_partner_update = lt_partners
    prot              = lt_prot.

if lt_prot[] is not initial.
  " handle error message here
endif.
0
On

if you need to make a commit and you can do it after the 'WS_DELIVERY_UPDATE_2' , try to call it in a new task. for exemple :

call function 'WS_DELIVERY_UPDATE_2' STARTING NEW TASK task
  PERFORMING return_fm ON END OF TASK
  exporting
    vbkok_wa          = ls_vbkok
    synchron          = 'X'
    commit            = ' '
    delivery          = ls_vbkok-vbeln_vl
  tables
    vbpok_tab         = lt_vbpok
    it_partner_update = lt_partners
    prot              = lt_prot.


*your code
WAIT UNTIL get_executed <> space.

FORM return_fm   USING i_taskname.
*your code
  get_executed = 'X'.
ENDFORM.