‎2006 Dec 02 9:52 AM
hello gurus,
Below s the sample code where i am using for material master updation
i am updating client data & plant data
when i put alone client data it s getting updated
but whne i include plant data
it executes but material is not getting created
i dont know what i am missing
please correct me the below code
DATA: headdata TYPE bapimathead.
DATA: clientdata TYPE bapi_mara.
DATA: clientdatax TYPE bapi_marax.
DATA: plantdata TYPE bapi_marc.
DATA: plantdatax TYPE bapi_marcx.
DATA: descdata TYPE TABLE OF bapi_makt WITH HEADER LINE.
DATA: return TYPE TABLE OF bapiret2 WITH HEADER LINE.
DATA: returnm TYPE TABLE OF bapi_matreturn2 WITH HEADER LINE.
DATA: imat TYPE TABLE OF bapimatinr WITH HEADER LINE.
CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
EXPORTING
material_type = 'ZMED'
INDUSTRY_SECTOR = 'M'
TABLES
material_number = imat.
READ TABLE imat INDEX 1.
IF sy-subrc = 0.
headdata-material = imat-material.
ENDIF.
headdata-ind_sector = 'Z'.
headdata-matl_type = 'ZMED'.
headdata-basic_view = 'X'.
headdata-purchase_view = 'X'.
clientdata-base_uom = meins.
clientdatax-base_uom = 'X'.
clientdata-old_mat_no = bismt.
clientdatax-old_mat_no = 'X'.
clientdata-matl_group = matkl.
clientdatax-matl_group = 'X'.
clientdata-document = zeinr.
clientdatax-document = 'X'.
clientdata-size_dim = groes.
clientdatax-size_dim = 'X'.
clientdata-std_descr = normt.
clientdatax-std_descr = 'X'.
clientdata-basic_matl = wrkst.
clientdatax-basic_matl = 'X'.
clientdata-del_flag = lvorm.
clientdatax-del_flag = 'X'.
plantdata-plant = werks.
plantdatax-plant = 'X'.
plantdata-pur_group = ekgrp.
plantdatax-pur_group = 'X'.
plantdata-auto_p_ord = kautb.
plantdatax-auto_p_ord = 'X'.
descdata-langu = sy-langu.
descdata-matl_desc = maktx.
APPEND descdata.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = headdata
clientdata = clientdata
clientdatax = clientdatax
<b> plantdata = plantdata
plantdatax = plantdatax</b> ( when i include material is not updated)
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
IMPORTING
return = return
TABLES
materialdescription = descdata
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
returnmessages = returnm
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
.
CHECK sy-subrc = 0.
IF sy-subrc EQ 0.
return-number = 0.
return-type = 'S'.
return-id = 'Z1'.
return-message = 'Successfully updated'.
return-message_v1 = ''.
return-message_v2 = ''.
return-message_v3 = ''.
return-message_v4 = sy-mandt.
ELSE.
return-number = 0.
return-type = 'E'.
return-id = 'Z1'.
return-message = 'Not updated'.
return-message_v1 = ''.
return-message_v2 = ''.
return-message_v3 = ''.
return-message_v4 = sy-mandt.
ENDIF.
thanx n advance
senthil
‎2006 Dec 02 11:26 AM
Please try these options,
1) plantdatax = plantdatax ( when i include material is not updated) - Just comment this line and test your program
2) In the code sample I posted earlier
This is the logic,
Plant - Purchasing
BAPI_MARC1-PLANT = INT_MAT-WERKS.
BAPI_MARC1-PUR_GROUP = INT_MAT-EKGRP.
<b> BAPI_MARCX-PLANT = INT_MAT-WERKS.</b>
BAPI_MARCX-PUR_GROUP = 'X'.
In your code,
plantdata-plant = werks.
<b>plantdatax-plant = 'X'.</b>
plantdata-pur_group = ekgrp.
plantdatax-pur_group = 'X'.
3) Try to get what the message is returned in this,
<b>returnmessages = returnm</b>. That might give what the error is.
4) Make sure you do this after the BAPI call,
Commit or Rollback Transaction
IF return-type EQ 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
Just try to change as the logic above, worth a try.
Regards
Kathirvel
‎2006 Dec 02 10:05 AM
Check this link
http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
Regards
Kathirvel
‎2006 Dec 02 10:50 AM
thanx for u r reply
I have checked but still unable to locate
the problem
PLease help me out
It is very urgent
thanx in advance
senthil
‎2006 Dec 02 11:26 AM
Please try these options,
1) plantdatax = plantdatax ( when i include material is not updated) - Just comment this line and test your program
2) In the code sample I posted earlier
This is the logic,
Plant - Purchasing
BAPI_MARC1-PLANT = INT_MAT-WERKS.
BAPI_MARC1-PUR_GROUP = INT_MAT-EKGRP.
<b> BAPI_MARCX-PLANT = INT_MAT-WERKS.</b>
BAPI_MARCX-PUR_GROUP = 'X'.
In your code,
plantdata-plant = werks.
<b>plantdatax-plant = 'X'.</b>
plantdata-pur_group = ekgrp.
plantdatax-pur_group = 'X'.
3) Try to get what the message is returned in this,
<b>returnmessages = returnm</b>. That might give what the error is.
4) Make sure you do this after the BAPI call,
Commit or Rollback Transaction
IF return-type EQ 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
Just try to change as the logic above, worth a try.
Regards
Kathirvel
‎2006 Dec 02 11:36 AM
hi kathirvel
Thank you for u r replies
My problem has been solved
i have changed
plantdata-plant = werks.
plantdatax-plant = werks. ( from 'X' to werks )
THank you very much
it is working fine now
senthil