2007 Oct 12 9:39 PM
Hi All,
I am using BAPI_MATERIAL_SAVEDATA to add some default values to sales data views. When i execute BAPI is throwing an error message "<b>Key fields for use data SALESDATA and checkbox structure SALESDATAX are different</b>". Here is my sales data view code.If i comment the Salesdata processing code, material is creating scuccessfull.
**************************************************************************************
FORM process_halb USING pv_wa_final LIKE wa_final
pv_wa_matno LIKE wa_matno
pv_v_error LIKE v_error
pv_v_sucess LIKE v_sucess
pv_wa_return LIKE wa_return.
bapimathead-material = pv_wa_matno-material. "Material Number
bapimathead-ind_sector = c_m. "industry sector
bapimathead-matl_type = pv_wa_final-mtart. "Material type
bapimathead-basic_view = c_x. "select Basic View
bapimathead-mrp_view = c_x. "Select MRP Views
bapimathead-storage_view = c_x. "Select Storage Views
bapimathead-account_view = c_x. "select Account views
bapimathead-work_sched_view = c_x. "Work Scheduling View
bapimathead-cost_view = c_x. "Costing View
bapimathead-sales_view = c_x.
Inserting Data for Sales view
IF pv_wa_final-werks EQ c_1010.
bapi_mvke-sales_org = c_1000. "Sales organisation
ENDIF. "IF pv_wa_final-werks EQ c_1010.
IF pv_wa_final-werks EQ c_1020.
bapi_mvke-sales_org = c_2000. "Sales Organisation
ENDIF. "IF pv_wa_final-werks EQ c_1020.
bapi_mvkex-sales_org = c_x.
bapi_mvke-distr_chan = c_00. "Distribution Channel
bapi_mvkex-distr_chan = c_x.
IF pv_wa_final-werks EQ c_1010.
bapi_mvke-delyg_plnt = c_1010. "Delivery Plant
ELSE.
bapi_mvke-delyg_plnt = c_1020. "Delivery Plant
ENDIF.
bapi_mvke-delyg_plnt = c_x.
bapi_mara-item_cat = c_0001. "General Item Category
bapi_marax-item_cat = c_x.
bapi_mvke-item_cat = c_0001. "Item Category Group
bapi_mvkex-item_cat = c_x.
IF pv_wa_final-werks EQ c_1010.
bapi_marc-availcheck = c_zw. "Availabity Check
ENDIF. "IF pv_wa_final-werks EQ c_1010.
IF pv_wa_final-werks EQ c_1020.
bapi_marc-availcheck = c_zg. "Availability Check
ENDIF. " IF pv_wa_final-werks EQ c_1020.
bapi_marcx-availcheck = c_x.
bapi_mara-trans_grp = c_0001. "Transportation Group
bapi_marax-trans_grp = c_x.
bapi_marc-loadinggrp = c_0001. "Loading Group
bapi_marcx-loadinggrp = c_x.
<b>bapi_mlan-taxclass_1 = c_1. </b> "Tax Classification
IF pv_wa_final-werks EQ c_1010.
bapi_marc-profit_ctr = c_wt. "Profit Center
ENDIF. "IF pv_wa_final-werks EQ c_1010.
IF pv_wa_final-werks EQ c_1020.
bapi_marc-profit_ctr = c_gt. "Profit Center
ENDIF. " IF pv_wa_final-werks EQ c_1020.
bapi_marcx-profit_ctr = c_x.
IF NOT pv_wa_final-lgnum IS INITIAL.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
clientdatax = bapi_marax
plantdata = bapi_marc
plantdatax = bapi_marcx
storagelocationdata = bapi_mard
storagelocationdatax = bapi_mardx
valuationdata = bapi_mbew
valuationdatax = bapi_mbewx
warehousenumberdata = bapi_mlgn
warehousenumberdatax = bapi_mlgnx
salesdata = bapi_mvke
salesdatax = bapi_mvkex
storagetypedata = bapi_mlgt
storagetypedatax = bapi_mlgtx
IMPORTING
return = pv_wa_return
TABLES
materialdescription = i_matdesc
unitsofmeasure = i_bapi_marm
unitsofmeasurex = i_bapi_marmx
materiallongtext = i_bapi_mltx
extensionin = i_bapiparex
extensioninx = i_bapiparexx.
IF pv_wa_return-type = c_e.
pv_v_error = pv_v_error + c_1.
Roll back an errored BAPI
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSEIF pv_wa_return-type = c_s.
pv_v_sucess = pv_v_sucess + c_1.
Commit a successfull BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF. "IF pv_wa_return-type = c_e
********************************************************************************
The statement in the Bold is assigning a constant to Tax classification field.I assigned 'X' for all checkbox structures except for the Tax classification as i have'nt find the checkbox structure.
Can any one suggest where the problem lies and possible solution.
Thanks in advance
Hiy Ben.. Only one small mistake
Inserting Data for Sales view
IF pv_wa_final-werks EQ c_1010.
bapi_mvke-sales_org = c_1000. "Sales organisation
bapi_mvkex-sales_org = c_1000. -
Added
ENDIF. "IF pv_wa_final-werks EQ c_1010.
IF pv_wa_final-werks EQ c_1020.
bapi_mvke-sales_org = c_2000. "Sales Organisation
bapi_mvkex-sales_org = c_2000. -
Added
ENDIF. "IF pv_wa_final-werks EQ c_1020.
//bapi_mvkex-sales_org = c_x. ... Even for checkbox structure you need to provide actual sales organization value for key fields..not "X".. ( Check out the structure of mvkex )
Hope this will help.
Nilesh
2007 Oct 13 12:55 AM
Hiy Ben.. Only one small mistake
Inserting Data for Sales view
IF pv_wa_final-werks EQ c_1010.
bapi_mvke-sales_org = c_1000. "Sales organisation
bapi_mvkex-sales_org = c_1000. -
Added
ENDIF. "IF pv_wa_final-werks EQ c_1010.
IF pv_wa_final-werks EQ c_1020.
bapi_mvke-sales_org = c_2000. "Sales Organisation
bapi_mvkex-sales_org = c_2000. -
Added
ENDIF. "IF pv_wa_final-werks EQ c_1020.
//bapi_mvkex-sales_org = c_x. ... Even for checkbox structure you need to provide actual sales organization value for key fields..not "X".. ( Check out the structure of mvkex )
Hope this will help.
Nilesh
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |