Technical Articles
Next line should throw a dump
Recently, I came across an interesting question. I am not sure if it has been posted here before, or how common knowledge it is, but needless to say, I found it very amusing and was, frankly, stumped by it.
The question is a purely hypothetical one, without any practical significance, so, just take it as a fun exercise.
The question goes like this:
Say, you are writing an ABAP report. The first line is always fixed.
REPORT <zprogram>.
The next line of this report, whether declaration or executable line, should throw an ABAP runtime error (dump). You are not allowed to do some data declarations first and then cause it to dump. For example, consider below report:
REPORT <zporgram>
FIELD-SYMBOLS: <fs_temp> TYPE any.
<fs_temp> = 'X'.
While the above may throw an ABAP runtime error, the second line of the program has already been used up to define the field symbol. So, this solution is not acceptable.
After much thought I was finally able to come up with a couple of solutions!ย
Here are a few of them.
REPORT <zprogram>.
MESSAGE 'Dump' TYPE 'X'.
REPORT <zprogram>.
RAISE EXCEPTION.
REPORT <zprogram>.
DATA(lv_var) = 1 / 0.
Let me know in the comments if there are better answers!
Why? I mean, really why? ๐
Ok, for the LULZ is always a good answer ๐
indeed for the lulz! ๐๐
Oh yea! That's a good one.
Yes, but let's make it hard to read as well... ๐
Another to test bad eyesight / missed types lesson:
Great!ย I'm Laughing now.ย I needed this.ย I can't even imagine why anyone would want to do this.
๐๐
You may get bored with all those static shortdumps, how about random shortdump everytime you execute your program?
I cheated a little bit by moving entire code into a separate class
Now now, instructions
Create single class with single static method having returning parameter referenced to cx_root.
Use code below to fill your method, (i know its ugly)
ย
now fun part
Ha Ha Ha... This sure looks like extra fun! ๐
It sure is!
It will dump with no code at all:
Activate ZTEST
Run ZTEST2
Run ZTEST
What a daft challenge. I like it. ๐
Note - no need to have anything after REPORT. Of course you can use PROGRAM instead.
Very nice!
I have come across several SAP notes that appear to recommend
for various โshould not be possibleโ situations. The key point is that your user actually does get a message, rather than a short dump.
For some impressions have a look at the 16 years old contest in the German Abapforum.com
๐