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: 
former_member736527
Active Participant
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!
16 Comments
abo
Active Contributor
Why? I mean, really why? 😄

Ok, for the LULZ is always a good answer 😉
DominikTylczyn
Active Contributor
ASSERT 1 = 0.
former_member736527
Active Participant
indeed for the lulz! 😀😀
former_member736527
Active Participant
Oh yea! That's a good one.
mmcisme1
Active Contributor
Great!  I'm Laughing now.  I needed this.  I can't even imagine why anyone would want to do this.
joltdx
Active Contributor
Yes, but let's make it hard to read as well... 😊
ASSERT '1I1llII1!1IlIII11l!111lIl' = '1I1llII1!1IllII11l!111lIl'.
former_member736527
Active Participant
0 Kudos
😀😀
thalesvb
Active Contributor
Another to test bad eyesight / missed types lesson:
assert ' ' = ` `.
sercankdm
Explorer

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)

    SELECT COUNT(*) FROM seoclass WHERE clsname LIKE 'CX_%'.
DATA(iOffset) = cl_abap_random_int=>create( seed = cl_abap_random=>seed( ) min = 1 max = sy-dbcnt - 1 )->get_next( ).
SELECT clsname FROM seoclass WHERE clsname LIKE 'CX_%' ORDER BY clsname INTO TABLE @DATA(exceptab) UP TO 1 ROWS OFFSET @iOffset.
DATA(clsname) = exceptab[ 1 ]-clsname.
CREATE OBJECT exception TYPE (clsname).

 

now fun part

REPORT <zprogram>.
RAISE SHORTDUMP zcl_random_shortdump=>get( ).
Mithun_Kumar
Active Participant
Ha Ha Ha... This sure looks like extra fun! 😄
former_member736527
Active Participant
0 Kudos
It sure is!
marcfbe
Participant
It will dump with no code at all:
REPORT ztest.

Activate ZTEST
REPORT ztest2.
DATA c TYPE TABLE OF c.
INSERT REPORT 'ZTEST' FROM c.

Run ZTEST2


Run ZTEST
matt
Active Contributor

What a daft challenge. I like it. 😁

REPORT.
CALL METHOD ('NO_SUCH_CLASS')=>('NO_SUCH_METHOD').

Note - no need to have anything after REPORT. Of course you can use PROGRAM instead.

former_member736527
Active Participant
0 Kudos
Very nice!
martin_E
Active Contributor
0 Kudos
I have come across several SAP notes that appear to recommend
MESSAGE 'Dump' TYPE 'X'.

for various “should not be possible” situations. The key point is that your user actually does get a message, rather than a short dump.
ennowulff
Active Contributor
For some impressions have a look at the 16 years old contest in the German Abapforum.com

😀

 
Labels in this area