Ansicht
Dokumentation

/SMERP/SD_DODELIVERY_STO_CRT - BAPI Wrapper: Generates Delivery for Stock Transport Order

/SMERP/SD_DODELIVERY_STO_CRT - BAPI Wrapper: Generates Delivery for Stock Transport Order

CL_GUI_FRONTEND_SERVICES - Frontend Services   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

A delivery is created for a stock transport order or for individual stock transport order items. A delivery split can mean that several deliveries are created.

With the exception of the stock transport order number in at least one entry of the STOCK_TRANS_ITEMS parameter, all parameters are optional.

Interface

Parameter Opt.   Description
Import  
SHIP_POINT X   Shipping point
DUE_DATE X   Delivery creation date
DEBUG_FLG X   Forces termination (ALE analysis)
Export  
DELIVERY X   First generated delivery
NUM_DELIVERIES X   Number of generated deliveries
Tables   Direction
STOCK_TRANS_ITEMS   Import Order items/order number (STO)
SERIAL_NUMBERS X Import Serial numbers
EXTENSION_IN X Import Additional input data
DELIVERIES X Export Generated deliveries
CREATED_ITEMS X Export Generated delivery items
EXTENSION_OUT X Export Additional output data
RETURN X Export Error log

Opt.: Optional
Direction: Shows the direction used for table parameters.
The exported table parameters are initialized before processing. This
deletes any data that was in these parameters before the BAPI was called.

Imported parameters

Shipping point (SHIP_POINT)
If the shipping point is not specified, the first shipping point that can be determined among the referenced purchase order items is selected.

Delivery creation date (DUE_DATE)
The delivery creation date selected is December 12 9999, unless specified otherwise.

DEBUG_FLG
For internal use only. The DEBUG_FLG can be used in ALE inbound processing to force a termination, thereby making the analysis of the process easier.

Stock transport order (STOCK_TRANS_ITEMS-REF_DOC)
Unless specified otherwise, the entire order is delivered. This means that it is not necessary to list all the order items. It is sufficient to specify the order number of the STO.

Stock transport order item (STOCK_TRANS_ITEMS-REF_ITEM)

The order item must be specified if one of the following applies:

  • Not all order items in the order are to be delivered
  • You want to specify delivery quantities
  • Order items are to be delivered in different deliveries (external number assignment)
Caution:

  • An order item must not occur more than once in STOCK_TRANS_ITEMS.
  • An order item must not occur if the order number occurs on its own in another entry.

Delivery quantities (STOCK_TRANS_ITEMS-LFIMG)
If no delivery quantities are specified, the delivery creation date is used to determine the delivery quantities from the schedule lines. Otherwise, the delivery quantity is copied from the original quantity.

If the delivery quantity is specified, the sales unit must be specified, either as an SAP code (SALES_UNIT) or an ISO code (SALES_UNIT_ISO).

Delivery quantities can only be specified for individual order items.

External delivery number (STOCK_TRANS_ITEMS-DELIV_NUMB)
A delivery number from the external number range interval can be
specified.

Serial numbers (SERIAL_NUMBERS)
In Parameter SERIAL_NUMBERS, serial numbers can be assigned to the delivery items that supply the specified order items.

Additional import data (EXTENSION_IN)
In Parameter EXTENSION_IN, additional data can be transferred. For more information, see the documentation for BAdI BADI_DLV_CREATE_STO_EXTIN.

Exported parameters

Delivery number (DELIVERY)
Generated delivery (key field in BOR object type LIKP). In case of a delivery split, this is the first generated delivery.

Number of generated deliveries (NUM_DELIVERIES)
In case of a delivery split, more than one delivery may be generated.

Generated deliveries (DELIVERIES)
List of all generated deliveries (including DELIVERY).

Generated delivery items (CREATED_ITEMS)
List of all generated delivery items.

Additional export data (EXTENSION_OUT)
In case of a synchronous call, additional data can be returned to the caller after delivery creation, in parameter EXTENSION_OUT. See the documentation for BAdI BADI_DLV_CREATE_EXTOUT.

Error log (RETURN)
Parameter RETURN contains the error log. In the same way as in transaction VL10, deliveries may be created even if there were error messages during processing. Since an asynchronous caller of the BAPI (ALE) only learns of the success of processing via the RETURN parameter, error messages are converted to warning messages if at least one delivery could be created. If a delivery is created successfully with converted error messages, message VLBAPI061 (see below) is output.

In addition, RETURN contains the following important messages:

Message Description
BAPI000 A delivery could be created
BAPI001 A delivery could not be created
VLBAPI061 Delivery created with errors (see warning messages)
VL311 Delivery has been saved

Thus, in case of an asynchronous call, the VL311 messages tell you which deliveries could be created.

Transactional Behavior

  • No COMMIT WORK.
  • ROLLBACK WORK, if no delivery could be created.

Example

The following report delivers a stock transport order.


report  zz_test_create_sto.

parameters: vbeln like ekko-ebeln OBLIGATORY memory id bes,
            vstel like tvst-vstel,
            logsys like tbdls-logsys default 'NONE'.

data: lf_vbeln type vbeln_vl,
      lf_num type vbnum,
      ls_deli type bapishpdelivnumb,
      lt_deli type table of bapishpdelivnumb,
      lt_order type table of bapidlvreftosto,
      ls_order type bapidlvreftosto,
      ls_itm type bapidlvitemcreated,
      lt_itm type table of bapidlvitemcreated,
      ls_ext type bapiparex,
      lt_extin type table of bapiparex,
      lt_extout type table of bapiparex,
      ls_ret type bapiret2,
      lt_return type table of bapiret2.

* StockTransItems (here: complete STO)
ls_order-ref_doc = vbeln.
append ls_order to lt_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                =
*     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
          .

write: / 'Delivery:', lf_vbeln,
       / 'NumDeliveries:', lf_num,
       / 'Deliveries:'.
loop at lt_deli into ls_deli.
  write ls_deli-deliv_numb.
endloop.

if not lt_itm[] is initial.
  write: / 'CreatedItems:'.
  loop at lt_itm into ls_itm.
    write: / ls_itm-ref_doc,
             ls_itm-ref_item,
             ls_itm-deliv_numb,
            ls_itm-deliv_item,
             ls_itm-material,
             ls_itm-dlv_qty,
             ls_itm-sales_unit,
             ls_itm-sales_unit_iso.
  endloop.
endif.

if not lt_return[] is initial.
  write: / 'Return:'.
  loop at lt_return into ls_ret.
    write: / ls_ret-type, ls_ret-id, ls_ret-number,
             ls_ret-message,
           /.
  endloop.
endif.

if not lt_extout[] is initial.
  write: / 'ExtensionOut:'.
  loop at lt_extout into ls_ext.
    write: / ls_ext.
  endloop.
endif.

* COMMIT WORK
if not lf_vbeln is initial.
  commit work.
endif.

Notes

  • This BAPI can deliver several orders simultaneously, but is not designed for mass delivery.
  • The BAPI cannot be called multiple times in one logical unit of work (LUW). After a successful call, a COMMIT WORK is required of the caller before this BAPI or another BAPI of function group V50I can be called.
  • The BAPI cannot specify delivery item numbers.

Further information

  • Documentation for parameter STOCK_TRANS_ITEMS.
  • Documentation for the BAdIs:
  • BADI_DLV_CREATE_STO_EXTIN

  • BADI_DLV_CREATE_EXTOUT





Parameters

ES_BAPI_OUTPUT
ET_CREATED_ITEMS
ET_DELIVERIES
ET_EXTENSION_OUT
ET_RETURN
EV_DELIVERY
EV_NUM_DELIVERIES
IS_BAPI_INPUT
IT_EXTENSION_IN
IT_SERIAL_NUMBERS
IT_STOCK_TRANS_ITEMS
IV_CREATE_TYPE
IV_DUE_DATE
IV_SHIP_POINT

Exceptions

Function Group

RP/SAPLBAPI_SD_DELIVERY

ROGBILLS - Synchronize billing plans   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 16470 Date: 20240419 Time: 042608     sap01-206 ( 132 ms )