Skip to Content
Technical Articles
Author's profile photo Taha Farosh

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>.


REPORT <zprogram>.


REPORT <zprogram>.
DATA(lv_var) = 1 / 0.


Let me know in the comments if there are better answers!

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Andrea Borgia
      Andrea Borgia

      Why? I mean, really why? ๐Ÿ˜€

      Ok, for the LULZ is always a good answer ๐Ÿ˜‰

      Author's profile photo Taha Farosh
      Taha Farosh
      Blog Post Author

      indeed for the lulz! ๐Ÿ˜€๐Ÿ˜€

      Author's profile photo Dominik Tylczynski
      Dominik Tylczynski
      ASSERT 1 = 0.
      Author's profile photo Taha Farosh
      Taha Farosh
      Blog Post Author

      Oh yea! That's a good one.

      Author's profile photo Jรถrgen Lindqvist
      Jรถrgen Lindqvist

      Yes, but let's make it hard to read as well... ๐Ÿ˜Š

      ASSERT '1I1llII1!1IlIII11l!111lIl' = '1I1llII1!1IllII11l!111lIl'.
      Author's profile photo Thales Batista
      Thales Batista

      Another to test bad eyesight / missed types lesson:

      assert ' ' = ` `.
      Author's profile photo Michelle Crapo
      Michelle Crapo

      Great!ย  I'm Laughing now.ย  I needed this.ย  I can't even imagine why anyone would want to do this.

      Author's profile photo Taha Farosh
      Taha Farosh
      Blog Post Author


      Author's profile photo Sercan Kucukdemirci
      Sercan Kucukdemirci

      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( ).
      Author's profile photo Mithun Kumar
      Mithun Kumar

      Ha Ha Ha... This sure looks like extra fun! ๐Ÿ˜€

      Author's profile photo Taha Farosh
      Taha Farosh
      Blog Post Author

      It sure is!

      Author's profile photo Marc Bernard
      Marc Bernard

      It will dump with no code at all:

      REPORT ztest.

      Activate ZTEST

      REPORT ztest2.

      Run ZTEST2

      Run ZTEST

      Author's profile photo Matthew Billingham
      Matthew Billingham

      What a daft challenge. I like it. ๐Ÿ˜


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

      Author's profile photo Taha Farosh
      Taha Farosh
      Blog Post Author

      Very nice!

      Author's profile photo Martin English
      Martin English

      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.

      Author's profile photo Enno Wulff
      Enno Wulff

      For some impressions have a look at the 16 years old contest in the German