How to process SELECT data in packages with COMMIT using CURSOR in ABAP?

You may find yourself needing to process huge amount of database records, for example INSERT, UPDATE or DELETE millions of rows.

You cannot perform all of those in one transaction as that may result in exceeding the size of the rollback area. Solution is to process the data in packages and COMMIT changes to the database after every package. This can be achieved in ABAP using CURSOR. Without it it is not possible to COMMIT changes, as that results in a DUMP.


Below I present an example.