In all previous and current R/3 releases, ABAP/4 commands ROLLBACK WORK and WRITE cannot be used together.
Sample SysLog messages:
Database error: TemSe->XRTAB(RT_UPDATE)->64(NotFound)
with table TST01, key (...)SPOOL..... ,1
F20 No handle for an open TemSe object (magic==X'4f444f23')
SPOOL_TEMSE_ERROR
Reason and PrerequisitesWRITE writes to the spool. The spooler saves its contents in the database. A ROLLBACK deletes everything from the database written since the last COMMIT. The task of a neat database system is not to leave any traces at all. As a result, the spooler data is also erased.
- 1. Can you use ROLLBACK WORK and WRITE together?
No.
While it micht be helpful for everything written before the last COMMIT to be retained and everything written thereafter deleted, this is not compatible with the other characteristics of ABAP/4: negative line counters are allowed with the SKIP command, and you can also move backwards with POSITION.
This has two imporant consequences:
1.1 A subsequent WRITE can overwrite something written by a previous WRITE. Example:
WRITE / 'Test with overwriting'.
WRITE /20 '******old******'.
COMMIT WORK.
WRITE 21 '--no, new--' .
ROLLBACK WORK.
WRITE 23 ' NO OLD ' .
1.2 The ABAP/4 list processor is forced store at least one page temporarily. This temporary storage is not subject to the database transactions. As a result, the data would not be written to the spooler at least until the end of page was reached.
This could have various consequences:
1.2.1 Half a page has been written since the program started. A ROLLBACK WORK would have no effect on list output. The page buffer of the list processor is not affected, and the spool request has not even been started.
1.2.2 More than one page has been written since the program started. A ROLLBACK WORK would have serious consequences. Not only is the spooled data lost, but also the knowledge that a spool request has been started in the first place. Typical error messages:
Database error: TemSe->XRTAB(RT_UPDATE)-> 64(NotFound)
in table TST01 key SPOOL..... ,1
No handle for an open TemSe object (magic==X'4f444f23')
Note: Since Kernel Release 4.6D, a dump has not occurred in this situation. The system rolls back all closed pages in the spool; the spool request only contains the lines written after the ROLLBACK WORK.
1.2.3 More than one page has been written since the program started, and a COMMIT has been sent. A ROLLBACK WORK at this time would either delete nothing, or delete one or more pages from the list.
Therefore, do not try to mix WRITE and ROLLBACK WORK in the hope that you can predict what will happen.
1. How should such programs be written?
2.1 Database accesses with CAUTION
Your safest strategy is only to make changes in the database once you are sure that this is what you want. You will then find that you never need the ROLLBACK command.
2.2 Delay writing to the database
Everything that is to be written to the database is collected, and is not written until you are sure you want to.
2.3 Complete termination
When serious problems occur, a program is always terminated with a ROLLBACK. It does not attempt, however, to continue to work with the previous data. The problem message will not appear in the list, either, but instead as a termination message (and SysLog entry).
2.4 Delayed list writing
Everything a program needs to write is first written to an internal table with APPEND, and then copied to the list (with editing) at the end of the program.
2.5 Write lists in sure sections
The spool request is started, written, and completed within a single database transaction. By using the automatic APPEND mechanism of the spooler, you can perform this operation repeatedly, and still group everything together in a single, long list.
...
NEW-PAGE PRINT ON.
WRITE...
WRITE...
NEW-PAGE PRINT OFF.
COMMIT WORK.
...
2.6 Write lists to a safe location
Paradoxically, a location is "safe" when it is neither subject to the database transaction concept, nor does it interact with it.
2.6.1 The TemSe.
You can use the function modules
RSTS_OPEN_WL ( EXPORTING NO_ROLLBACK = 'X' )
RSTS_WRITE
RSTS_CLOSE
to write to the TemSe. A function to print such a TemSe object directly has not yet been implemented. Therefore, the list must later be copied to the spool.
2.6.2 Files
However, the way in which the functions
OPEN DATASET
TRANSFER
CLOSE DATASET
react to ROLLBACK WORK is not yet officially guaranteed.
3. Procedure
3.1 Should the problem occur in a program shipped by SAP, register the problem, quoting this note, the name of the program, and the way it is used.
3.2 If the problem occurs in your own programs, you will have to change them accordingly.CC
Key word: ROLLBACK WRITE
No comments:
Post a Comment