Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Author: Andrea Olivieri
Submitted: 22 October 2010

Highlights

This is an extract of the OSS Note 531207 - Use of BAPI_SHIPMENT_CREATE concerning shipping statuses created as answer to this thread

Symptom

This note complements the documentation for the interface of function module BAPI_SHIPMENT_CREATE concerning dates and transportation planning status.
Function module BAPI_SHIPMENT_CREATE is able to generateshipment documents including preassigned planned and actual dates for the individual shipping statuses planning, registration, loading start, loading end, shipment completion, shipment start and shipment end.
On the one hand, BAPI_SHIPMENT_CREATE can be used as a remote-enabledmodule. On the other hand, you have the option of using the function within the EDI with function module IDOC_INPUT_SHIPMENT_CREATEFROM or IDoc basic type SHIPMENT_CREATEFROMDATA01 (IDOC_INPUT_SHIPMENT_CREATEFROM only converts SHIPMENT_CREATEFROMDATA01 and then calls BAPI_SHIPMENT_CREATE for further processing)

Other terms

Alternative for idoc_input_shpmnt

Reason and Prerequisites

When you use bapi_shipment_create, there are different ways of setting the different dates of the shipment header. The following statements can be understood by means of the attached report ZTEST_BAPI_SHIPMENT_CREATE2.

Only the fields

  • bapishipmentheader-status_plan
  • bapishipmentheader-status_checkin
  • bapishipmentheader-status_load_start
  • bapishipmentheader-status_load_end
  • bapishipmentheader-status_compl
  • bapishipmentheader-status_shpmnt_start
  • bapishipmentheader-status_shpmnt_end
    of structure bapishipmentheader are set with the call of bapi_shipment_create (value = 'X'): In this case the corresponding statuses of the new shipment are also set, the respective DATA and TIMES
  1. VTTK-DTDIS --> Date of end of planning
  2. VTTK-UZDIS --> Scheduling end time
  3. VTTK-DAREG --> Actual date of check-in
  4. VTTK-UAREG --> Current time of check-in
  5. VTTK-DALBG --> Current date for start of loading
  6. VTTK-UALBG --> Actual loading start time
  7. VTTK-DALEN --> Actual date for end of loading
  8. VTTK-UALEN --> Actual loading end time
  9. VTTK-DTABF --> Current date of shipment completion
  10. VTTK-UZABF --> Time of transportation processing
  11. VTTK-DATBG --> Current date for start of shipment
  12. VTTK-UATBG --> Actual transport start time
  13. VTTK-DATEN --> Actual date for end of shipment
  14. VTTK-UATEN --> Actual shipment end time
    correspond to the SYSTEM DATE or the SYSTEM TIME, at which the function module was imported. The respective PLANNED data and PLANNED times remain empty.
  • Filling the seven above-mentioned BAPISHIPMENTHEADER fieldsis not necessary if you assign the HEADERDEADLINE interface to the function module. If Headerdeadline is filled correctly, the statuses of the shipment WITH date and time are taken from this structure. (Setting the fields from Bapishipmentheader is not necessary in this case, but also not incorrect). The PLANNED data can also be set with structure HEADERDEADLINE.

However, structure HEADERDEADLINE must be filled in accordance with the following rule:

  • TIME_TYPE = logical time --> to be filled with fixed values:
  1. TIME_TYPE = HDRSTPLDT --> Date/time of end of planning
  2. TIME_TYPE = HDRSTCIPDT --> PLANNED date/time of check-in
  3. TIME_TYPE = HDRSTCIADT --> ACTUAL date/time of check-in
  4. TIME_TYPE = HDRSTLSPDT --> PLANNED date/time of loading start
  5. TIME_TYPE = HDRSTLSADT --> ACTUAL date/time of loading start
  6. TIME_TYPE = HDRSTLEPDT --> PLANNED date/time of loading end
  7. TIME_TYPE = HDRSTLEADT --> ACTUAL date/time of loading end
  8. TIME_TYPE = HDRSTCPDT --> PLANNED date/time of shipment completion
  9. TIME_TYPE = HDRSTCADT --> ACTUAL date/time of shipment completion
  10. TIME_TYPE = HDRSTSSPDT --> PLANNED date/time of shipment start
  11. TIME_TYPE = HDRSTSSADT --> ACTUAL date/time of shipment start
  12. TIME_TYPE = HDRSTSEPDT --> PLANNED date/time of shipment end
  13. TIME_TYPE = HDRSTSEADT --> ACTUAL date/time of shipment end

These equivalents can also be found in function group V56I_BAPI --> Include LV56I_BAPITOP

  • TIME_STAMP_UTC = UTC time stamp in short form (YYYYMMDDhhmmss)
  • TIME_ZONE = time zone

Remark

If you set some fields, which do not have any equivalent in Headerdeadline, in Bapishipmentheader, system date and system time are set again for these (current) shipping statuses. The planned data stays empty for these (additional) statuses.

Solution

Here you can find the specified SAMPLE report .

Error rendering macro 'code': Invalid value specified for parameter 'lang'
REPORT ZTEST_BAPI_SHIPMENT_CREATE2 .
***************************************************************
* This report is provided to help understanding the interface *
* of function module 'BAPI_SHIPMENT_CREATE' with regard to    *
* its ability to fill the different shipment-deadlines        *
* With running this report, new shipments are created         *
***************************************************************
* fill the interface for bapi
DATA: HEADERDATA LIKE BAPISHIPMENTHEADER,
         HEADERDEADLINE LIKE BAPISHIPMENTHEADERDEADLINE
                    OCCURS 0 WITH HEADER LINE,
         ITEMDATA LIKE BAPISHIPMENTITEM  OCCURS 0 WITH HEADER LINE,
         STAGEDATA LIKE BAPISHIPMENTSTAGE OCCURS 0 WITH HEADER LINE,
         STAGEDEADLINE LIKE BAPISHIPMENTSTAGEDEADLINE
                           OCCURS 0 WITH HEADER LINE,
         ITEMONSTAGE LIKE BAPISHIPMENTITEMONSTAGE
                          OCCURS 0 WITH HEADER LINE,
         ADDRESS LIKE BAPISHIPMENTADDRESS
                          OCCURS 0 WITH HEADER LINE,
         HDUNHEADER LIKE BAPISHIPMENTHDUNHEADER
                          OCCURS 0 WITH HEADER LINE,
         HDUNITEM LIKE BAPISHIPMENTHDUNITEM
                          OCCURS 0 WITH HEADER LINE,
         RETURN LIKE BAPIRET2  OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN COMMENT /1(83) COM1.
SELECTION-SCREEN COMMENT /1(83) COM2.
SELECTION-SCREEN COMMENT /1(83) COM3.
SELECTION-SCREEN COMMENT /1(83) COM4.
SELECTION-SCREEN COMMENT /1(83) COM5.
SELECTION-SCREEN COMMENT /1(83) COM6.
SELECTION-SCREEN COMMENT /1(83) COM7.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN ULINE.

SELECTION-SCREEN BEGIN OF BLOCK HEADER WITH FRAME TITLE TEXT-HRD.
* Headerdate - obligatory
SELECTION-SCREEN COMMENT /1(79) COM8 FOR FIELD TPLST.
PARAMETER: TPLST LIKE VTTK-TPLST.
SELECTION-SCREEN COMMENT /1(79) COM9 FOR FIELD TPLST.
PARAMETER: SHTYP LIKE VTTK-SHTYP.
SELECTION-SCREEN END OF BLOCK HEADER.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF BLOCK STATUS WITH FRAME TITLE COM10.
* Plan
PARAMETER:  PLAN LIKE  BAPISHIPMENTHEADER-STATUS_PLAN.
*checkin
PARAMETER:  CHECK LIKE  BAPISHIPMENTHEADER-STATUS_CHECKIN.
*load start
PARAMETER:  LOAD_S LIKE  BAPISHIPMENTHEADER-STATUS_LOAD_START.
*load end
PARAMETER:  LOAD_E LIKE  BAPISHIPMENTHEADER-STATUS_LOAD_END.
*Completion
PARAMETER:  COMPL LIKE  BAPISHIPMENTHEADER-STATUS_COMPL.
* tra begin
PARAMETER:  SHIP_S LIKE  BAPISHIPMENTHEADER-STATUS_SHPMNT_START.
* tra end
PARAMETER:  SHIP_E LIKE  BAPISHIPMENTHEADER-STATUS_SHPMNT_END.
SELECTION-SCREEN END OF BLOCK STATUS.
* Headerdeadline
SELECTION-SCREEN BEGIN OF BLOCK H_DEADLINE WITH FRAME TITLE COM11.
PARAMETERS: TTYPE(10)
            DEFAULT 'HDRSTPLDT', "= End of planning
            UTC LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE2(10)
            DEFAULT 'HDRSTCIPDT',"= planned date of check-in
            UTC2 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE2 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE3(10)
            DEFAULT 'HDRSTCIADT',"= actual date of check-in
            UTC3 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE3 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE4(10)
            DEFAULT 'HDRSTLSPDT',"= planned date f. start loading
            UTC4 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE4 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE5(10)
            DEFAULT 'HDRSTLSADT',"= current date f. start loading
            UTC5 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE5 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE6(10)
            DEFAULT 'HDRSTLEPDT',"= planned date f. end loading
            UTC6 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE6 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE7(10)
            DEFAULT 'HDRSTLEADT',"= actual date f. end loading
            UTC7 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE7 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE8(10)
            DEFAULT 'HDRSTCPDT',"= planned date f. shpmnt completion
            UTC8 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE8 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE9(10)
            DEFAULT 'HDRSTCADT',"= actual date f. shpmnt completion
            UTC9 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE9 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE10(10)
            DEFAULT 'HDRSTSSPDT',"= planned date f. start shpmnt
            UTC10 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE10 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE11(10)
            DEFAULT 'HDRSTSSADT',"= actual date f. start shpmnt
            UTC11 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE11 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE12(10)
            DEFAULT 'HDRSTSEPDT',"= planned date f. end shpmnt
            UTC12 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE12 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
PARAMETERS: TTYPE13(10)
            DEFAULT 'HDRSTSEADT',"= actual date f. end shpmnt
            UTC13 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_STAMP_UTC,
            ZONE13 LIKE BAPISHIPMENTHEADERDEADLINE-TIME_ZONE.
SELECTION-SCREEN END OF BLOCK H_DEADLINE.
***********************************************************************
* Format the select-options                                           *
***********************************************************************
INITIALIZATION.
  COM1 = 'This report was provided to help understanding the behaviour'.
  COM2 = 'of function module BAPI_SHIPMENT_CREATE with regard to its '.
  COM3 = 'ability to fill the new shipments deadlines: '.
  COM4 = 'Planning, Check-In, Loading Start, Loading end, '.
  COM5 = 'Shpmnt completion, Shipment start and shipment end.'.
  COM6 = 'This report creates new shipments which can be '.
  COM7 = 'viewed e.g. with transaction VT03n'.
  COM8 = 'Transportation Planning Point (obligatory)'.
  COM9 = 'Shipment type (obligatory)'.
  COM10 = 'BAPISHIPMENTHEADER-Flags --> see note 531207 '.
  COM11 = 'HEADERDEADLINE-Structure --> see note 531207 '.
***********************************************************************

START-OF-SELECTION.
******************head begin***********************************
  HEADERDATA-TRANS_PLAN_PT = TPLST.
  HEADERDATA-SHIPMENT_TYPE = SHTYP.
* change Plan status
*  HEADERDATA-SHIPMENT_NUM = tknum.
  IF PLAN <> SPACE.
    HEADERDATA-STATUS_PLAN = PLAN.
  ENDIF.
* Change Check_in status
  IF CHECK <> SPACE.
    HEADERDATA-STATUS_CHECKIN = CHECK.
  ENDIF.
*load beginn
  IF LOAD_S <> SPACE .
    HEADERDATA-STATUS_LOAD_START = LOAD_S.
  ENDIF.
* load end
  IF LOAD_E <> SPACE .
    HEADERDATA-STATUS_LOAD_END = LOAD_E.
  ENDIF.
* completion
  IF COMPL <> SPACE.
    HEADERDATA-STATUS_COMPL = COMPL.
  ENDIF.
*tra beginn
  IF SHIP_S <> SPACE.
    HEADERDATA-STATUS_SHPMNT_START = SHIP_S.
  ENDIF.
*tra beginn
  IF SHIP_E <> SPACE.
    HEADERDATA-STATUS_SHPMNT_END = SHIP_E.
  ENDIF.
***** HEADERDEADLINE END OF PLANNING
  IF TTYPE <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC.
    HEADERDEADLINE-TIME_ZONE = ZONE.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE PLANNED DATE OF CHECK-IN
  IF TTYPE2 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE2.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC2.
    HEADERDEADLINE-TIME_ZONE = ZONE2.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE ACTUAL DATE OF CHECK-IN
  IF TTYPE3 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE3.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC3.
    HEADERDEADLINE-TIME_ZONE = ZONE3.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE PLANNED D START OF LOADING
  IF TTYPE4 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE4.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC4.
    HEADERDEADLINE-TIME_ZONE = ZONE4.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE CURRENT D START OF LOADING
  IF TTYPE5 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE5.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC5.
    HEADERDEADLINE-TIME_ZONE = ZONE5.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE PLANNED D END OF LOADING
  IF TTYPE6 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE6.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC6.
    HEADERDEADLINE-TIME_ZONE = ZONE6.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE ACTUAL D END OF LOADING
  IF TTYPE7 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE7.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC7.
    HEADERDEADLINE-TIME_ZONE = ZONE7.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE PLANNED D SHIPMENT COMPLETION
  IF TTYPE8 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE8.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC8.
    HEADERDEADLINE-TIME_ZONE = ZONE8.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE ACTUAL D SHIPMENT COMPLETION
  IF TTYPE9 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE9.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC9.
    HEADERDEADLINE-TIME_ZONE = ZONE9.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE PLANNED D START OF SHIPMENT
  IF TTYPE10 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE10.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC10.
    HEADERDEADLINE-TIME_ZONE = ZONE10.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE ACTUAL D START OF SHIPMENT
  IF TTYPE11 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE11.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC11.
    HEADERDEADLINE-TIME_ZONE = ZONE11.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE PLANNED D END OF SHIPMENT
  IF TTYPE12 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE12.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC12.
    HEADERDEADLINE-TIME_ZONE = ZONE12.
    APPEND HEADERDEADLINE.
  ENDIF.
***** HEADERDEADLINE CURRENT D END OF SHIPMENT
  IF TTYPE13 <> SPACE.
    HEADERDEADLINE-TIME_TYPE = TTYPE13.
    HEADERDEADLINE-TIME_STAMP_UTC = UTC13.
    HEADERDEADLINE-TIME_ZONE = ZONE13.
    APPEND HEADERDEADLINE.
  ENDIF.
************************************************************
************************************************************
  CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
    EXPORTING
      HEADERDATA     = HEADERDATA
    TABLES
      HEADERDEADLINE = HEADERDEADLINE
      ITEMDATA       = ITEMDATA
      STAGEDATA      = STAGEDATA
      STAGEDEADLINE  = STAGEDEADLINE
      ITEMONSTAGE    = ITEMONSTAGE
      ADDRESS        = ADDRESS
      HDUNHEADER     = HDUNHEADER
      HDUNITEM       = HDUNITEM
      RETURN         = RETURN.
  LOOP AT RETURN.
    WRITE: RETURN.
  ENDLOOP.