Application Development 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: 

ERROR: Gross Weight, Net Weight Upload using BAPI

Former Member
0 Kudos

Hi All,

I have written some code for Material Master: Gross Weight, Net Weight Upload using BAPI but i'm gettting errors from the BAPI. But i can create the same using mm02.

<b>"Specify the conversion factors for the unit of measure EA"</b>

The code i'm using is posted below.


  Loop at itab.
    select single * from mara into mara
       where matnr = itab-matnr.                        


    xbapimathead-material          =   mara-matnr.        
    xbapimathead-ind_sector        =   mara-mbrsh.        
    xbapimathead-matl_type         =   mara-mtart.        
    xbapimathead-basic_view        =   'X'.

    xbapimara-matl_group           =   mara-matkl.        

    translate itab-weight using ', '.
    condense  itab-weight no-gaps.
    move      itab-weight to ws_brgew.

    xbapimara-net_weight           =   ws_brgew.
    xbapimara-unit_of_wt           =   'LB'.

    xbapimarax-net_weight          =   'X'.
    xbapimarax-unit_of_wt          =   'X'.

    xbapimarm-gross_wt             =   ws_brgew.
    xbapimarm-unit_of_wt           =   'LB'.
    xbapimarm-alt_unit             =   mara-meins.
    append xbapimarm.

    xbapimarmx-gross_wt            =   'X'.
    xbapimarmx-unit_of_wt          =   'X'.
    xbapimarmx-alt_unit            =   mara-meins.
    append xbapimarmx.

  clear: return.     refresh: return.

  call function 'BAPI_MATERIAL_SAVEDATA'
    exporting
      headdata        = xbapimathead
      clientdata      = xbapimara
      clientdatax     = xbapimarax
    importing
      return          = return
    tables
      unitsofmeasure  = xbapimarm
      unitsofmeasurex = xbapimarmx.

  read table return with key type = 'S'.
  if sy-subrc = 0.
    call function 'BAPI_TRANSACTION_COMMIT'
      exporting
        wait   = '1'
      importing
        return = return.
  endif.

  if return-type = 'E'.
    write:/       xbapimathead-material color 6.
  elseif return-type = 'S'.
    write:/       xbapimathead-material color 5.
  endif.
  write:    20  return-type,
            40  return-id,
            55  return-number,
            75  return-message.

Endloop.

Please let me know what i'm doing wrong.

Thanks in advance.

Jr.

Message was edited by: Jr Abaper

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I checked this code..It is working fine for me..

Since your code is within a loop make sure you refresh all the internal tables...

REFRESH: xbapimarm, xbapimarmx.

As the previous material data might carry over...

Thanks,

Naren

4 REPLIES 4

Former Member

0 Kudos

Thanks for the reply Sudheer,

However those doesn't quite answer my problem.

Thanks anyways,

Jr.

0 Kudos

Please try to pass the Base Unit of Measure which you can extract from MARA. I think that will rectify your error for Unit of Measure conversions. For unit of measure conversions, check table MARM.

Kind Regards

Eswar

Former Member
0 Kudos

Hi,

I checked this code..It is working fine for me..

Since your code is within a loop make sure you refresh all the internal tables...

REFRESH: xbapimarm, xbapimarmx.

As the previous material data might carry over...

Thanks,

Naren