‎2007 Jun 15 12:58 PM
Hi all,
1) Can we change(Edit, Delete) data from MARA & MAKT table? If yes then what is the procedure to do so? And if not why?
2) Can we protect the material created by a particular user(eg. PP) in MARA table?
If yes how to do it.
Thanx in advance..........
‎2007 Jun 21 1:05 PM
Hi Mohd
You should never update directly in SAP standard tables.
You ask <b>And if not why?</b>
I guess at least hundreds of tables in your SAP database contains material numbers.
I will give you an example.
If you have a sales order the material number will be stored in table VBAP.
Now if you delete the material number from MARA, there is a database inconsistency - the VBAP record links to a not existing MARA record.
This will probably result in a dump if the users try to change the sales order in transaction VA02.
best regards
Thomas Madsen Nielsen
‎2007 Jun 15 1:13 PM
Hi,
1. If MARA is really the table you want to delete records from, maybe better to use BAPI_MATERIAL_DELETE to flag it for deletion. And if you do that, then you only need to store the material numbers. Saves memory.
TABLES: mara.
DATA: wa_mara LIKE mara.
Copy of the internal table, which is (I assume) the same as MARA.
TYPES: t_itab_keep LIKE mara,
t_itab_delete LIKE mara.
DATA: itab_keep TYPE TABLE OF t_itab_keep WITH HEADER LINE.
DATA: itab_delete TYPE TABLE OF t_itab_delete WITH HEADER LINE.
DATA: h_lines TYPE i.
SELECT * FROM mara UP TO 10 ROWS.
TEST FILL itab_keep.
DESCRIBE TABLE itab_keep LINES h_lines.
IF h_lines < 9.
MOVE mara TO itab_keep.
APPEND itab_keep.
CLEAR itab_keep.
ENDIF.
END OF TEST FILL itab_keep
READ TABLE itab_keep WITH KEY matnr = mara-matnr.
IF sy-subrc <> 0. "Not in ITAB, must be deleted from MARA
APPEND mara TO itab_delete.
ENDIF.
ENDSELECT.
LOOP AT itab_delete.
WRITE:/ itab_delete.
ENDLOOP.
Be very careful (should lock too), and allow restore!
DELETE mara FROM TABLE itab.
2.By giving Autorization u can protect your code.
anyway material creation is responsibilty of functional guys so u can better to consult functional people.
<b>Reward points</b>
Regards
‎2007 Jun 15 1:41 PM
1) It is NOT best practice to write code to directly update standard SAP system tables. You should use:
Batch Input on MM02 or
BAPI_MATERIAL_EDIT or
RMDATIND
2) Assign such materials to their own Authorisation Group (MARA-BEGRU), then set users up to have/not have access to the via their authorisation profiles
‎2007 Jun 21 1:05 PM
Hi Mohd
You should never update directly in SAP standard tables.
You ask <b>And if not why?</b>
I guess at least hundreds of tables in your SAP database contains material numbers.
I will give you an example.
If you have a sales order the material number will be stored in table VBAP.
Now if you delete the material number from MARA, there is a database inconsistency - the VBAP record links to a not existing MARA record.
This will probably result in a dump if the users try to change the sales order in transaction VA02.
best regards
Thomas Madsen Nielsen