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

Problems updating MARM table using bapi_material_save_data

0 Likes
1,895

I need to do a mass update to the "EA" unit of measure record in my MARM table. I am new to ABAP and my code is not working. Can someone review and tell me what I have done wrong.

I have written the program to run from select parameters for starters, when this works I will replace with a table to update all my UOM's.

DATA: BEGIN OF it_unitsofmeasure OCCURS 0.

INCLUDE STRUCTURE bapi_marm.

DATA: END OF it_unitsofmeasure.

DATA: BEGIN OF it_unitsofmeasurex OCCURS 0.

INCLUDE STRUCTURE bapi_marmx.

DATA: END OF it_unitsofmeasurex.

DATA: BEGIN OF wa_bapimathead.

INCLUDE STRUCTURE bapimathead.

DATA: END OF wa_bapimathead.

DATA: BEGIN OF IT_BAPIRET2.

INCLUDE STRUCTURE BAPIRET2.

DATA: END OF IT_BAPIRET2.

PARAMETER: zmat LIKE bapimathead-material.

PARAMETER: zalt LIKE bapi_marm-alt_unit.

PARAMETER: znum LIKE bapi_marm-numerator.

PARAMETER: zden LIKE bapi_marm-denominatr.

wa_bapimathead-material = zmat.

it_unitsofmeasure-alt_unit = zalt.

it_unitsofmeasure-numerator = znum.

it_unitsofmeasure-denominatr = zden.

it_unitsofmeasureX-alt_unit = 'EA'.

it_unitsofmeasureX-numerator = 'X'.

it_unitsofmeasureX-denominatr = 'X'.

APPEND it_unitsofmeasure.

APPEND it_unitsofmeasurex.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = wa_bapimathead

  • CLIENTDATA =

  • 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 = IT_BAPIRET2

TABLES

  • MATERIALDESCRIPTION =

unitsofmeasure = it_unitsofmeasure

unitsofmeasurex = it_unitsofmeasurex

  • INTERNATIONALARTNOS =

  • MATERIALLONGTEXT =

  • TAXCLASSIFICATIONS =

  • RETURNMESSAGES =

  • PRTDATA =

  • PRTDATAX =

  • EXTENSIONIN =

  • EXTENSIONINX =

. "period

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

3 REPLIES 3
Read only

Former Member
0 Likes
1,224

Change this

wa_bapimathead-material = zmat.

it_unitsofmeasure-alt_unit = zalt.

it_unitsofmeasure-numerator = znum.

it_unitsofmeasure-denominatr = zden.

it_unitsofmeasureX-alt_unit = zalt.

it_unitsofmeasureX-numerator = 'X'.

it_unitsofmeasureX-denominatr = 'X'.

in function call

tables
unitsofmeasure = it_unitsofmeasure[]
unitsofmeasurex = it_unitsofmeasurex[]

Read only

0 Likes
1,224

thank you for your help, I added the changes, but it still did not work. I printed out the IT_BAPIRET2 return and it says my my material was created or extended.

Maybe I am mistaken, but I should be able to update an existing EA record with the new denom and numerator, correct? If so, am I using the commit FM incorrectly?

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

Read only

0 Likes
1,224

I am closing this thread, the problem was I had not selected at least one view in the mathead. Once I selected Basic_view, the unit of measure updated. Thanks for all your help