‎2009 Jun 02 3:20 PM
Hi Gurus,
I need to update the MARC table by changing the value of MMSTA field.
I need to do this in a program based on certain conditions.
Only I need to update MMSTA field of MARC, how can I do this ? Direct Update, I am not using any TCODE.
Thanks
Chandan
‎2009 Jun 03 7:08 AM
Check these link :
http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
Reg,
Siva
‎2009 Jun 02 3:24 PM
Hi,
First enqueue the table .
Then update using UPDATE statement with SET <fieldname> option.
Then dequeue the table.
Press F1 on update to get exact syntax for SET option.
Regards,
Mukul.
‎2009 Jun 02 3:27 PM
Thanks Mukul, but unfortunately I dont have much time, can you please give me the syntax and explain a bit on en queue and dequeue syntax ?
‎2009 Jun 02 3:30 PM
*Function module to lock table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = <table name>
IF sy-subrc EQ 0.
UPDATE <table name>
SET <your field name> = new value
WHERE <key field > = key field value.
*Functioj module to unlock
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
tabname = <table name>
.
Hope it helps
‎2009 Jun 02 3:34 PM
Thanks a lot Mukul, I guess this should update this standard table.
Let me see if its working or not, meanwhile you can also suggest different ways of updating a standard table.
‎2009 Jun 02 3:37 PM
As a rule of thumb....NEVER EVER update standard tables using 'UPDATE' statement. Sure, it will work, but most SAP standard tables are interrelated, and it could (and will) mess up the referential integrity of the database. SAP delivers several methods of updating standard tables like, BAPI's, FM, BDC, LSMW etc. Use them, and NOT direct update of database table.
A BAPI you can use: BAPI_MATERIAL_SAVEDATA.
‎2009 Jun 02 3:52 PM
What Micky say is absolutely the case.
You risk invalidating your clients support contract with SAP, by updating tables directly.
You risk your employer getting into severe contractual difficulties with the client.
Worse, you're doing something risk, "in a hurry". And, since your asking for ENQUEUE/DEQUEUE sytnax, it's clear you are not an experienced ABAPer, so even more so, you really really shouldn't be doing this. You've not got sufficient experience.
Do your employer and your client know?
‎2009 Jun 03 6:29 AM
Thanks Micky and Matt for that piece of information.
Well, guys can you help me out then in using BAPI_MATERIAL_SAVEDATA ?
I need to update MMSTA field of MARC , how can I do this ?
Thanks,
Chandan
‎2009 Jun 03 6:38 AM
Have you read the documentation on the BAPI? Have you search this site for examples of how to use it?
matt
‎2009 Jun 03 6:48 AM
Yes Matt, I have searched this site, but a perfect result is not available.
People have tried using this BAPI, but didnt get perfect results, that what I got to know while searching.
Can you please help me out ?
Thanks
Chandan
‎2009 Jun 03 6:55 AM
So you got something, right? Anyway something is better than nothing. so start coding with that examples and post the code part where you are struck.
Don't expect others to write code for you.
Regards
Karthik D
‎2009 Jun 03 7:01 AM
Hey Please don't talk like a teacher, LOL
Anyways, I need to update just one field i.e MMSTA, which is present in PLANTDATA.
So is it like PLANTDATA = wa_marc ???? Where wa_marc will contain MMSTA field only.
Also please tell me the mandatory fields needed to pass in this BAPI, to update MMSTA field correctly.
Thanks
Chandan
Edited by: chandan sinha on Jun 3, 2009 8:04 AM
‎2009 Jun 03 7:11 AM
Hi,
The mandatory input is the structure HEADDATA and in your case you also have to pass PLANTDATA and PLANTDATAX.
Give as;
wa_Plantdata-PUR_STATUS = wa_marc-mmsta.
wa_plantdatax-PUR_STATUS = 'X'.You may also need to supply all required fields of plantdata.
Regards
Karthik D
‎2009 Jun 03 7:14 AM
Exactly, Anyways I got it.
I need to pass other fields but those will be blank.
Thanks a lot for your quick response.
Let me do it and check.
Thanks
Chandan
‎2009 Jun 03 7:16 AM
Hello
DATA: XHEADDATA LIKE BAPIMATHEAD OCCURS 0 WITH HEADER LINE,
XPLANTDATA LIKE BAPI_MARC OCCURS 0 WITH HEADER LINE,
XPLANTDATAX LIKE BAPI_MARCX OCCURS 0 WITH HEADER LINE,
XRETURN LIKE BAPI_MATRETURN2 OCCURS 0 WITH HEADER LINE.
XPLANTDATA-PLANT = SET_WERKS_HERE.
XPLANTDATA-PUR_STATUS = SET_MMSTA_HERE.
APPEND XPLANTDATA.
XPLANTDATAX-PLANT = SET_WERKS_HERE.
XPLANTDATAX-PUR_STATUS = 'X'.
APPEND XPLANTDATAX.
REFRESH XHEADDATA.
XHEADDATA-MATERIAL = SET_MATNR_HERE.
XHEADDATA-MRP_VIEW = 'X'.
XHEADDATA-INP_FLD_CHECK = 'W'.
APPEND XHEADDATA.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = XHEADDATA
PLANTDATA = XPLANTDATA
PLANTDATAX = XPLANTDATAX
TABLES
RETURNMESSAGES = XRETURN.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.
‎2009 Jun 03 7:08 AM
Check these link :
http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
Reg,
Siva