BAPI for creating Return delivery to vendor using transaction MIGO

Hi All,
         My requirement is to create Return delivery to vendor using transaction MIGO.
In MIGO transaction to create return delivery, the following steps needs to be followed.
i) Select the option A02 Return delivery, R02 Material document,
    Enter Material document xxxxxxxx.
    Reson for movement:xxxx
    By selecting the option item ok and via delivery check box, then save.
After saving return delivery needs to be created.
Is there any BAPI/FM exist for this requirement?
I made lot of search in sdn, but i could not find any thing helpful.
Appreciate quick help.
regards
surya

Hi
In VL02n->Extras->Delivery Output->Header
Check if you see any message type (LD00 ?).
If you do not see any, insert a message type LD00.
If you want to check the IMG settings, see Txns : V/71 (for delivery types RL/RLL) and V/73 (for Item category RLLN)
Best regards
Ramki

Similar Messages

  • BAPI for creating outbound delivery

    Hi,
    Can anyone please let me know the bapi for creating outbound delivery.I have checked for few bapi's like
    BAPI_OUTB_DELIVERY_SAVEREPLICA
    BAPI_DELIVERPROCESSING_EXEC
    If i use the first one i would like to know whether i need to do the PGI seperately by using any bdc or is it taken care in the same bapi.
    Its basically for the workflow task werein we have all the required parameters like delivery numb, sales order num ...etc
    Iam new to BAPI's.Please consider my request and let me know the details for the same.
    thanks
    keith

    The below is for creating delivery for STO's.
        Delivery creation
          call function 'SHP_VL10_DELIVERY_CREATE'
            exporting
              IF_LEDAT           = I_LFDAT
              IF_NUR_VORGABE_POS = YES
              IT_KEY_ENQUE_READ  = IT_KEY_ENQUE_READ
              IT_KOMDLGN         = IT_KOMDLGN
            changing
              CX_SD_ORDER        = XS_SD_ORDER
              CT_VBSK_ALL        = XT_VBSK_ALL
              CT_VBLS            = XT_VBLS
              CT_KEY_LATE        = XT_KEY_LATE.
    Message was edited by: Anurag Bankley

  • BAPI for  Reversal of Goods Receipt Purchase Order(Transaction : MIGO)

    Hi all,
    Is there any BAPI for the Reversal of posting the documents Goods receipt Purchase order
    (Transaction: MIGO).
    Any inputs on this..is highly appreciable...
    thanks in advance...
    regards..
    prathima.

    Hi,
    Try this passing material doc and year.
    * Cancel the goods movement (creates a reversal document)
      CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
        EXPORTING
          materialdocument = g_material_doc
          matdocumentyear  = g_matdoc_year
        TABLES
          return           = i_return.
    Edited by: Raj on May 14, 2008 7:46 PM

  • BAPI for creating outbound delivery reference to PO

    Hi all,
       I want to crate delivery against the the PO. scenario is i want to create delivery in one plant which will be copy of delivery in some other plant. I require it for automation. Main thing is that BAPI should handle batch split scenario. The problem is that i used 'GN_DELIVERY_CREATE' bt although it meets po quantity it is not closing PO's ELIKZ flag. Plz suggest some solution on it.
    Theme is I want to create delivery against PO but quantity should be from other delivery and it should handle battch split.
    I will thankful to u .

    hi Amol,
    welcome to SDN
    here is related scenario check it out
    BAPI to Copy Materials from one Plant to Another
    Copy Materials from one Plant to Another
    First run   GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
    Second run  UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
    Check data in Excel before Second run
    REPORT ZBAPIMM01 LINE-SIZE 255 NO STANDARD PAGE HEADING
                     LINE-COUNT 065(001).
    TABLES: T001L, "Storage Locations
            MARA,  "General Material Data
            MAKT,  "Material Descriptions
            MBEW,  "Material Valuation
            MARC.  "Plant Data for Material
    DATA: BAPI_HEAD   LIKE BAPIMATHEAD,
          BAPI_MAKT   LIKE BAPI_MAKT,    "Material Description
          BAPI_MARA1  LIKE BAPI_MARA,    "Client Data
          BAPI_MARAX  LIKE BAPI_MARAX,
          BAPI_MARC1  LIKE BAPI_MARC,    "Plant View
          BAPI_MARCX  LIKE BAPI_MARCX,
          BAPI_MBEW1  LIKE BAPI_MBEW,    "Accounting View
          BAPI_MBEWX  LIKE BAPI_MBEWX,
          BAPI_RETURN LIKE BAPIRET2.
    DATA: BEGIN OF INT_MAKT OCCURS 100.
            INCLUDE STRUCTURE BAPI_MAKT.
    DATA: END OF INT_MAKT.
    DATA: BEGIN OF INT_MAT OCCURS 100,
             WERKS(4),     "Plant
             MTART(4),     "Material type
             MATNR(18),    "Material number
             MATKL(9) ,    "Material group
             MBRSH(1),     "Industry sector
             MEINS(3),     "Base unit of measure
             GEWEI(3),     "Weight Unit
             SPART(2),     "Division
             EKGRP(3),     "Purchasing group
             VPRSV(1),     "Price control indicator
             STPRS(12),    "Standard price
             PEINH(3),     "Price unit
             SPRAS(2),     "Language key
             MAKTX(40),     "Material description
           END OF INT_MAT.
    SELECT-OPTIONS:
                PLANT    FOR  MARC-WERKS OBLIGATORY MEMORY ID PLT,
                MATERIAL FOR  MARA-MATNR MEMORY ID MAT,
                MATLTYPE FOR  MARA-MTART MEMORY ID MTY,
                DIVISION FOR  MARA-SPART MEMORY ID DIV.
    PARAMETERS:  F_FILE LIKE RLGRAP-FILENAME
                 DEFAULT 'C:\DATA\ZMATERIAL.XLS' MEMORY ID F_FILE,
                 GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
                 UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
    IF GETDATA = 'X'.
       PERFORM DOWNLOAD_DATA.
       PERFORM DOWNLOAD_FILE.
    ENDIF.
    IF UPDDATA = 'X'.
       PERFORM UPLOAD_FILE.
       PERFORM UPDATE_MM.
    ENDIF.
    FORM DOWNLOAD_DATA.
    SELECT * FROM MARC  WHERE LVORM EQ ' '
                          AND WERKS IN PLANT
                          AND MATNR IN MATERIAL.
        CLEAR MARA.
        SELECT SINGLE * FROM MARA WHERE MATNR =  MARC-MATNR.
        CHECK MATLTYPE.
        CHECK DIVISION.
        CLEAR MBEW.
        SELECT SINGLE * FROM MBEW WHERE MATNR =  MARC-MATNR
                                    AND BWKEY =  MARC-WERKS.
        CLEAR MAKT.
        SELECT SINGLE * FROM MAKT WHERE SPRAS =  'EN'
                                    AND MATNR =  MARC-MATNR.
        WRITE:/ MARC-WERKS,    "Plant
                MARA-MTART,    "Material type
                MARA-MATNR,    "Material number
                MARA-MATKL,    "Material group
                MARA-MBRSH,    "Industry sector
                MARA-MEINS,    "Base unit of measure
                MARA-GEWEI,    "Weight Unit
                MARA-SPART,    "Division
                MARC-EKGRP,    "Purchasing group
                MBEW-VPRSV,    "Price control indicator
                MBEW-STPRS,    "Standard price
                MBEW-PEINH,    "Price unit
                MAKT-SPRAS,    "Language key
                MAKT-MAKTX.    "Material description
                INT_MAT-WERKS = MARC-WERKS.    "Plant
                INT_MAT-MTART = MARA-MTART.    "Material type
                INT_MAT-MATNR = MARA-MATNR.    "Material number
                INT_MAT-MATKL = MARA-MATKL.    "Material group
                INT_MAT-MBRSH = MARA-MBRSH.    "Industry sector
                INT_MAT-MEINS = MARA-MEINS.    "Base unit of measure
                INT_MAT-GEWEI = MARA-GEWEI.    "Weight Unit
                INT_MAT-SPART = MARA-SPART.    "Division
                INT_MAT-EKGRP = MARC-EKGRP.    "Purchasing group
                INT_MAT-VPRSV = MBEW-VPRSV.    "Price control indicator
                INT_MAT-STPRS = MBEW-STPRS.    "Standard price
                INT_MAT-PEINH = MBEW-PEINH.    "Price unit
                INT_MAT-SPRAS = MAKT-SPRAS.    "Language key
                INT_MAT-MAKTX = MAKT-MAKTX.    "Material description
                APPEND INT_MAT.
                CLEAR  INT_MAT.
    ENDSELECT.
    ENDFORM.
    FORM DOWNLOAD_FILE.
    call function 'WS_DOWNLOAD'
      EXPORTING
        FILENAME                      = F_FILE
        FILETYPE                      = 'DAT'
      FILETYPE                      = 'WK1'
      tables
        data_tab                      = INT_MAT
      EXCEPTIONS
        FILE_OPEN_ERROR               = 1
        FILE_WRITE_ERROR              = 2
        INVALID_FILESIZE              = 3
        INVALID_TYPE                  = 4
        NO_BATCH                      = 5
        UNKNOWN_ERROR                 = 6
        INVALID_TABLE_WIDTH           = 7
        GUI_REFUSE_FILETRANSFER       = 8
        CUSTOMER_ERROR                = 9
        OTHERS                        = 10.
    IF SY-SUBRC = 0.
       FORMAT COLOR COL_GROUP.
       WRITE:/ 'Data Download Successfully to your local harddisk'.
       SKIP.
    ENDIF.
    ENDFORM.
    FORM UPLOAD_FILE.
    call function 'WS_UPLOAD'
      EXPORTING
        FILENAME                      = F_FILE
        FILETYPE                      = 'DAT'
      FILETYPE                      = 'WK1'
      tables
        data_tab                      = INT_MAT
      EXCEPTIONS
        FILE_OPEN_ERROR               = 1
        FILE_WRITE_ERROR              = 2
        INVALID_FILESIZE              = 3
        INVALID_TYPE                  = 4
        NO_BATCH                      = 5
        UNKNOWN_ERROR                 = 6
        INVALID_TABLE_WIDTH           = 7
        GUI_REFUSE_FILETRANSFER       = 8
        CUSTOMER_ERROR                = 9
        OTHERS                        = 10.
    IF SY-SUBRC = 0.
       FORMAT COLOR COL_GROUP.
       WRITE:/ 'Data Upload Successfully from your local harddisk'.
       SKIP.
    ENDIF.
    ENDFORM.
    FORM UPDATE_MM.
    LOOP AT INT_MAT.
    Header
        BAPI_HEAD-MATERIAL        = INT_MAT-MATNR.
        BAPI_HEAD-IND_SECTOR      = INT_MAT-MBRSH.
        BAPI_HEAD-MATL_TYPE       = INT_MAT-MTART.
        BAPI_HEAD-BASIC_VIEW      = 'X'.
        BAPI_HEAD-PURCHASE_VIEW   = 'X'.
        BAPI_HEAD-ACCOUNT_VIEW    = 'X'.
    Material Description
        REFRESH INT_MAKT.
        INT_MAKT-LANGU           = INT_MAT-SPRAS.
        INT_MAKT-MATL_DESC       = INT_MAT-MAKTX.
        APPEND INT_MAKT.
    Client Data - Basic
        BAPI_MARA1-MATL_GROUP     = INT_MAT-MATKL.
        BAPI_MARA1-BASE_UOM       = INT_MAT-MEINS.
        BAPI_MARA1-UNIT_OF_WT     = INT_MAT-GEWEI.
        BAPI_MARA1-DIVISION       = INT_MAT-SPART.
        BAPI_MARAX-MATL_GROUP = 'X'.
        BAPI_MARAX-BASE_UOM   = 'X'.
        BAPI_MARAX-UNIT_OF_WT = 'X'.
        BAPI_MARAX-DIVISION   = 'X'.
    Plant - Purchasing
        BAPI_MARC1-PLANT      = INT_MAT-WERKS.
        BAPI_MARC1-PUR_GROUP  = INT_MAT-EKGRP.
        BAPI_MARCX-PLANT      = INT_MAT-WERKS.
        BAPI_MARCX-PUR_GROUP  = 'X'.
    Accounting
        BAPI_MBEW1-VAL_AREA   = INT_MAT-WERKS.
        BAPI_MBEW1-PRICE_CTRL = INT_MAT-VPRSV.
        BAPI_MBEW1-STD_PRICE  = INT_MAT-STPRS.
        BAPI_MBEW1-PRICE_UNIT = INT_MAT-PEINH.
        BAPI_MBEWX-VAL_AREA   = INT_MAT-WERKS.
        BAPI_MBEWX-PRICE_CTRL = 'X'.
        BAPI_MBEWX-STD_PRICE  = 'X'.
        BAPI_MBEWX-PRICE_UNIT = 'X'.
        WRITE:/ BAPI_HEAD, BAPI_MARC1.
        call function 'BAPI_MATERIAL_SAVEDATA'
          exporting
            HEADDATA                   = BAPI_HEAD
            CLIENTDATA                 = BAPI_MARA1
            CLIENTDATAX                = BAPI_MARAX
            PLANTDATA                  = BAPI_MARC1
            PLANTDATAX                 = BAPI_MARCX
          FORECASTPARAMETERS         =
          FORECASTPARAMETERSX        =
          PLANNINGDATA               =
          PLANNINGDATAX              =
          STORAGELOCATIONDATA        =
          STORAGELOCATIONDATAX       =
            VALUATIONDATA              = BAPI_MBEW1
            VALUATIONDATAX             = BAPI_MBEWX
          WAREHOUSENUMBERDATA        =
          WAREHOUSENUMBERDATAX       =
          SALESDATA                  = BAPI_MVKE1
          SALESDATAX                 = BAPI_MVKEX
          STORAGETYPEDATA            =
          STORAGETYPEDATAX           =
          IMPORTING
            RETURN                     = BAPI_RETURN
          TABLES
            MATERIALDESCRIPTION        = INT_MAKT
          UNITSOFMEASURE             =
          UNITSOFMEASUREX            =
          INTERNATIONALARTNOS        =
          MATERIALLONGTEXT           =
          TAXCLASSIFICATIONS         =
          RETURNMESSAGES             =
          PRTDATA                    =
          PRTDATAX                   =
          EXTENSIONIN                =
          EXTENSIONINX               =
    IF BAPI_RETURN-TYPE = 'E'.
       WRITE:/ 'Error Message ', BAPI_RETURN.
    ENDIF.
    ENDLOOP.
    ENDFORM.
    *---End of Program
    if u find it useful mark the points
    Regards,
    Naveen

  • Very urgent::: Standard BAPI for creating quotation in vendor side

    hi all
    i need a standard bapi for creating Quotation in the vendor side
    i found 2 bapi's :
    bapi_quotation_createfromdata,
    bapi_salesorder_createfromdat1.
    but these are related to customer side itseems...
    i want standard bapi's for vendor side Quotation creation....
    points will be awarded for useful answer...

    hi all
    i need a standard bapi for creating Quotation in the vendor side
    i found 2 bapi's :
    bapi_quotation_createfromdata,
    bapi_salesorder_createfromdat1.
    but these are related to customer side itseems...
    i want standard bapi's for vendor side Quotation creation....
    points will be awarded for useful answer...

  • Return Delivery to Vendor (Message- Determination)

    Hai All........Assalamualium.
    I want to Post a Return Delivery to Vendor using Mat.Doc.
    Movemet 122. ok
    this i am doing it Via Shipiing .
    A Return Deliver to vendor is Created .
    i can see it in VL03N.or in the PO History.
    now i want to see the preview of the Document..i.e The Return Delivery
    document and i want to send it along with the goods as a proof of delivery.
    are there any setting for the Output Types that i have to do?..
    plz Hlp me.

    Hi
    In VL02n->Extras->Delivery Output->Header
    Check if you see any message type (LD00 ?).
    If you do not see any, insert a message type LD00.
    If you want to check the IMG settings, see Txns : V/71 (for delivery types RL/RLL) and V/73 (for Item category RLLN)
    Best regards
    Ramki

  • Finding FM/BAPI/RFC for Create Inbound Delivery(vl31n).

    Hi all,
    i need for a FM/BAPI/RFC for Create Inbound Delivery(vl31n) or ASN
    where in import Parameter i have to pass -
    *vendor no*
    *PO no*
    *External ID no*
    *Delivery date*
    *TransPlanngDate*
    *BillOfLad*
    *GR/GI Slip*
    in Export i need ASN no and in tables we can use ITEM details.
    Regards,
    Sunil sahoo.

    Hi,
    Check the below link
    [https://forums.sdn.sap.com/click.jspa?searchID=16938983&messageID=5780492]
    Regards,
    Surinder

  • FM/BAPI for creating the credit memo request for Vendor

    Hi Experts,
        I need an RFC/BAPI,  for creating the credit memo request for Vendor.
    Thanks in Advance,
    Kiruba.R

    Hi,
    Use this BAPI 'BAPI_DRMCREDITMEMOREQ_CREATE' - Credit Memo Request Creation
    Regards,
    Jyothi CH.

  • M7279- Data for creating a delivery is incomplete (Vendor)

    Dear All,
    i am getting below error while processing Goods receipt.
    "M7279- Data for creating a delivery is incomplete (Vendor)" 
    1.I am doing Goods receipt with mvt type 521( GR without ref to prod order).
    2.storge location is WH manged + HU managed.
    3.Material master is assinged with sales org / distribution channel- sales view.
    4.maintained for Transportation Group . loading group - sales gen/plant data.
    5. Maintaine for shipping data for Storage location ( customisation -SPRO-LE-Shipping-Basic shipping function- Shipping points and goods receiving points determination-Assign goods receiving points for Inbound Deliveries.)
    6. HUM- setting - LG-HUM-HU requirement for storage location and default values for deliveries)
    Why system is thowing this error message as in my case vendor does not comes in to picture ( I can cosider if a GR is with refence to PO , in that case in customer master number has to be maintained in vendor master + shipping condition entered in customer master)
    Could you pl help me on above ( as this is 521 movement , it should not have any link with vendor or customer master) then why i am getting this error.
    Appreciate your earliest response.
    Om

    I am doing simple goods receipt without reference to any document ( mvt 521 - goods receipt without ref to production order) , in that case it should not ask for any vendor or should not search for vendor code , i am not getting why it is searching for vendor.
    If i removed the setting related to HU management for storage location then it allows me to post the document without any error, but if i activate for HU managment in below path i am getting error ( even in below path if i entered any vendor code then it allows me to post the document)
    Logistics general- Handling unit management- basics-materials management - inventory management -HU requirement for storage location and default values for deliveries
    plant     Storage location      Partner storage location   Sal org  Dist chan shipping division vendor customer HU requred
    05         ZBD1                       ZPK1
    in above if i entered any vendor code then it allows me to post the doc but i remove it then i am getting above error.
    If there any alternative or other setting to overcome this error.
    Thanks
    Om

  • BAPI or function module for creating outbound delivery agains STO

    Hi,
    Is there any function module or BAPI to create an outboud delivery against STO?  Appreciated if anybody tells what are all the mandatory fields to pass.
    Thanks and Regards,
    Suresh

    Hi,
    Pls check the BAPIs,
    BAPI_OUTB_DELIVERY_CONFIRM_DEC BAPI for Outbound Delivery Confirmation from a Decentralized System
    BAPI_OUTB_DELIVERY_SPLIT_DEC   BAPI for Subsequent Outbound-Delivery Split from a Decentralized Syste
    Regards,
    Renjith Michael.

  • What is the BAPI for creating an inbound delivery without reference.

    Hi Experts,
    What is the BAPI for creating an inbound delivery without reference.
    Points will be rewarded

    BAPI_DELIVERYPROCESSING_EXEC
    cheers
    Aveek

  • Regarding Return delivery to vendor

    Dear Guru's,
    While doing return delivery to vendor, i am facing an error
    "Deficit of PU IR quantity 5.000 L"
    Message no. M7021
    Pls help me out..
    Regards,
    cherukuri

    Hi Cherukuri,
    Vendor Returns after MIGO & MIRO will be handled like this.
    Create a Return Purchase Order with standard doc type NB and check the box Return Items in Po Detail tab.
    Now Make a Goods Return receipt for the return po. Here 161 Mov type will be automatically takes place.
    Now create a Credit memo for the Vendor using MIRO.
    Please check the stock is there.
    Reg,
    Ashok
    Rewards if helpful.

  • FM for create outbound delivery with order reference

    Hi,
      Can u pls tell me the function module name for create outbound delivery with order reference.
    regards,
    Mahi.

    Hi,
    You can use the BAPI BAPI_DELIVERYPROCESSING_EXEC
    Check this sample code..
    PARAMETERS: p_vbeln LIKE vbak-vbeln.
    DATA: BEGIN OF t_vbap OCCURS 0,
            vbeln LIKE vbap-vbeln,
            posnr LIKE vbap-posnr,
            kwmeng LIKE vbap-kwmeng,
            matnr  LIKE vbap-matnr,
            werks  LIKE vbap-werks,
          END OF t_vbap.
    DATA: t_request TYPE STANDARD TABLE OF bapideliciousrequest
          WITH HEADER LINE.
    DATA: t_created TYPE STANDARD TABLE OF bapideliciouscreateditems
          WITH HEADER LINE.
    DATA: t_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
    SELECT vbeln posnr kwmeng matnr werks
           INTO TABLE t_vbap
           FROM vbap
           WHERE vbeln = p_vbeln.
    LOOP AT t_vbap.
      t_request-document_numb = t_vbap-vbeln.
      t_request-document_item = t_vbap-posnr.
      t_request-quantity_sales_uom = t_vbap-kwmeng.
      t_request-id = 1.
      t_request-document_type = 'A'.
      t_request-delivery_date      = sy-datum.
      t_request-material = t_vbap-matnr.
      t_request-plant = t_vbap-werks.
      t_request-date = sy-datum.
      t_request-goods_issue_date = sy-datum.
      t_request-goods_issue_time = sy-uzeit.
      APPEND t_request.
    ENDLOOP.
    CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'
      TABLES
        request               = t_request
        createditems          = t_created
        return                = t_return
    READ TABLE t_return WITH KEY type = 'E'.
    IF sy-subrc = 0.
      MESSAGE e208(00) WITH 'Delivery creation error'.
    ENDIF.
    COMMIT WORK.
    READ TABLE t_created INDEX 1.
    Write: /  t_created-document_numb.
    Thanks
    Naren

  • Return delivery to vendor is picking incorrect customer

    Hi,
    We are trying to return the material to vendor due to quality reasons, by creating a return delivery (T-code MBRL, Mvt.-122). We are performing this as under.
    We have created this vendor as customer (say XXXXX) also, and assigned in vendor master, under control data view. Our expectation was that, the outbound return delivey should be created with customer master number XXXXX.
    But system is creating the outbound return delivery with different customer master (say YYYYY). In fact we have used this customer number in PO item details--> Delivery address, to fill the PO's delivery address as customer's address. So while doing GR (with mvt-101), in material document this customer number has been copied as partner.
    Then we tried to create the return delivery with T-code MBRL. But the system has created return delivery with customer YYYYY. But that should be created with XXXXX. As per our process we should use customer number in PO, for delivery address purposses. With out changing that, how can we correct this situation in our future transactions? Do we need to do any settings?
    Kindly throw some light on this matter and suggest.
    Thanks & regards,
    Prabhakar.

    Hi..... Mr Reddy u need not to do Shipping notification (inbound delivery) i think so.
    After creation of STPO, just go for MB1B t.code, there u can directly transport the stock from one plant to another.
    i think it will be useful for u.

  • Function module for create outbound delivery

    Hi,
          Can any one pls tell me the BAPI function module name for create outbound delivery with order reference.
    Regards,
    Mahi

    Hi
    This is the BAPI for creating Delivery with Sales Order Reference.
    You can use the BAPI <b>BAPI_DELIVERYPROCESSING_EXEC</b>
    Check this sample code..
    PARAMETERS: p_vbeln LIKE vbak-vbeln.
    DATA: BEGIN OF t_vbap OCCURS 0,
            vbeln LIKE vbap-vbeln,
            posnr LIKE vbap-posnr,
            kwmeng LIKE vbap-kwmeng,
            matnr  LIKE vbap-matnr,
            werks  LIKE vbap-werks,
          END OF t_vbap.
    DATA: t_request TYPE STANDARD TABLE OF bapideliciousrequest
          WITH HEADER LINE.
    DATA: t_created TYPE STANDARD TABLE OF bapideliciouscreateditems
          WITH HEADER LINE.
    DATA: t_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
    SELECT vbeln posnr kwmeng matnr werks
           INTO TABLE t_vbap
           FROM vbap
           WHERE vbeln = p_vbeln.
    LOOP AT t_vbap.
      t_request-document_numb = t_vbap-vbeln.
      t_request-document_item = t_vbap-posnr.
      t_request-quantity_sales_uom = t_vbap-kwmeng.
      t_request-id = 1.
      t_request-document_type = 'A'.
      t_request-delivery_date      = sy-datum.
      t_request-material = t_vbap-matnr.
      t_request-plant = t_vbap-werks.
      t_request-date = sy-datum.
      t_request-goods_issue_date = sy-datum.
      t_request-goods_issue_time = sy-uzeit.
      APPEND t_request.
    ENDLOOP.
    CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'
      TABLES
        request               = t_request
        createditems          = t_created
        return                = t_return
    READ TABLE t_return WITH KEY type = 'E'.
    IF sy-subrc = 0.
      MESSAGE e208(00) WITH 'Delivery creation error'.
    ENDIF.
    COMMIT WORK.
    READ TABLE t_created INDEX 1.
    Write: /  t_created-document_numb.
    REWARD IF HELPFUL.

Maybe you are looking for