Skip to Content

BAPI_PO_CREATE1 automatic outbound delivery Transfer Orders

Hi all,

i'm facing a strange behaviour using BAPI_PO_CREATE1 in order to create a Transfer Order and its Outbound delivery.


We need to move some goods between two plants of ours so the receiving plant will create a Transfer Order towards the shipping one and two deliveries (Outbound from Shipping and Inbound in Receiving) close the flow.

We'll have an OData service doing the job, exposed towards an Angular App with UI5

Situation and Test
As first step, we tried the flow (obviously) via ME21N and we saw that when we create the Transfer Order, SAP (thanks the customizing) generate the outbound delivery automatically and we see it linked to the TO item

Manually we create the inbound deliver via VL10B and all works.

So i created a local report using the BAPI_PO_CREATE1 to generate the transfer order and the FM BBP_INB_DELIVERY_CREATE for the inbound delivery.

i run the report and.. surprise! Everything works correctly!

i made a copy and paste of the code and put it in my service and i find the issue.

The problem

When we call the service, the BAPI_PO_CREATE1 do not create the Outbound delivery automatically.

But the code is exactly the same of my local report!

To avoid any problem, i made a global wrapper function and put it in both my local report and my OData service and... the behaviour is still different:

  • Local report create the outbound delivery
  • OData service no

I tried to look for OSS Note but i did not find anything and, honestly, it's hard to find something without knowing the exact breaking points.

Any suggestion?

This is my code by the way (and yes, i managed the Commit/Rollback, the PO/TO is created!)

 data: poheader  type  bapimepoheader,
        poheaderx type  bapimepoheaderx,
        item      type  bapimepoitem,
        items      type table of  bapimepoitem,
        itemx     type  bapimepoitemx,
        itemsx    type table of bapimepoitemx,
        returns    type table of  bapiret2,
        extx type bapi_te_mepoitemx,
        ext type bapi_te_mepoitem,
        exin type bapiparex,
        exins type table of bapiparex,
        exppurchaseorder type  bapimepoheader-po_number,
        expheader type  bapimepoheader.

  select single t001k~bukrs t001w~ekorg into (poheader-comp_code, poheader-purch_org)  from t001w inner join t001k
on t001w~bwkey = t001k~bwkey
                where t001w~werks = p_dwerks.

  poheader-doc_type = 'UD'.
  poheader-suppl_plnt = p_werks.
  poheader-pur_group = poheader-comp_code(2).
  poheaderx-doc_type = poheaderx-pur_group =  poheaderx-comp_code = 
              poheaderx-suppl_plnt = poheaderx-purch_org = 'X'.
  item-po_item = 10.
  item-material = p_matnr.
  item-plant = p_dwerks.
  item-stge_loc = p_dlgort.
  item-quantity = p_qty.
  select single meins into item-po_unit from mara where matnr = p_matnr.
  item-item_cat = 'U'.
  item-conf_ctrl = '0004'.
  item-suppl_stloc = p_lgort.
  itemx-po_item = 10.
  itemx-material = itemx-plant = itemx-stge_loc = itemx-quantity = itemx-po_unit = itemx-item_cat = itemx-conf_ctrl =
    itemx-suppl_stloc = abap_true.
  append item to items.
  append itemx to itemsx.
  ext-po_item = extx-po_item = 10.
  ext-zzpl_piid = 'BULK'.
  extx-zzpl_piid = 'X'.
  exin-structure = 'BAPI_TE_MEPOITEM'.
  exin+30 = ext.
  append exin to exins.
  clear exin.
  exin-structure = 'BAPI_TE_MEPOITEMX'.
  exin+30 = extx.
  append exin to exins.

  call function 'BAPI_PO_CREATE1'
      poheader          = poheader
      poheaderx         = poheaderx
     testrun           = ' '
     exppurchaseorder  = exppurchaseorder
      expheader         = expheader
      return            = returns
      poitem            = items
      poitemx           = itemsx
      extensionin       = exins.

Thanks all


ok.png (16.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    May 26, 2017 at 08:15 AM

    Dear Simone,

    Please try running your local report in background mode... does it still work fine?

    Kind regards,


    Add comment
    10|10000 characters needed characters exceeded

  • May 25, 2017 at 11:14 AM

    I understand your words but somehow what you explained from a normal business flow does not match with my experience (I am not yet talking about the BAPI, odata or other programming things).

    ME21N creates a purchase order. It does not create an outbound delivery automatically

    BAPI_PO_CREATE1 is used to create a purchase order too as a technical replacement for the ME21N user transaction, but even this BAPI does not create an outbound delivery.

    So I wonder in general how your outbound delivery was created "automatically" . I could assume that there is a batch job scheduled, maybe even event triggered. But from alone is no outbound delivery created in SAP, just because someone entered PO.

    Add comment
    10|10000 characters needed characters exceeded

  • May 25, 2017 at 03:23 PM

    As you can test the two "programs" with an identical test data, maybe you can run an ABAP trace (SAT), compare the two traces (with the comparison tool in SAT), and you should get the same traces except at one point which should be where the problem is.

    By the way, you should also test with the same user. I guess this is the only different thing (OData runs with a predefined user, and your program runs with your current user).

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Sandra,

      Thanks for the answer!

      To avoid any possible difference, i put fix values in both the local program and in my Odata service and assigned my user to the Odata service too, so the only difference is the that one runs on sapgui and the other via service/gateway.

      Maybe i found the "critical point": checking OSS Note 1069448 (not applicable to my system), i found out the function responsible of the delivery creation /SPE/OUTBOUND_DELIVERY_CREATE

      It seems not being triggered by the service but i do not know why :\

  • avatar image
    Former Member
    May 26, 2017 at 11:51 AM


    I am confused with your description, As you mentioned that PO creation, what type of PO It is.

    What process your are runing ?

    I think you are creating STO through Bapi, then delivery is created automatically and transfer order is created one delivery is created so cehck WMTA output type and automatic delivery creation setting in IMG

    But you mentioned VL10B for inbound delivery that will be outbound delivery right?



    Add comment
    10|10000 characters needed characters exceeded

    • As i put in my question, i'm creating a Stock Transfer Order or Transfer Order (name as you want) which manually triggers the creation of outbound delivery (check my comments to Jurgen reply!).

      With VL10B i create the inbound delivery as 2nd manual step.

      The problem is the BAPI doesn't trigger (check my replies to Sandra and Julian) the specific function to create the outbound delivery when called into an OData Service.

      All these steps are explained in the previous comments and answers.