‎2006 Sep 11 10:06 AM
Hi,
i have created one report to create shipment order using BAPI_SHIPMENT_CREATE.i have not passed the data to stagedeadline & itemonstage as this is not required.
first i upload all the required data & then i passed all the data to this BAPI.
now everything is fine but i am getting 3 errors in RETURN
parameter.i am getting only message number & type of message. but not getting any message ID & message.
i want to find those error messages so that i can correct that error but could not found that message.
i am providing my coding below.did i do any mistake in my coding so that i am getting this type of message?
i think, error message should come, but how come no error message but message number?
plz suggest me.it is very urgent.
REPORT ZSHIPMENT_BAPI .
Tables:vttk, "shipment header
vttp, "shipment item
vtts, "stage in transport
vtsp, "stage in transport per shipment item
vtpa, "shipment partners
vekp, "handling unit-header table
vepo. "packing:handling unit item
DATA:gfilename LIKE rlgrap-filename.
INCLUDE <ICON>.
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,
i_return LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
shipmentid LIKE BAPISHIPMENTIDS.
Data:begin of t_upload,
"header data
stdis(1), "status of transportation planning
streg(1), "status of check in
stlbg(1), "status of start of loading
stlad(1), "status of end of loading
stabf(1), "status of shipment completion
sttbg(1), "status of start of shipment
stten(1), "status of end of shipment
vsbed(2), "shipping conditions
vsart(2), "shipping type(truck/air/ship etc)
erdat(), "Date on which shipment created
erzet(), "Time at which shipment created
route(6), "shipment route
aulwe(10), "route schedule
tdlnr(10), " no. of forwarding agent
tndr_carr(10), "forwarding agent who accepted the shipment
tndr_crnm(35), "name of carrier who accepted the shipment
tndr_trkid(35),"forwarding agent tracking ID
signi(20), "container ID
exti1(20), "external identification 1
exti2(20), "external identification 2
"header dead line
ttype(10), "logical time
utc1(15), "UTC time stamp(YYYYMMDDhhmmss)
utc2(15),
utc3(15),
utc4(15),
utc5(15),
utc6(15),
utc7(15),
utc8(15),
utc9(15),
utc10(15),
utc11(15),
utc12(15),
utc13(15),
zone(6), "Time zone
"item data
vbeln1(10), "delivery
tprfo1(4), "itinerary of shipment items
vbeln2(10), "delivery
tprfo2(4),
vbeln3(10), "delivery
tprfo3(4),
"stage data
tsnum(4), "stage of transport no
tstyp(1), "stage category
tsrfo(4), "stage of transport seq
vsart(2), "shipping type for shipment stage
knota(10), "deparature point
knotz(10), "destination point
"stage dead line
"item on stage
"address
name(25), "name 1
name_2(25), "name 2
city(15), "city
region(3), "state/province code
country(3), "country
postl_cod1(10), "city postal code
"hd un header
venum(10), "internal handling unit number
exidv(20), "external handling unit identification
exida(1), "type of external handling unit identifier
brgew(15), "total weight of handling unit
gewei(3), "weight unit
btvol(15), "total volume of handling unit
voleh(3), "volume unit
vhilm(18), "packaging materials
laeng(13), "length
breit(13), "width
hoehe(13), "height
meabm(3), "unit of dimension for length/width/height
meins(3), "base unit of measure
vhart(4), "packaging material type
inhalt(40), "description of handling unit content
magrv(4), "material group:packaging material
werks(4), "plant
"hd un item
vepos(10), "Handling unit item
id_unit(20), "ID of the handling unit into which goods r packed.
exid(20), "external handling unit identification
posnr(6), "Delivery item
vemng(15), "Base quantity packed in the handling unit item
matnr(18), "Material number
end of t_upload.
DATA:begin of t_vbup,
posnr like vbup-posnr,
wbsta like vbup-wbsta,
fksta like vbup-gbsta,
lfgsa like vbup-lfgsa,
end of t_vbup.
DATA:v_tplst like vttk-tplst,
v_shtyp like vttk-shtyp,
v_vsbed like vttk-vsbed,
v_route like vttk-route,
v_tdlnr like vttk-route,
v_vsart like vttk-route,
v_vbeln like vbuk-vbeln,
v_wbstk like vbuk-wbstk,
v_fkstk like vbuk-fkstk,
v_lfgsk like vbuk-lfgsk,
v_posnr like vbup-posnr,
v_wbsta like vbup-posnr,
v_fksta like vbup-fksta,
v_lfgsa like vbup-lfgsa,
v_msehi like t006-msehi,
v_msehi2 like t006-msehi,
v_msehi3 like t006-msehi,
v_msehi4 like t006-msehi,
v_traty like tvty-traty,
v_magrv like tvegr-magrv,
v_werks like t001w-werks.
DATA:i_upload like standard table of t_upload,
i_vbup like standard table of t_vbup,
wa_upload like t_upload,
wa_vbup like t_vbup.
*---Constants
CONSTANTS: c_comma TYPE c VALUE ',', " For splitting data at commas
c_01(2) TYPE c VALUE '01', " For movement code in Bapi
c_b TYPE c VALUE 'B', " For mvt. Indicator in Bapi
c_creat(5) TYPE c VALUE 'CREAT', " For button text
c_clear(5) TYPE c VALUE 'CLEAR', " For clear button
c_mvmt(4) TYPE c VALUE 'MVMT',
c_ok(2) TYPE c VALUE 'OK',
c_error(5) TYPE c VALUE 'Error'.
*--
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETERS: p_tplst LIKE vttk-tplst default '0001',
p_shtyp like vttk-shtyp default '0001',
p_file(256) default 'c:/shipment.txt'. "File name
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN PUSHBUTTON 15(10) v_create USER-COMMAND creat.
SELECTION-SCREEN PUSHBUTTON 40(10) v_clear USER-COMMAND clear.
*----
INITIALIZATION -
INITIALIZATION.
v_create = c_creat .
v_clear = c_clear.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM selectfile USING p_file.
*--
AT SELECTION-SCREEN .
IF sy-ucomm = c_clear.
PERFORM f_clear.
ELSE.
IF sy-ucomm <> c_mvmt.
**--- Validating the input data.
PERFORM f_check_inputs.
ELSEif sy-ucomm = c_creat.
*--- Validating the input data.
PERFORM f_check_inputs.
*-- Uploading the PO data.
PERFORM f_SHIPMENT_upload.
*---checking the PO data
PERFORM f_check_upload_data.
*---create sales order from PO data
PERFORM f_Shipment_order_create.
ENDIF.
ENDIF.
&----
*& Form f_check_inputs
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_check_inputs.
if not p_tplst is initial.
select single tplst from ttds into v_tplst where tplst = p_tplst.
if sy-subrc <> 0.
MESSAGE W001(zk) with p_tplst.
endif.
endif.
if not p_shtyp is initial.
select single shtyp from tvtk into v_shtyp where shtyp = p_shtyp.
if sy-subrc <> 0.
MESSAGE W002(zk) with p_shtyp.
endif.
endif.
ENDFORM. " f_check_inputs
&----
*& Form selectfile
&----
text
----
-->P_P_FILE text
----
FORM selectfile changing value(filename) type c.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = gfilename
def_path = 'C:\'
mask = ',*.txt.'
mode = 'O'
title = 'Select File Name'
IMPORTING
filename = filename
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
ENDFORM. " selectfile
&----
*& Form f_SHIPMENT_upload
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_SHIPMENT_upload.
gfilename = p_file.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = gfilename
filetype = 'DAT'
TABLES
data_tab = i_upload
EXCEPTIONS
conversion_error = 1
file_open_error = 2
file_read_error = 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.
MESSAGE i398(00) WITH '(WS_UPLOAD)'
' Errors occured with exception '
sy-subrc.
ENDIF.
ENDFORM. " f_SHIPMENT_upload
&----
*& Form f_Shipment_order_create
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_Shipment_order_create.
PERFORM f_fill_header.
loop at i_upload into wa_upload.
PERFORM f_fill_headerdeadline.
PERFORM f_fill_item.
PERFORM f_fill_stage.
PERFORM f_fill_stagedeadline.
PERFORM f_fill_itemonstage.
PERFORM f_fill_address.
PERFORM f_fill_hdunheader.
PERFORM f_fill_hdunitem.
endloop.
PERFORM f_call_BAPI.
ENDFORM. " f_Shipment_order_create
&----
*& Form f_fill_header
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_header.
read table i_upload into wa_upload index 1.
if not wa_upload-vsbed is initial.
select single vsbed from tvsb into v_vsbed where
vsbed = wa_upload-vsbed.
if sy-subrc <> 0.
MESSAGE W003(zk) with wa_upload-vsbed.
endif.
endif.
if not wa_upload-route is initial.
select single route from tvro into v_route where
route = wa_upload-route.
if sy-subrc <> 0.
MESSAGE W004(zk) with wa_upload-route.
endif.
endif.
if not wa_upload-tdlnr is initial.
select single lifnr from lfa1 into v_tdlnr where
lifnr = wa_upload-tdlnr.
if sy-subrc <> 0.
MESSAGE W005(zk) with wa_upload-tdlnr.
endif.
endif.
if not wa_upload-vsart is initial.
select single vsart from t173 into v_vsart where
vsart = wa_upload-vsart.
if sy-subrc <> 0.
MESSAGE W006(zk) with wa_upload-vsart.
endif.
endif.
headerdata-trans_plan_pt = p_tplst.
headerdata-shipment_type = p_shtyp.
headerdata-status_plan = wa_upload-stdis.
headerdata-status_checkin = wa_upload-stlbg.
headerdata-status_load_start = wa_upload-stlad.
headerdata-status_load_end = wa_upload-stabf.
headerdata-status_compl = wa_upload-sttbg.
headerdata-status_shpmnt_start = wa_upload-stten.
headerdata-status_shpmnt_end = wa_upload-stdis.
headerdata-shipment_route = wa_upload-route.
headerdata-route_schedule = wa_upload-aulwe.
headerdata-service_agent_id = wa_upload-tdlnr.
headerdata-tendering_carrier_id = wa_upload-tndr_carr.
headerdata-tendering_carrier_name = wa_upload-tndr_crnm.
headerdata-tendering_carrier_track_id = wa_upload-tndr_trkid.
headerdata-container_id = wa_upload-signi.
headerdata-external_id_1 = wa_upload-exti1.
headerdata-external_id_2 = wa_upload-exti2.
ENDFORM. " f_fill_header
&----
*& Form f_fill_headerdeadline
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_headerdeadline.
*end of planning
if not wa_upload-utc1 is initial.
headerdeadline-time_type = 'HDRSTPLDT'.
headerdeadline-time_stamp_utc = wa_upload-utc1.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*planned date of check in
if not wa_upload-utc2 is initial.
headerdeadline-time_type = 'HTRSTCIPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc2.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Actual date of check in
if not wa_upload-utc3 is initial.
headerdeadline-time_type = 'HTRSTCIADT'.
headerdeadline-time_stamp_utc = wa_upload-utc3.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*planned date of start of loading
if not wa_upload-utc4 is initial.
headerdeadline-time_type = 'HDRSTLSPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc4.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Current date of start of loading
if not wa_upload-utc5 is initial.
headerdeadline-time_type = 'HTRSTCIPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc5.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*planned date of end loading
if not wa_upload-utc6 is initial.
headerdeadline-time_type = 'HDRSTLEPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc6.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Actual date of end loading
if not wa_upload-utc7 is initial.
headerdeadline-time_type = 'HDRSTLEADT'.
headerdeadline-time_stamp_utc = wa_upload-utc7.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*planned date of shipment completion
if not wa_upload-utc8 is initial.
headerdeadline-time_type = 'HDRSTCPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc8.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Actual date of shipment completion
if not wa_upload-utc9 is initial.
headerdeadline-time_type = 'HDRSTCADT'.
headerdeadline-time_stamp_utc = wa_upload-utc9.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Planned date of start of shipment
if not wa_upload-utc10 is initial.
headerdeadline-time_type = 'HDRSTSSPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc10.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Actual date of start of shipment
if not wa_upload-utc11 is initial.
headerdeadline-time_type = 'HDRSTSSADT'.
headerdeadline-time_stamp_utc = wa_upload-utc11.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*planned date of end of shipment
if not wa_upload-utc12 is initial.
headerdeadline-time_type = 'HDRSTSEPDT'.
headerdeadline-time_stamp_utc = wa_upload-utc12.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
*Actual date of end of shipment
if not wa_upload-utc13 is initial.
headerdeadline-time_type = 'HDRSTSEADT'.
headerdeadline-time_stamp_utc = wa_upload-utc13.
headerdeadline-time_zone = wa_upload-zone.
append headerdeadline.
endif.
ENDFORM. " f_fill_headerdeadline
&----
*& Form f_fill_item
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_item.
*Delivery 1
if not wa_upload-vbeln1 is initial.
select single vbeln wbstk fkstk lfgsk from vbuk into
(v_vbeln, v_wbstk, v_fkstk,v_lfgsk) where vbeln = wa_upload-vbeln1.
if sy-subrc <> 0.
MESSAGE W007(zk) with wa_upload-vbeln1.
else.
if v_wbstk = 'B' AND v_fkstk = 'B' AND v_lfgsk = 'B'.
MESSAGE I008(zk) with wa_upload-vbeln1.
elseif v_wbstk = 'C' AND v_fkstk = 'C' AND v_lfgsk = 'C'..
MESSAGE W009(zk) with wa_upload-vbeln1.
endif.
endif.
*if not wa_upload-tprfo1 is initial.
select posnr wbsta fksta lfgsa from vbup into
table i_vbup where vbeln = wa_upload-vbeln1.
if sy-subrc <> 0.
MESSAGE W017(zk) with wa_upload-tprfo1.
else.
loop at i_vbup into wa_vbup.
if wa_vbup-wbsta = 'B' AND wa_vbup-fksta = 'B' AND wa_vbup-lfgsa = 'B'.
MESSAGE I018(zk) with wa_upload-vbeln1.
elseif wa_vbup-wbsta = 'C' AND wa_vbup-fksta = 'C' AND
wa_vbup-lfgsa = 'C'.
MESSAGE W019(zk) with wa_upload-vbeln1.
endif.
endloop.
endif.
itemdata-delivery = wa_upload-vbeln1.
itemdata-itenerary = wa_upload-tprfo1.
append itemdata.
endif.
**Delivery 2
*if not wa_upload-vbeln2 is initial.
*itemdata-delivery = wa_upload-vbeln2.
*itemdata-itenerary = wa_upload-tprfo2.
*append wa_upload to i_upload.
*endif.
*
*
**Delivery 3
*if not wa_upload-vbeln3 is initial.
*itemdata-delivery = wa_upload-vbeln3.
*itemdata-itenerary = wa_upload-tprfo3.
*append wa_upload to i_upload.
*endif.
*
ENDFORM. " f_fill_item
&----
*& Form f_fill_address
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_address.
if not wa_upload-name is initial.
address-name = wa_upload-name.
address-name_2 = wa_upload-name_2.
address-city = wa_upload-city.
address-region = wa_upload-region.
address-country = wa_upload-country.
address-postl_cod1 = wa_upload-postl_cod1.
append address.
endif.
ENDFORM. " f_fill_address
&----
*& Form f_fill_hdunheader
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_hdunheader.
if not wa_upload-venum is initial.
select single msehi from t006 into v_msehi where
msehi = wa_upload-gewei.
if sy-subrc <> 0.
MESSAGE W010(zk) with wa_upload-gewei.
endif.
select single msehi from t006 into v_msehi2 where
msehi = wa_upload-voleh.
if sy-subrc <> 0.
MESSAGE W011(zk) with wa_upload-voleh.
endif.
select single msehi from t006 into v_msehi3 where
msehi = wa_upload-meabm.
if sy-subrc <> 0.
MESSAGE W012(zk) with wa_upload-meabm.
endif.
select single msehi from t006 into v_msehi4 where
msehi = wa_upload-meins.
if sy-subrc <> 0.
MESSAGE W013(zk) with wa_upload-meins.
endif.
select single traty from tvty into v_traty where
traty = wa_upload-vhart.
if sy-subrc <> 0.
MESSAGE W014(zk) with wa_upload-vhart.
endif.
select single magrv from tvegr into v_magrv where
magrv = wa_upload-magrv.
if sy-subrc <> 0.
MESSAGE W015(zk) with wa_upload-magrv.
endif.
select single werks from t001w into v_werks where
werks = wa_upload-werks.
if sy-subrc <> 0.
MESSAGE W016(zk) with wa_upload-werks.
endif.
hdunheader-deliv_numb = wa_upload-vbeln1.
hdunheader-hdl_unit = wa_upload-venum.
hdunheader-hdl_unit_exid = wa_upload-exidv.
hdunheader-hdl_unit_exid_ty = wa_upload-exida.
hdunheader-total_wght = wa_upload-brgew.
hdunheader-unit_of_wt = wa_upload-gewei.
hdunheader-total_vol = wa_upload-btvol.
hdunheader-volumeunit = wa_upload-voleh.
hdunheader-ship_mat = wa_upload-vhilm.
hdunheader-length = wa_upload-laeng.
hdunheader-width = wa_upload-breit.
hdunheader-height = wa_upload-hoehe.
hdunheader-unit_dim = wa_upload-meabm.
hdunheader-base_uom = wa_upload-meins.
hdunheader-sh_mat_typ = wa_upload-vhart.
hdunheader-mat_grp_sm = wa_upload-magrv.
hdunheader-plant = wa_upload-werks.
append hdunheader.
endif.
ENDFORM. " f_fill_hdunheader
&----
*& Form f_fill_hdunitem
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_hdunitem.
if not wa_upload-tprfo1 is initial.
hdunitem-hdl_unit_no = wa_upload-venum.
hdunitem-hdl_unit_exid = wa_upload-exidv.
hdunitem-deliv_numb = wa_upload-vbeln1.
hdunitem-deliv_item = wa_upload-tprfo1.
hdunitem-pack_qty = wa_upload-vemng.
*hdunitem-material = wa_upload-matnr.
hdunitem-hdl_unit_exid_into = wa_upload-id_unit.
append hdunitem.
endif.
ENDFORM. " f_fill_hdunitem
&----
*& Form f_call_BAPI
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_call_BAPI.
clear: headerdeadline,itemdata,address,hdunheader,hdunitem.
CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
EXPORTING
HEADERDATA = headerdata
IMPORTING
TRANSPORT = shipmentid-shipmentnum
SHIPMENTGUID = shipmentid-guid
TABLES
RETURN = i_return
HEADERDEADLINE = headerdeadline
ITEMDATA = itemdata
STAGEDATA = stagedata
STAGEDEADLINE =
ITEMONSTAGE =
ADDRESS = address
HDUNHEADER = hdunheader
HDUNITEM = hdunitem.
if not ( shipmentid-shipmentnum is initial ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write: /'Shipment Number:', shipmentid-shipmentnum,
/'shipment GUID:', shipmentid-guid.
else.
loop at i_return.
IF i_return-TYPE = 'E'.
ULINE /1(108).
write:/ icon_led_RED as icon, i_return-MESSAGE,i_return-NUMBER,
i_return-ID.
ULINE /1(108).
ENDIF.
IF i_return-TYPE = 'W'.
ULINE /1(108).
write:/ icon_led_YELLOW as icon, i_return-MESSAGE,i_return-NUMBER,
i_return-ID.
ULINE /1(108).
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " f_call_BAPI
&----
*& Form f_clear
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_clear.
clear:p_tplst,
p_shtyp.
ENDFORM. " f_clear
&----
*& Form f_fill_stage
&----
text
----
--> p1 text
<-- p2 text
----
FORM f_fill_stage.
if not wa_upload-tstyp is initial.
stagedata-stage_cat = wa_upload-tstyp.
stagedata-stage_seq = wa_upload-tsrfo.
stagedata-shipping_type = wa_upload-vsart.
stagedata-org_point = wa_upload-knota.
stagedata-dest_point = wa_upload-knotz.
append stagedata.
endif.
ENDFORM. " f_fill_stage
Regards
pabitra
‎2006 Sep 12 1:19 AM
Hi all,
plz somebody suggest me, where i am doing mistake?it is very urgent.points will be rewarded for correct answers.
Thanks in advance.
Regards
‎2006 Sep 12 1:19 AM
Hi all,
plz somebody suggest me, where i am doing mistake?it is very urgent.points will be rewarded for correct answers.
Thanks in advance.
Regards
‎2006 Sep 12 1:28 AM
Did you check if you have anything in the Message(BAPIRET2-MESSAGE) of the return, am assuming your message should be populated in there.
hith
Sunil Achyut
Message was edited by: Sunil Achyut