05-18-2006 8:04 PM
Hello all.
Im trying to update a material using BAPI_MATERIAL_SAVEDATA, I have to update the field PLANTDATA-VARIANCE_KEY among others.
But the BAPI returns with the following error:
<i>Key fields for user data PLANTDATA and checkbox structure PLANTDATAX are different</i>
Here is my code
LOOP AT it_data WHERE result EQ 1.
CLEAR: header, w_mbew, return, return_msg.
REFRESH: return_msg.
*- Header data
header-material = it_data-matnr.
header-cost_view = 'X'.
header-purchase_view = 'X'.
header-matl_type = it_data-mtart.
*- Valuation View
w_mbew-val_area = it_data-werks.
w_mbew-qty_struct = ' '.
w_mbew-plndprice1 = it_data-zplp1.
w_mbew-price_unit = it_data-peinh.
w_mbew-price_ctrl = it_data-vprsv.
w_mbew-std_price = it_data-stprs.
w_mbew-moving_pr = it_data-verpr.
w_mbew-plndprdate1 = p_zldp1.
w_mbewx-val_area = it_data-werks.
w_mbewx-qty_struct = 'X'.
w_mbewx-plndprice1 = 'X'.
w_mbewx-price_unit = 'X'.
w_mbewx-price_ctrl = 'X'.
w_mbewx-std_price = 'X'.
w_mbewx-moving_pr = 'X'.
w_mbewx-plndprdate1 = 'X'.
* Plant data
w_marc-plant = it_data-werks.
w_marc-variance_key = it_data-awsls.
w_marcx-plant = 'X'.
w_marcx-variance_key = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = header
plantdata = w_marc
plantdatax = w_marcx
valuationdata = w_mbew
valuationdatax = w_mbewx
IMPORTING
return = return
TABLES
returnmessages = return_msg.
Any help will be rewarded...
05-18-2006 8:09 PM
Please try......
* Plant data
w_marc-plant = it_data-werks.
w_marc-variance_key = it_data-awsls.
<b>w_marcx-plant = it_data-werks. </b>
w_marcx-variance_key = 'X'.
The reason is that the PLANT field in the "X" structure is not a flag field, but the 4 character plant field which needs a valid plant.
Regards,
Rich Heilman
05-18-2006 8:09 PM
Please try......
* Plant data
w_marc-plant = it_data-werks.
w_marc-variance_key = it_data-awsls.
<b>w_marcx-plant = it_data-werks. </b>
w_marcx-variance_key = 'X'.
The reason is that the PLANT field in the "X" structure is not a flag field, but the 4 character plant field which needs a valid plant.
Regards,
Rich Heilman