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

BAPI_MATERIAL_SAVEDATA

0 Likes
769

Hi all,

this is the part of code where I set to '20' the status of material 'AL1001' in division/plant 'AOI1'. It work well. Now, I have to set the same status to the default/null/void value ''. I write '' instead of '20', but it doesn't work. why?

        • part of code ****

testata-material = 'AL1001'.

testata-purchase_view = 'X'.

tb_marc-plant = 'AOI1'.

tb_marc-pur_status = '20'.

tb_marcx-plant = 'AOI1'.

tb_marcx-pur_status = '20'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = testata

plantdata = tb_marc

plantdatax = tb_marcx

IMPORTING

return = tb_ret

1 ACCEPTED SOLUTION
Read only

santhosh_patil
Contributor
0 Likes
699

hi,

Try this code it may work,if we want to update any entry in the plantdata(tb_marc) the corresponding entry in the plantdatax(tb_marcx) must be set to 'X'.

tb_marc-plant = 'AOI1'.

tb_marc-pur_status = ' '.

<b>tb_marcx-plant = 'AOI1'.

tb_marcx-pur_status = 'X'.</b>

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = testata

plantdata = tb_marc

plantdatax = tb_marcx

IMPORTING

return = tb_ret

7 REPLIES 7
Read only

Former Member
0 Likes
699

Gilbert,

Why don't you try clearing the value in tb_marc-pur_status = '20'rather than initializing it to blank. May be it would work.

Regards,

Abhijeet.

Read only

0 Likes
699

Because if a field has a clear value then the BAPI don't update that field.

In my situation, if the field tb_marc-pur_status is null or void or '' or clear, the 'BAPI_MATERIAL_SAVEDATA' don't update that field.

Exist another way to update a field to ''?

Read only

0 Likes
699

Help me, please!

Read only

0 Likes
699

How are you testing the bapi?

Did you write a program?

Are you using the same material for testing?

Read only

0 Likes
699

First case (right, itipudate the value to '20')

REPORT ztest.

DATA testata LIKE bapimathead.

DATA tb_marc LIKE bapi_marc.

DATA tb_marcx LIKE bapi_marcx.

DATA tb_ret LIKE bapiret2.

testata-material = 'AL1001'.

testata-purchase_view = 'X'.

tb_marc-plant = 'AOI1'.

tb_marc-pur_status = '20'.

clear tb_marc-pur_status.

tb_marcx-plant = 'AOI1'.

tb_marcx-pur_status = '20'.

clear tb_marcx-pur_status.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = testata

plantdata = tb_marc

plantdatax = tb_marcx

IMPORTING

return = tb_ret

.

IF tb_ret-type = 'E'.

WRITE:/ 'Error Message ', tb_ret-message.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

WRITE:/ 'Update eseguito'.

ENDIF.

************************************************

Second case (wrong. It don't update the value)

REPORT ztest.

DATA testata LIKE bapimathead.

DATA tb_marc LIKE bapi_marc.

DATA tb_marcx LIKE bapi_marcx.

DATA tb_ret LIKE bapiret2.

testata-material = 'AL1001'.

testata-purchase_view = 'X'.

tb_marc-plant = 'AOI1'.

tb_marc-pur_status = ''.

clear tb_marc-pur_status.

tb_marcx-plant = 'AOI1'.

tb_marcx-pur_status = ''.

clear tb_marcx-pur_status.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = testata

plantdata = tb_marc

plantdatax = tb_marcx

IMPORTING

return = tb_ret

.

IF tb_ret-type = 'E'.

WRITE:/ 'Error Message ', tb_ret-message.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

WRITE:/ 'Update eseguito'.

ENDIF.

Read only

santhosh_patil
Contributor
0 Likes
700

hi,

Try this code it may work,if we want to update any entry in the plantdata(tb_marc) the corresponding entry in the plantdatax(tb_marcx) must be set to 'X'.

tb_marc-plant = 'AOI1'.

tb_marc-pur_status = ' '.

<b>tb_marcx-plant = 'AOI1'.

tb_marcx-pur_status = 'X'.</b>

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = testata

plantdata = tb_marc

plantdatax = tb_marcx

IMPORTING

return = tb_ret

Read only

0 Likes
699

thank you!