‎2006 Jun 19 11:32 AM
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
‎2006 Jun 19 12:24 PM
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
‎2006 Jun 19 11:41 AM
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.
‎2006 Jun 19 11:46 AM
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 ''?
‎2006 Jun 19 11:51 AM
‎2006 Jun 19 11:57 AM
How are you testing the bapi?
Did you write a program?
Are you using the same material for testing?
‎2006 Jun 19 12:10 PM
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.
‎2006 Jun 19 12:24 PM
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
‎2006 Jun 19 12:52 PM