‎2009 Jun 10 2:00 PM
Hi Gurus,
I am getting this error message while using BAPI_MATERIAL_SAVEDATA :
" Key fields for user data PLANTDATA and checkbox structure PLANTDATAX are different "
Can anyone please tell me, what are the fields am I missing ?
I am passing only PLANT as of now.
Thanks,
Chandan
‎2009 Jun 10 2:11 PM
have you also set an X in the appropiate field which you fill in plantdata for the plantdatax structure ??
kind regards
arthur
‎2009 Jun 10 2:10 PM
Hi
DB after the successful call of the FB 'BAPI_MATERIAL_SAVEDATA'.
Something like that:
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = BAPIMATHEAD
CLIENTDATA = BAPI_MARA
CLIENTDATAX = BAPI_MARAX
PLANTDATA = BAPI_MARc
PLANTDATAX = BAPI_MARcx
IMPORTING
RETURN = IT_RETURN2
TABLES
MATERIALDESCRIPTION = IT_MATERIALDESC
EXTENSIONIN = IT_BAPIPAREX
EXTENSIONINX = IT_BAPIPAREXX.
IF SY-SUBRC EQ 0.
UPDATE MARA SET ZZFORST = '0000704148'
WHERE MATNR = IT_MATERIAL_NUMBER-MATERIAL.
ENDIF.
BAPI_MATERIAL_SAVEDATA you have table prameters
EXTENSIONIN
EXTENSIONINX
read the documentation on these two parameters.
After your BAPI call ,call this BAPI BAPI_TRANSACTION_COMMIT
if not IT_RETURN2[] is intial.
loop at it_return2 where TYPE = 'S'.
call function 'BAPI_TRANSACTION_COMMIT'.
exit.
endloop.
endif.
Please check the below link.
go thru the sample also
http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
Regards
Pugal
‎2009 Jun 10 2:11 PM
have you also set an X in the appropiate field which you fill in plantdata for the plantdatax structure ??
kind regards
arthur
‎2009 Jun 10 2:14 PM
Yeah, what I did is like this
gwa_bapi_headata-material = 'KM657480G07'.
gwa_bapi_marc-plant = 'KOU'.
gwa_bapi_marcx-plant = 'X'.
gwa_bapi_mard-del_flag = 'X'.
gwa_bapi_mardx-del_flag = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gwa_bapi_headata
plantdata = gwa_bapi_marc
plantdatax = gwa_bapi_marcx
storagelocationdata = gwa_bapi_mard
storagelocationdatax = gwa_bapi_mardx
IMPORTING
return = gv_bapimsg.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = space
IMPORTING
return = gv_return1.
ENDIF.Now tell me , did I miss anything ? I only need to pass this many fields only.
If at all I am passing gwa_bapi_marcx-plant = 'KOU', then I am getting the following error.
Field WERKS has been transferred inconsistently or is blankPlease help
Thanks
Chandan
Edited by: chandan sinha on Jun 10, 2009 3:20 PM
‎2009 Jun 10 2:30 PM
for the keyfield the x structure has to be provided with the same value
gwa_bapi_marc-plant = 'KOU'.
gwa_bapi_marcx-plant = 'KOU'.
kind regards
arthur
‎2009 Jun 10 2:32 PM
If at all I am passing gwa_bapi_marcx-plant = 'KOU', then I am getting the following error.
Field WERKS has been transferred inconsistently or is blank
Please help
‎2009 Jun 10 2:33 PM
you also have to provide it with mard
gwa_bapi_mard = 'bla'
gwa_bapi_mardx = 'bla'
‎2009 Jun 10 2:34 PM
‎2009 Jun 10 2:47 PM
But the error is with the Plant data structure.
Moreover I am passing same values to MARD structure.
"Field WERKS has been transferred inconsistently or is blank"
‎2009 Jun 10 3:19 PM
‎2009 Jun 10 3:21 PM
gwa_bapi_headata-material = 'KM657480G07'.
gwa_bapi_marc-plant = 'KOU'.
gwa_bapi_marcx-plant = 'KOU'.
gwa_bapi_mard-del_flag = 'X'.
gwa_bapi_mardx-del_flag = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gwa_bapi_headata
plantdata = gwa_bapi_marc
plantdatax = gwa_bapi_marcx
storagelocationdata = gwa_bapi_mard
storagelocationdatax = gwa_bapi_mardx
IMPORTING
return = gv_bapimsg.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = space
IMPORTING
return = gv_return1.
ENDIF.
This is what I have done till now.......
‎2009 Jun 10 3:25 PM
ps what is it you want to do with the data ?? you pass a marc plant but for the rest you do nothing with any data of the plant.
you have also not completed the mard structure with the werks and storagelocation but you pass a delete field to it which is not correct if you don't fill the werks and storagelocation in both structures
kind regards
arthur
‎2009 Jun 11 6:30 AM
Thanks a lot,
Now I am passing Plant to MARD Structure, but then still it is giving error for Storage Location, which I don't need to pass.
what should I do now ?
Latest Error: Field LGORT has been transferred inconsistently or is blank
Moreover: Can't I update an already existing entry in the table ? Like I want to update only one field of the complete entry in MARD, is it possible?
I am asking because BAPI is throwing error : Material already exist or extended
Please help
Edited by: chandan sinha on Jun 11, 2009 7:49 AM
‎2009 Jun 11 7:57 AM
what do you mean I don't have to pass ? you NEED to pass it if you have storagelocation data !!
can you please explain how you can have storagelocation data from a material without storage ?
you want to delete records from mard so they have a storage location otherwise there would ne no records at all
if you have multiple storage locations then you have to delete every record individually with this bapi
kind regards
arthur
Edited by: A. de Smidt on Jun 11, 2009 8:58 AM
‎2009 Jun 11 8:01 AM
Agreed Arthur, I am passing storage location to that structure.
Now after doing that, I am facing this problem
Can't I update an already existing entry in the table ? Like I want to update only one field of the complete entry in MARD, is it possible?
I am asking because BAPI is throwing error : Material already exist or extended
Please help
‎2009 Jun 11 10:24 AM
can you perhaps post the new code again so I can verify what you try to do ??
and if you want to change things in the storage view you also have to set the view on in the headdata
gwa_bapi_headata-storage_view = 'X'
and for the sales view
gwa_bapi_headata-sales_view = 'X'
and ofcourse not to forget the basic view
gwa_bapi_headata-basic_view ='X'
I'm not sure if this was necessary but I have it in my programm set this way.
kind regards
arthur
Edited by: A. de Smidt on Jun 11, 2009 11:25 AM
Edited by: A. de Smidt on Jun 11, 2009 11:29 AM
Edited by: A. de Smidt on Jun 11, 2009 11:30 AM
‎2009 Jun 11 10:52 AM
Sure
Please find the latest code below
DATA: gwa_bapi_headata LIKE bapimathead,
gwa_bapi_mard LIKE bapi_mard,
gwa_bapi_mardx LIKE bapi_mardx,
gwa_bapi_marc LIKE bapi_marc,
gwa_bapi_marcx LIKE bapi_marcx.
DATA: gv_bapimsg LIKE bapiret2,
gv_return1 LIKE bapiret2.
gwa_bapi_headata-material = 'KM276449'.
gwa_bapi_headata-basic_view = 'X'.
gwa_bapi_headata-storage_view = 'X'.
gwa_bapi_headata-mrp_view = 'X'.
gwa_bapi_marc-plant = 'KNES'.
gwa_bapi_marcx-plant = 'KNES'.
gwa_bapi_mard-plant = 'KNES'.
gwa_bapi_mardx-plant = 'KNES'.
gwa_bapi_mard-stge_loc = 'SG00'.
gwa_bapi_mardx-stge_loc = 'SG00'.
gwa_bapi_mard-del_flag = 'X'.
gwa_bapi_mardx-del_flag = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gwa_bapi_headata
plantdata = gwa_bapi_marc
plantdatax = gwa_bapi_marcx
storagelocationdata = gwa_bapi_mard
storagelocationdatax = gwa_bapi_mardx
IMPORTING
return = gv_bapimsg.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = space
IMPORTING
return = gv_return1.
ENDIF.Still I am getting the same Old error i.e. Material already created or extended
Kindly Help
‎2009 Jun 11 11:07 AM
is it a error or an message ? not everything in the returntable is an error
it can also give the confirmation message that the article is extended
thhe best way to know is to do a bapi transaction commit and see if the mard record gets the delete
status
and why have you set the mrp view ?
kind regards
arthur
Edited by: A. de Smidt on Jun 11, 2009 12:07 PM
‎2009 Jun 11 11:13 AM
‎2009 Jun 11 9:08 AM
Hi Chandan,
LOOP AT it_tab INTO wa_tab.
wa_head-material = wa_tab-matnr.
wa_head-ind_sector = wa_tab-mbrsh.
wa_head-matl_type = wa_tab-mtart.
wa_head-basic_view = wa_tab-basic_view.
wa_head-sales_view = wa_tab-sales_view.
wa_head-purchase_view = wa_tab-purchase_view.
wa_head-mrp_view = wa_tab-mrp_view.
wa_head-work_sched_view = wa_tab-work_sched_view.
wa_head-warehouse_view = wa_tab-warehouse_view.
wa_head-quality_view = wa_tab-quality_view.
wa_head-account_view = wa_tab-account_view.
wa_head-cost_view = wa_tab-cost_view.
wa_marc-loadinggrp = wa_tab-ladgr.
wa_marc-pur_group = wa_tab-ekgrp.
wa_marc-gr_pr_time = wa_tab-webaz.
wa_marc-mrp_type = wa_tab-dismm.
wa_marc-reorder_pt = wa_tab-minbe.
wa_marc-mrp_ctrler = wa_tab-dispo.
wa_marc-lotsizekey = wa_tab-disls.
wa_marc-proc_type = wa_tab-beskz.
wa_marc-spproctype = wa_tab-sobsl.
wa_marc-sm_key = wa_tab-fhori.
wa_marc-plnd_delry = wa_tab-plifz.
wa_marc-qm_authgrp = wa_tab-qmata.
wa_marc-profit_ctr = wa_tab-prctr.
wa_marc-prodprof = wa_tab-sfcpf.
wa_marc-serno_prof = wa_tab-sernp.
wa_marc-iss_st_loc = wa_tab-lgpro.
wa_marc-plant = wa_tab-werks.
wa_marcx-loadinggrp = 'X'.
wa_marcx-pur_group = 'X'.
wa_marcx-gr_pr_time = 'X'.
wa_marcx-mrp_type = 'X'.
wa_marcx-reorder_pt = 'X'.
wa_marcx-mrp_ctrler = 'X'.
wa_marcx-lotsizekey = 'X'.
wa_marcx-proc_type = 'X'.
wa_marcx-spproctype = 'X'.
wa_marcx-sm_key = 'X'.
wa_marcx-plnd_delry = 'X'.
wa_marcx-qm_authgrp = 'X'.
wa_marcx-profit_ctr = 'X'.
wa_marcx-prodprof = 'X'.
wa_marcx-serno_prof = 'X'.
wa_marcx-iss_st_loc = 'X'.
wa_marcx-plant = wa_tab-werks.
wa_mard-stge_loc = wa_tab-lgort.
wa_mardx-stge_loc = wa_tab-lgort.
wa_mlgn-whse_no = wa_tab-lgnum.
wa_mlgnx-whse_no = wa_tab-lgnum.
wa_mara-base_uom = wa_tab-meins.
wa_mara-base_uom_iso = wa_tab-meins.
wa_mara-base_uom_iso = 'EA'.
wa_marax-base_uom_iso = 'X'.
wa_mara-matl_group = wa_tab-matkl.
wa_marax-matl_group = 'X'.
wa_mara-extmatlgrp = wa_tab-extwg.
wa_mara-catprofile = wa_tab-rbnrm.
wa_mbew-val_area = wa_tab-werks.
wa_mbew-val_class = wa_tab-bklas.
wa_mbew-price_ctrl = wa_tab-vprsv.
wa_mbew-price_unit = wa_tab-peinh.
wa_mbew-moving_pr = wa_tab-verpr.
wa_mbewx-val_area = wa_tab-werks.
wa_mbewx-val_class = 'X'.
wa_mbewx-price_ctrl = 'X'.
wa_mbewx-price_unit = 'X'.
wa_mbewx-moving_pr = 'X'.
wa_makt-langu = sy-langu.
wa_makt-matl_desc = wa_tab-maktx.
APPEND wa_makt TO it_makt.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = wa_head
clientdata = wa_mara
clientdatax = wa_marax
plantdata = wa_marc
plantdatax = wa_marcx
storagelocationdata = wa_mard
storagelocationdatax = wa_mardx
valuationdata = wa_mbew
valuationdatax = wa_mbewx
warehousenumberdata = wa_mlgn
warehousenumberdatax = wa_mlgnx
SALESDATA =
IMPORTING
return = wa_return
TABLES
materialdescription = it_makt.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
APPEND wa_return TO it_return.
CLEAR:wa_return.
CLEAR: wa_head,wa_marc,wa_mard,wa_mlgn,wa_mara,wa_makt,wa_mbew.
REFRESH: it_makt.
Edited by: Rasheed salman on Jun 11, 2009 10:08 AM