Skip to Content
0
Former Member
Sep 22, 2006 at 06:58 PM

ERROR: Gross Weight, Net Weight Upload using BAPI

630 Views

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