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 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 |