Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
horst_keller
Product and Topic Expert
Product and Topic Expert

In a recent discussion I've seen someone was testing whether a loop was executed by placing a WRITE statement inside. Maybe it was a beginner's error but maybe others tend to do that too. Since the discussion is locked, I say it here:

WRITE is not appropriate for error analysis.


WRITE writes to he list buffer (or to the SAP spool system). A display of the list buffer in form of a classic list only takes place after calling the list. An automatic call of a classic list happens only in the program flow of a submitted executable program. As a rule, in any other framework there is no automatic list display. Therefore, the fact that you don't see any list output normally does not allow you to conclude that the WRITE statement was not executed.

  • For finding bugs during development, you use checkpoints (breakpoints, assertions, logpoints).

  • For testing during and after development you use module tests of ABAP Unit.

For the most of you this is crystal clear, but sometimes I get the impression that the knowledge about the fundamentals of classic ABAP programming - that unfortunately can freely be mixed into all the modern stuff - is taking a backseat more and more. Reminds me of the old days when I started with ABAP and also believed that WRITE is simply a kind of printf for creating a console output.

PS: As some of the below comments pointed out (thx), a more general rule would be:

Use WRITE only if you know what you are doing.

And that involves some knowledge about classic lists, because no, WRITE is not a printf.

But please be aware, that productive usage of WRITE is not recommended since long.  The point of this blog is that even non-productive usage of WRITE can be unfavorable and that you should be aware of that.

23 Comments