Skip to Content
0
Former Member
Sep 12, 2011 at 10:19 AM

'BAPI_OUTB_DELIVERY_CREATE_STO error

482 Views

Hi ,

Im using 'BAPI_OUTB_DELIVERY_CREATE_STO Bapi to create a delivery document. Im able to create the delivery document which i can see through debugging but the same is not getting generated and not saved in LIKP even after commiting.

Even I can not see the same created Outbound Del. Document Number in VL03N. But BAPI is getting executed without errors and giving incremented delivery doc. number everytime.

Im using the below code. Please reply if there is a solution for this problem.

Please help.

SELECT EBELN
       EBELP
       MENGE FROM EKPO INTO TABLE IT_EKPO WHERE EBELN = VBELN.

LOOP AT IT_EKPO.
LS_ORDER-REF_DOC = IT_EKPO-EBELN.
LS_ORDER-REF_ITEM  = IT_EKPO-EBELP.
LS_ORDER-DLV_QTY  = IT_EKPO-MENGE.
LS_ORDER-SALES_UNIT = 'TO'.
LS_ORDER-SALES_UNIT_ISO = 'TO'.
APPEND LS_ORDER TO LT_ORDER.
CLEAR: LS_ORDER.

* ExtensionIn
ls_ext = 'My additional input'.
append ls_ext to lt_extin.

* Synchronous RFC
call function 'BAPI_OUTB_DELIVERY_CREATE_STO'
   DESTINATION LOGSYS
    EXPORTING
     SHIP_POINT              = vstel
     DUE_DATE                = '20110910'
*     DEBUG_FLG               =
  importing
    delivery                = lf_vbeln
*    num_deliveries          = lf_num
  tables
    stock_trans_items       = lt_order
*    extension_in            = lt_extin
*    deliveries              = lt_deli
*    created_items           = lt_itm
*    extension_out           = lt_extout
    return                  = lt_return.

  CLEAR ls_ret.
  READ TABLE lt_return INTO ls_ret
             WITH KEY type = 'E'.

  IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
          .
wait UP TO 3 SECONDS.
    WRITE: 'OUTBOUND DELIVERY CREATED', LF_VBELN.

ELSE.


         refresh:lt_return.
**      MESSAGE 'Error in delivery creation' TYPE 'E'.
    MESSAGE ID ls_ret-id
          TYPE ls_ret-type
        NUMBER ls_ret-number
          WITH ls_ret-message_v1
               ls_ret-message_v2
               ls_ret-message_v3
               ls_ret-message_v4.

    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
* IMPORTING
*   RETURN        =
              .
    LEAVE PROGRAM.
ENDIF.