09-21-2016 1:34 PM
I created two database tables table 1 & table 2. When new entry is saved in table 2 ,then corresponding fields in table 1 entry should get delete automatically .i tried so many syntax to delete but not deleting. How to do it?
09-21-2016 1:56 PM
See this sample code (First delete and then Insert)
DATA: itab TYPE TABLE OF ztable,
wa TYPE ztable,
DELETE FROM ztable WHERE qmnum = '001000012345'.
wa-qmnum = '001000012345'.
wa-field1 = 'ABCDEFGH'.
wa-field2 = 'Klmnopr stuvwxyz'.
....
....
APPEND wa TO itab.
INSERT INTO ztable VALUES wa.
Alternatively you can use UPDATE command also.
09-21-2016 1:49 PM
Hello
if you Drop an Table on the Database everthing is gone.
may have a lock at the Table CDPOS ( Change Historty)
regards
Christian
09-21-2016 1:53 PM
09-21-2016 1:52 PM
While saving in Table2.
you can check the key column field in Table1 if it exists you can delete it by using coding
May i know what is the problem.
09-22-2016 1:44 AM
table 1 has 3 fields,table 2 has those 5 fields including those 3 fields.I tried so many different type of syntax to delete but not getting required output?
09-21-2016 1:56 PM
See this sample code (First delete and then Insert)
DATA: itab TYPE TABLE OF ztable,
wa TYPE ztable,
DELETE FROM ztable WHERE qmnum = '001000012345'.
wa-qmnum = '001000012345'.
wa-field1 = 'ABCDEFGH'.
wa-field2 = 'Klmnopr stuvwxyz'.
....
....
APPEND wa TO itab.
INSERT INTO ztable VALUES wa.
Alternatively you can use UPDATE command also.
09-21-2016 2:09 PM
Hi Raghava,
but what are you trying to achieve?
Deleting the whole record from Table1 or clear/change single fields for the corresponding record in Table1?
And I suggest you to change the title of your post: it seems that you need a way to retrieve deleted records.
09-21-2016 2:25 PM
I think he is talking about behavior something like a trigger or stored procedure directly on the database. I don't know about triggers in the SAP world, but stored procedures there seems to be help out there... Database Procedure Proxies for SQLScript and also ABAP Managed Database Procedures . You could also look at Core Data Services.
I personally have never used any of these, just being aware of how a database LUW works in SAP has been sufficient for me.
09-21-2016 4:42 PM
09-21-2016 4:51 PM
Kaushik Debnath what you are recommending in the image that you posted is a way to bypass system security. I don't think that is what was being asked for and not something that should be promoted. If you need to change data, go through the proper channels set up by your organization.
09-21-2016 5:05 PM
09-21-2016 5:37 PM
Here is the code .
Lets say ..
data : lt _table_1 type table od mara,
lw _table_1 type mara,
lt_table_2 type table of marc ,
lw _table_2 type marc.
lw _table 2 -field1 = 'text1'.
lw _table 2 -field2 = 'text2'.
modify lt_table 2 from lw _table 2 .
if sy-subrc eq 0 .
commit work .
select single * from mara into lw _table_1 where field1 = lw _table 2-field1 .
if sy-subrc eq 0 .
delete mara FROM WA lw _table_1 .
if sy-subrc eq 0 .
commit work .
endif .
endif .
Hope it should work .
09-22-2016 1:47 AM