‎2005 Jul 01 10:46 AM
Howdy,
I want to use the following BAPI:
'BAPI_MATERIAL_SAVEDATA'.
Unfortunately it has no 'Exceptions' so how would I handle errors?
Currently it is coded like this:
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = st_head
clientdata = st_mara
clientdatax = st_marax
plantdata = st_plant
plantdatax = st_plantx
importing
return = git_rtrn
tables
materialdescription = git_makt.
if sy-subrc <> 0.
perform change_zsrcmtrx_status using 'E'.
else.
perform change_zsrcmtrx_status using 'P'.
endif.Would it be okay to add something like this:
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = st_head
clientdata = st_mara
clientdatax = st_marax
plantdata = st_plant
plantdatax = st_plantx
importing
return = git_rtrn
tables
materialdescription = git_makt
exceptions
error_message = 3
others = 4.
if sy-subrc <> 0.
perform change_zsrcmtrx_status using 'E'.
else.
perform change_zsrcmtrx_status using 'P'.
endif.Thanks for any input!
‎2005 Jul 01 10:49 AM
no Steve,
you must analyze (like a message from T100)
bapi-return <b>git_rtrn</b>
regards Andreas
‎2005 Jul 01 10:50 AM
Hi Steve,
This Bapi doesn't need the "Commit", so datas aren't save if errors occured.
As for the errors, check for the 'returnmessages' table.
Take a look at the following code :
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
clientdata = clientdata
clientdatax = clientdatax
plantdata = plantdata
plantdatax = plantdatax
forecastparameters = forecastparameters
forecastparametersx = forecastparametersx
planningdata = planningdata
planningdatax = planningdatax
storagelocationdata = storagelocationdata
storagelocationdatax = storagelocationdatax
valuationdata = valuationdata
valuationdatax = valuationdatax
warehousenumberdata = warehousenumberdata
warehousenumberdatax = warehousenumberdatax
salesdata = salesdata
salesdatax = salesdatax
storagetypedata = storagetypedata
storagetypedatax = storagetypedatax
flag_online = ' '
flag_cad_call = ' '
importing
return = return
tables
* materialdescription =
* unitsofmeasure =
* unitsofmeasurex =
* internationalartnos =
* materiallongtext =
* taxclassifications =
returnmessages = t_return_msg .
* prtdata =
* prtdatax =
* extensionin =
* extensioninx =
loop at t_return_msg.
move-corresponding t_return_msg to t_return_msg_all.
append t_return_msg_all.
endloop.
Hope this helps,
erwan.
‎2005 Jul 01 11:33 AM
Thanks Guys - that was really useful.
Would you know what would have happened if I had used sy-subrc, as I had originally stated? Would it always have been set to '0'?
Thanks