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

How can I put a commit work when I delete a Z table?

Former Member
0 Likes
5,261

Hi people!

I have a program that erase a Z table, but I have a problem with the rollback memory. A consultant tell me that if I execute a commit work after some records the memory of the rollback is cleared.

How can execute in my program the commit work after some files and when finish?

This is my simple code:


*Tabla a utilizar.
TABLES zavg_bal_table.

*Este select elimina todos los records encontrados en la tabla: ZAVG_BAL_TABLE.
DELETE  FROM zavg_bal_table.

Thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,540

Yes Rob,

It's my question.

Hi people!

I have a program that erase a Z table, but I have a problem with the rollback memory. A consultant tell me that if I execute a commit work after some records the memory of the rollback is cleared.

How can execute in my program the commit work after some files and when finish?

This is my simple code:


*Tabla a utilizar.
TABLES zavg_bal_table.

*Este select elimina todos los records encontrados en la tabla: ZAVG_BAL_TABLE.
DELETE  FROM zavg_bal_table.

Thanks!

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,540

If you would like to clear the entire table. You can do this.

delete from sflight CLIENT SPECIFIED where mandt = sy-mandt.
commit work.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,540

I'm not really sure what the question is, but if you try to deelte all the records from a very large table at once, the roll area may be exceeded causing a dump. Are you asking about this?

Rob

Read only

Former Member
0 Likes
2,541

Yes Rob,

It's my question.

Read only

0 Likes
2,540

OK - you have to find a way to delete data in chunks and do a commit after each chunk. One way to do this would be to select a group of records using the UP

TO n ROWS option of the SELECT statement and then for each group of records, delete the records and do a commit.

Rob

Read only

2,540

Something like:


REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 255
  MESSAGE-ID 00.

* Tabla a utilizar.
TABLES zavg_bal_table.

DATA: BEGIN OF itab OCCURS 0.
        INCLUDE STRUCTURE zavg_bal_table.
DATA: END   OF itab.

* Este select elimina todos los records encontrados en la tabla:
* ZAVG_BAL_TABLE.

WHILE sy-subrc = 0.

  SELECT * FROM  zavg_bal_table
    INTO TABLE itab UP TO 10000 ROWS.

  DELETE  zavg_bal_table FROM TABLE itab.
  COMMIT WORK.

ENDWHILE.

Rob

Read only

0 Likes
2,540

Fully agree with Rob,

We usually make a parameter for the number of rows in a package so it can be adjusted on a produciton without the need for transport.

I would do it a bit differently though:

WHILE num_rec >0.

SELECT * FROM zavg_bal_table

INTO TABLE itab UP TO p_rows ROWS.

endselect.

describe table itab lines num_rec.

check num_rec > 0.

DELETE zavg_bal_table FROM TABLE itab.

COMMIT WORK.

ENDWHILE.

Good luck !