Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

'BAPI_MATERIAL_SAVEDATA' - how to handle errors?

Former Member
0 Likes
474

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!

3 REPLIES 3
Read only

andreas_mann3
Active Contributor
0 Likes
389

no Steve,

you must analyze (like a message from T100)

bapi-return <b>git_rtrn</b>

regards Andreas

Read only

Former Member
0 Likes
389

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.

Read only

0 Likes
389

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