06-11-2014 4:31 PM
Hello Experts,
I am using FM : BAPI_MATERIAL_SAVDATA.
In this, I am giving one volume for basic unit of measure & want to give another volume for basic unit of measure as 'ME'.
Can it be possible ? What parameters to be used in declaration & in FM ?
Thanks,
Swanand
06-12-2014 5:54 AM
Hi Swanand,
I am not sure if I got you correctly.
If you meant that you want to give one unit for Basic Unit of Measure and another for Unit of Measure, its perfectly fine. You dont have to give the same for both BUOM and UOM.
TABLES:
bapi_mara, "Clientdata
bapi_marax, "Clientdatax
bapi_marm, " Units of Measure
bapi_marmx, " Units of Measurex
DATA: BEGIN OF it_uom OCCURS 0.
INCLUDE STRUCTURE bapi_marm.
DATA:END OF it_uom.
DATA: BEGIN OF it_uomx OCCURS 0.
INCLUDE STRUCTURE bapi_marmx.
DATA:END OF it_uomx.
In this BAPI, these two are provided in the following two parameters.
* For Base unit of measure , either from input file or hardcoded.
CLEAR bapi_mara.
bapi_mara-matl_group = it_matmaster-matkl.
bapi_mara-old_mat_no = it_matmaster-bismt.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = 'PC' "it_matmaster-meins
language = sy-langu
IMPORTING
* LONG_TEXT =
output = it_matmaster-meins. .
bapi_mara-base_uom = it_matmaster-meins.
bapi_mara-base_uom_iso = it_matmaster-meins.
bapi_mara-batch_mgmt = 'X'.
CLEAR bapi_marax.
bapi_marax-base_uom = 'X'.
bapi_mara-base_uom_iso = 'X'.
bapi_marax-old_mat_no = 'X'.
bapi_marax-matl_group = 'X'.
bapi_marax-batch_mgmt = 'X'.
*For Unit of measure
* Gross Weight
if it_matmaster-brgew is not INITIAL.
bapi_marm-gross_wt = it_matmaster-brgew.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = 'KG' "it_matmaster-gewei
language = sy-langu
IMPORTING
* LONG_TEXT =
output = it_matmaster-gewei .
bapi_marm-unit_of_wt = it_matmaster-gewei.
bapi_marm-unit_of_wt_iso = it_matmaster-gewei.
bapi_marm-alt_unit = it_matmaster-meins.
bapi_marm-alt_unit_iso = it_matmaster-meins.
APPEND bapi_marm TO it_uom.
bapi_marmx-gross_wt = 'X'.
bapi_marmx-unit_of_wt = 'X'.
bapi_marmx-unit_of_wt_iso = 'X'.
bapi_marmx-alt_unit = it_matmaster-meins.
bapi_marmx-alt_unit_iso = it_matmaster-meins.
APPEND bapi_marmx TO it_uomx.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
clientdatax = bapi_marax
plantdata = bapi_marc
plantdatax = bapi_marcx
storagelocationdata = bapi_mard
storagelocationdatax = bapi_mardx
valuationdata = bapi_mbew
valuationdatax = bapi_mbewx
IMPORTING
return = it_return
TABLES
materialdescription = it_materialdesc
unitsofmeasure = it_uom
unitsofmeasurex = it_uomx
* internationalartnos = it_mean
materiallongtext = it_mltx.
IF it_return-type = 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
06-12-2014 5:54 AM
Hi Swanand,
I am not sure if I got you correctly.
If you meant that you want to give one unit for Basic Unit of Measure and another for Unit of Measure, its perfectly fine. You dont have to give the same for both BUOM and UOM.
TABLES:
bapi_mara, "Clientdata
bapi_marax, "Clientdatax
bapi_marm, " Units of Measure
bapi_marmx, " Units of Measurex
DATA: BEGIN OF it_uom OCCURS 0.
INCLUDE STRUCTURE bapi_marm.
DATA:END OF it_uom.
DATA: BEGIN OF it_uomx OCCURS 0.
INCLUDE STRUCTURE bapi_marmx.
DATA:END OF it_uomx.
In this BAPI, these two are provided in the following two parameters.
* For Base unit of measure , either from input file or hardcoded.
CLEAR bapi_mara.
bapi_mara-matl_group = it_matmaster-matkl.
bapi_mara-old_mat_no = it_matmaster-bismt.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = 'PC' "it_matmaster-meins
language = sy-langu
IMPORTING
* LONG_TEXT =
output = it_matmaster-meins. .
bapi_mara-base_uom = it_matmaster-meins.
bapi_mara-base_uom_iso = it_matmaster-meins.
bapi_mara-batch_mgmt = 'X'.
CLEAR bapi_marax.
bapi_marax-base_uom = 'X'.
bapi_mara-base_uom_iso = 'X'.
bapi_marax-old_mat_no = 'X'.
bapi_marax-matl_group = 'X'.
bapi_marax-batch_mgmt = 'X'.
*For Unit of measure
* Gross Weight
if it_matmaster-brgew is not INITIAL.
bapi_marm-gross_wt = it_matmaster-brgew.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = 'KG' "it_matmaster-gewei
language = sy-langu
IMPORTING
* LONG_TEXT =
output = it_matmaster-gewei .
bapi_marm-unit_of_wt = it_matmaster-gewei.
bapi_marm-unit_of_wt_iso = it_matmaster-gewei.
bapi_marm-alt_unit = it_matmaster-meins.
bapi_marm-alt_unit_iso = it_matmaster-meins.
APPEND bapi_marm TO it_uom.
bapi_marmx-gross_wt = 'X'.
bapi_marmx-unit_of_wt = 'X'.
bapi_marmx-unit_of_wt_iso = 'X'.
bapi_marmx-alt_unit = it_matmaster-meins.
bapi_marmx-alt_unit_iso = it_matmaster-meins.
APPEND bapi_marmx TO it_uomx.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
clientdatax = bapi_marax
plantdata = bapi_marc
plantdatax = bapi_marcx
storagelocationdata = bapi_mard
storagelocationdatax = bapi_mardx
valuationdata = bapi_mbew
valuationdatax = bapi_mbewx
IMPORTING
return = it_return
TABLES
materialdescription = it_materialdesc
unitsofmeasure = it_uom
unitsofmeasurex = it_uomx
* internationalartnos = it_mean
materiallongtext = it_mltx.
IF it_return-type = 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
06-12-2014 6:14 AM
Hi Susmitha,
I have used like this :
DATA: i_headdata TYPE bapimathead,
i_uom TYPE bapi_marm OCCURS 0 WITH HEADER LINE,
i_uomx TYPE bapi_marmx OCCURS 0 WITH HEADER LINE,
i_clientdata TYPE bapi_mara OCCURS 0 WITH HEADER LINE,
i_clientdatax TYPE bapi_marax OCCURS 0 WITH HEADER LINE,
returnmes LIKE bapi_matreturn2 OCCURS 0 WITH HEADER LINE,
i_return TYPE bapiret2.
i_headdata-material = s_matnr-low.
i_headdata-basic_view = 'X'.
i_uom-alt_unit = s_meins-low.
i_uom-volume = final_volume.
i_uomx-alt_unit = s_meins-low.
i_uomx-volume = 'X'.
i_clientdata-BASE_UOM = 'ME'.
i_clientdata-ALLWD_VOL = me_final_volume.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = i_headdata
clientdata = i_clientdata
clientdatax = i_clientdatax
* PLANTDATA =
* PLANTDATAX =
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
* VALUATIONDATA =
* VALUATIONDATAX =
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA =
* SALESDATAX =
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
* FLAG_ONLINE = ' '
* FLAG_CAD_CALL = ' '
* NO_DEQUEUE = ' '
* NO_ROLLBACK_WORK = ' '
IMPORTING
return = i_return
TABLES
* MATERIALDESCRIPTION =
unitsofmeasure = i_uom
unitsofmeasurex = i_uomx
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
returnmessages = returnmes.
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
RETURN-TYPE is 'E' in case of error, else 'S'.
IF i_return-type = 'S'.
WRITE: / 'Volume of ', s_matnr-low , 'Changed From' , ls_marm-volum , 'To' , final_volume.
COMMIT WORK AND WAIT.
ELSEIF i_return-type = 'E'..
WRITE: / 'Material Changes Failed.'. "returnmes-message'.
ROLLBACK WORK.
ENDIF.
Any corrections in this code ?
06-12-2014 6:41 AM
Just ensure that the Basic Unit of measure and alternative unit are the same.
s_meins-low should be ME in this case. or Base UOM should be s_meins-low.
Also fill values for parameter alt_unit_iso
Further, I hope you are appending i_uom and i_uomx into the tables.
i_uom-alt_unit = 'ME'. "s_meins-low.
i_uom-alt_unit_iso = 'ME'. "s_meins-low.
i_uom-volume = final_volume.
i_uomx-alt_unit = 'ME' ."s_meins-low.
i_uomx-alt_unit_iso = 'ME'. "s_meins-low.
i_clientdata-BASE_UOM = 'ME'. "s_meins-low.
06-12-2014 6:59 AM
Hi,
You cannot add more than one unit of measure in 'Basic View'.because in MARA Table MATNR(material) is keyfield.
Regards,
venkatramesh.V