1

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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
SacrumDeus
  • 156
  • 1
  • 13

2 Answers2

1

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.
manuel_b
  • 1,646
  • 3
  • 20
  • 29
  • Is it required to make a `COMMIT WORK` before calling this function?. I hope it's not, because if I execute the BAPI, there will be a message printed – SacrumDeus Mar 11 '19 at 16:58
  • Unfortunately I think it is needed. Could you try adding a requirement (tx VOFM/NACE) in the message output checking for some particular field, or trying to customize the message to be printed only at change and not at insert ? – manuel_b Mar 11 '19 at 17:34
  • Unfortunately there is no way to change the adress within the LUW. After I've created a outbound delivery, I need to make a `COMMIT WORK`. Without this, there is no chance to change the adress. Under bad circumstances, the delivery will be processed, until the changes are made. Additionally, I need to print a message, which will be added afterwards...maybe I will try the BadI to solve my problem. I will post an update, when I solved the problem – SacrumDeus Apr 01 '19 at 17:11
  • How do you invoke delivery creation? Through action box? How do you run those BAPIs? – Suncatcher May 02 '19 at 19:32
0

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.                     
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Cheikh Lo
  • 1
  • 2