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.
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:
What a daft challenge. I like it. 😁
Note - no need to have anything after REPORT. Of course you can use PROGRAM instead.
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