Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Delete from Database Table

Former Member
0 Likes
789

Hi All,

I have a piece of code which is giving me some trouble.

SELECT * FROM s880
  INTO CORRESPONDING FIELDS OF TABLE it_s880
  WHERE vrsio EQ p_tvrsio OR
        vrsio EQ '000'.
DELETE s880 FROM TABLE it_s880.

Now, when i'm debugging, i find that even after the Delete has occured, the Data from the table hasn't been deleted. or atleast that i can still see it in SE16. I tried refreshing but no change.

But how ever the data at the end (after the program executes) seems to be OK.

Does this normally happen or am i doing something wrong.

Thanks in advance..!

Jr.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
742

Your syntax looks fine. put a break point on that delete statement and add another line of code after, like .... CHECK SY-SUBRC = 0. Now got to debug and stop at the DELETE statement, check the number of records in your DB table, now hit F5 to step to the next statement, now go back to SE16 and refresh, do you see the number change? It should.........if you are selecting the data correctly, make sure that you are getting data into the IT_S880 table.

Regards

RIch Heilman

5 REPLIES 5
Read only

Former Member
0 Likes
742

Hi,

Try putting a COMMIT WORK after the delete statement.

Hope it helps.

Regards,

Gilberto Li

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
743

Your syntax looks fine. put a break point on that delete statement and add another line of code after, like .... CHECK SY-SUBRC = 0. Now got to debug and stop at the DELETE statement, check the number of records in your DB table, now hit F5 to step to the next statement, now go back to SE16 and refresh, do you see the number change? It should.........if you are selecting the data correctly, make sure that you are getting data into the IT_S880 table.

Regards

RIch Heilman

Read only

0 Likes
742

If you are interupting the processing of this program, but exiting the program in debug after the delete statement, then yes, your changes will be rollbacked, but if you all the program to finish completely then the commit will happen automatically, or course you can COMMIT WORK explicitly after the DELETE statement.

Regards,

Rich Heilman

Read only

ferry_lianto
Active Contributor
0 Likes
742

Hi,

Please add this FM 'DB_COMMIT' at the end.

SELECT * FROM s880  
INTO CORRESPONDING FIELDS OF TABLE it_s880  
WHERE vrsio EQ p_tvrsio OR        
      vrsio EQ '000'.

DELETE s880 FROM TABLE it_s880

CALL FUNCTION 'DB_COMMIT'.

You can also use LIS Copy Management tool (t/code <b>MCSZ</b>) to maintain your custom info structure. It is easy and very handy.

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.

Read only

Former Member
0 Likes
742

It's working as expected. There is a commit when the program ends, so the records are really there until then.

Rob