‎2006 Aug 30 9:41 AM
hi all,
bapi_shipment_create is the bapi ,i want to use for the creation of shipment order but the structures & the fields inside that bapi is unfamiliar to me.so i need some samples so that i can follow.
1)i want to know which structures , i have to use & what r the fields of that structures, i have to pass so that a shipment order will be created.
that means, what r the fields of that bapi i have to use to crete a complete shipment order?plz suggest.
can anyone send me some sample code for creating shipment order using bapi?
Thanks & Regards
‎2006 Aug 30 9:46 AM
Sample call --- you need to populate the it_item table with the delivery note information.
IS_HEADER-TRANS_PLAN_PT = 'LHU1'.
IS_HEADER-SHIPMENT_TYPE = '0001'.
call function 'BAPI_SHIPMENT_CREATE'
exporting
HEADERDATA = IS_HEADER
importing
TRANSPORT = L_SHIPMENT_NUM
SHIPMENTGUID =
tables
HEADERDEADLINE =
ITEMDATA = IT_ITEM
STAGEDATA =
STAGEDEADLINE =
ITEMONSTAGE =
ADDRESS =
HDUNHEADER =
HDUNITEM =
RETURN = IT_RETURN
Message was edited by: Anurag Bankley
‎2006 Aug 30 9:46 AM
Sample call --- you need to populate the it_item table with the delivery note information.
IS_HEADER-TRANS_PLAN_PT = 'LHU1'.
IS_HEADER-SHIPMENT_TYPE = '0001'.
call function 'BAPI_SHIPMENT_CREATE'
exporting
HEADERDATA = IS_HEADER
importing
TRANSPORT = L_SHIPMENT_NUM
SHIPMENTGUID =
tables
HEADERDEADLINE =
ITEMDATA = IT_ITEM
STAGEDATA =
STAGEDEADLINE =
ITEMONSTAGE =
ADDRESS =
HDUNHEADER =
HDUNITEM =
RETURN = IT_RETURN
Message was edited by: Anurag Bankley
‎2006 Aug 30 9:47 AM
HI Pabitra
Though i have never worked with this FM, i think the
documentation provided should guide you for using it.
Below is the same for your reference:
Text
Create Shipment
Functionality
This function module creates a new shipment based on the
data supplied in the R/3 System.
The global data for the shipment must be specified in
structure HEADERDATA. To create a shipment, the system
needs to know the shipment type. The shipment number is
optional and is taken from the appropriate number range
and returned if it was not specified explicitly. The
transportation planning point is also optional and can be determined based on Customizing settings.
Global dates for the shipment (start of shipment, start
of loading, and so on) can be supplied by table
HEADERDEADLINE. Which deliveries should be assigned to
the shipment needs to be specified in table ITEMDATA.
The data for the shipment stages is taken from table
STAGEDATA. gelesen. Dates can also be supplied for each
stage (table STAGEDEADLINE). Because not all deliveries
necessarily need to have the same starting point and
destination, the deliveries are assigned to stages using
table ITEMONSTAGE. The addresses of the stage starting
points and destinations can be specified in detail from
table ADDRESS. Tables HDUNHEADER and HDUNITEM let you
inform the shipment that the deliveries should be packed
and which shipping units should be used.
After the function module is called, table RETURN
contains all the log entries generated during the
process.
You can create test scenarios directly with various
combinations and see the required data to be passed.
Will try to explore on my end and provide you the code
when i can make it.
Kind Regards
Eswar
‎2006 Aug 30 9:58 AM
Anurag's advice is working fine with me. Do test the
same way.
Kind Regards
Eswar
‎2006 Aug 30 10:38 AM
Hi,
Check this sample code.
REPORT ztest_bapi_shipment_create .
***************************************************************
* 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.
itemdata-DELIVERY = '0080000028'.
itemdata-ITENERARY = '0001'.
append itemdata.
************************************************************
************************************************************
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-message.
ENDLOOP.Regards
vijay