09-22-2006 7:58 PM
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
09-22-2006 9:11 PM
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
09-22-2006 8:04 PM
Hi,
have a look at the Sample programs of this BAPI ..
http://www.sap-img.com/abap/sample-abap-code-on-bapi-po-change.htm
http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
Regards
Sudheer
09-22-2006 8:09 PM
Thanks for the reply Sudheer,
However those doesn't quite answer my problem.
Thanks anyways,
Jr.
09-22-2006 8:47 PM
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
09-22-2006 9:11 PM
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