Skip to Content

Today, no business topic but it’s play time 🙂 A couple of days ago, I stumbled upon the free book “10 PRINT CHR$(205.5+RND(1)); : GOTO 10“. No joke, that’s the title of the book. It’s about an one-line Commodore 64 BASIC program that prints a maze to the screen. Because I’m a big fan of Retrocomputing, I browsed the book a little bit.

Afterwards I asked myself what ABAP report I could write in one line of 40 characters with a nice output. The answer was sobering: Nothing interesting. Even with 80 characters I just printed vertical lines to the screen 🙂 Here is my approach.


Finally I decided to give up the length restriction and wrote my own random maze generator as a homage to the original BASIC program. It uses the WRITE instruction and the characters “-” and “|” to build frames. You will find it on GitHub, too.

REPORT z_random_maze.

DATA: lr_random_int TYPE REF TO cl_abap_random_int,
      lv_random_int TYPE i,
      lv_position_x TYPE i,
      lv_position_y TYPE i,
      lv_maze_part  TYPE char2.

lr_random_int = cl_abap_random_int=>create( seed = CONV i( sy-uzeit ) min = 1 max = 9 ).

  lv_position_y = sy-index.
  lv_position_x = 1.
  DO 30 TIMES.
    CLEAR lv_maze_part.
    IF lv_position_y = 20.
      lv_maze_part = '--'.
      lv_random_int = lr_random_int->get_next( ).
      IF lv_random_int < 5.
        lv_maze_part = '|'.
      ELSEIF lv_random_int > 7.
        lv_maze_part = '--'.
    WRITE AT lv_position_x(2) lv_maze_part.
    lv_position_x = lv_position_x + 2.

Relax your eyes, try to find your way through the maze and have fun 🙂 Here is a little example of the report output. And if you have a good idea for an interesting one-liner in ABAP, let me know.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Uwe Fetzer

    Challenge accepted

    REPORT z.DATA(r) = cl_abap_random_int=>create( min = 1 max = 3 ).DO 10 TIMES.DO 80 TIMES.WRITE SWITCH #( r->get_next( ) WHEN 1 THEN '-' WHEN 2 THEN '|' ELSE ` ` ) NO-GAP.ENDDO.NEW-LINE.ENDDO.ULINE (80).
    1. Michael Keller Post author

      I’m very interested in. Next week I have more free time to look at abapGit. There is a lot of unreleased stuff lying here around. A good chance to start with abapGit :-))

    1. Michael Keller Post author

      I support your request. Between all the business stuff we should have the chance to relax a minute without log out from our favorite erp 🙂 By the way: Enno has a nice collection of ABAP games under “”.


Leave a Reply