Skip to Content
Author's profile photo Horst Keller

Three ABAP Games

Look what I’ve found.

Under the cloak of “Examples of Expression-Oriented Programming” recent versions of the Example Library of the ABAP Keyword Documentation contain three ABAP games.

Jaw Breaker

/wp-content/uploads/2016/01/jawbreaker_869549.gif

Not too demanding but colorful …

Mine Sweeper

/wp-content/uploads/2016/01/minesweeper_869551.gif

Time-honored and well known …

2048 Game

/wp-content/uploads/2016/01/2048_869552.gif

A recent smart phone game and a real challenge …

Wanna play?

    

          (The examples from the 7.50 documentation can rely on 7.50 features. For 7.40, there are 7.40 examples).

  • If you have a release older than 7.40, you can copy old fashioned 7.00 source code from the  attached text file . Maybe you also have to replace the usage of CL_DEMO_INPUT with PARAMETERS then.

Only outside working hours, of course.

Wanna Contribute?

Maybe, the pattern used in these games (usage of CL_ABAP_BROWSER etc.) motivate you to create some other games?

Note

Due to the discussion below (thanks Enno!) I adjusted the HTML output of

  • DEMO_JAWBREAKER_HTML_740
  • DEMO_JAWBREAKER_HTML_700
  • DEMO_MINESWEEPER_740
  • DEMO_MINESWEEPER_700

in Release 7.50, SP03. You find the new sources in the attached text file .

Hopefully, those run for all combinations of SAP GUI and IE. If not, next round …

Assigned Tags

      38 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Michael Fritz
      Michael Fritz

      Horst,

      guess you compiled those games outside your working hours, too, right? Or was it just for demonstration purposes to explain new features of the ABAP language. 😉

      Michael

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Once my boss explained to me, that I'm working in the moment I'm doing something that is related to ABAP or SAP ...

      Author's profile photo Michael Fritz
      Michael Fritz

      That's a good reason and explanation 😎

      Author's profile photo Roberto Vacca
      Roberto Vacca

      A company can save money everytime a program becomes faster or better or deeper  in giving details or functionalities .

      Games are among first sources of alghorytm of efficiency example applications and often they're the best way to achieve a complex result.

      So we should study Games and alghorytm and save money and time for the company or instead we should change job = GAME OVER 🙂

      Author's profile photo Enno Wulff
      Enno Wulff

      Waiting for the day the canteen will offer ABAP noodles with SELECTed dressing... 😉

      Author's profile photo Nikolay Evstigneev
      Nikolay Evstigneev

      Time to brush up JavaScript? 🙂

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Copy&Paste ... 😉

      Author's profile photo Nikolay Evstigneev
      Nikolay Evstigneev

      Woo-hoo, next time I need to do a copy-paste I'll explain that Horst advised me to do that 😆

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Only for HTML/JS of course, in ABAP we're good enough 😈

      Author's profile photo Enno Wulff
      Enno Wulff

      Hello Horst,

      "Click" is not working... 🙁

      at_click FOR EVENT sapevent OF cl_abap_browser IMPORTING action

      I did test it on two systems now.

      At least a fine, compact and much to small demo (on high resolution displays) 😉

      Greetings Enno 

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      "Click" is not working...


      Makes me wonder. Never had problems with that.


      Can you check SAPEVENT in program DEMO_HTML_BROWSER?


      CL_ABAP_BROWSER should work since 702.


      Horst

      Author's profile photo Enno Wulff
      Enno Wulff

      The Demo_HTML_Browser works. In Jawbreaker I have no pointing hand on "Mouse Over". There is no link...

      Unless I adjust the demo and put something in the table cell:

      CONCATENATE line

                    '<td class="c' cc '">'

                     '<a href="sapevent:x' xn 'y' yn '"/>X</td>' INTO line.

      ...

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Now that's amazing ...

      The Jawbreaker game seemed to work fine in the HTML control of SAP GUI since I implemented it, and now that.

      In order to check, I extracted an HTML file to the disk:

      <html>

      <head>

      <meta http-equiv="content-type" content="text/html; charset=utf-8">

      <style type="text/css">

      a{text-decoration:none;width:18px;height:18px}

      .c1{background-color:lightblue}

      .c2{background-color:cornflowerblue}

      .c3{background-color:darkblue}

      .c4{background-color:steelblue}

      </style>

      </head>

      <body leftmargin="35" topmargin="60" scroll="no">

      <table border="0">

      <tr>

      <td class="c1"><a href="sapevent:x01y01"/></td>

      <td class="c1"><a href="sapevent:x02y01"/></td>

      </tr>

      <tr>

      <td class="c1"><a href="sapevent:x01y02"/></td>

      <td class="c2"><a href="sapevent:x02y02"/></td>

      </tr>

      </table>

      </body>

      </html>         

      And yes, it looks bad in all browsers ...

      /wp-content/uploads/2016/01/small_870425.gif

      Oh my!

      Don't ask me, why it works fine in most (?) SAP GUI controls but not in yours.

      Found a correction that works for me:

      <html>

      <head>

      <meta http-equiv="content-type" content="text/html; charset=utf-8">

      <style type="text/css">

      .bx{text-decoration:none;width:18px;height:18px;cursor:hand}

      .c1{background-color:lightblue}

      .c2{background-color:cornflowerblue}

      .c3{background-color:darkblue}

      .c4{background-color:steelblue}

      </style>

      </head>

      <body leftmargin="35" topmargin="60" scroll="no">

      <table border="0">

      <tr>

      <td class="c1"><a href="sapevent:x01y01"/><div class="bx"></div></td>

      <td class="c1"><a href="sapevent:x02y01"/><div class="bx"></div></td>

      </tr>

      <tr>

      <td class="c1"><a href="sapevent:x01y02"/><div class="bx"></div></td>

      <td class="c2"><a href="sapevent:x02y02"/><div class="bx"></div></td>

      </tr>

      </table>

      </body>

      </html>

      Does it work for you? If this is the case, I think about adjusting DEMO_JAWBREAKER_HTML_... (and Mine Sweeper) in 751.

      Thanks for notifying!

      Horst

      Author's profile photo Enno Wulff
      Enno Wulff

      Yes, it does! Thanks. The report needs some more changes than just adding bx and div. LINE (C255) is too small to take the changes...

      I always cause trouble with my computers configuration. 🙂

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      It depends on the GUI version. I had to add a ";cursor:hand"  to the bx class above otherwise it would not work in recent GUIs any more!

      What SAP GUI version are you using?

      Author's profile photo Enno Wulff
      Enno Wulff

      740 Final Release

      Dateiversion 7400.1.4.1106

      Build 1598106

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Same as I 😐

      Author's profile photo Enno Wulff
      Enno Wulff

      Isn't it relevant which IE version is taken by the GUI?

      Maybe these are different?

      I do not know how to identify the internal version...

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      It's both, SAP GUI and IE, because SAP GUI influences the browser's standard CSS.

      In order to work out right in my SAP GUI as well as other browsers, I finally will combine an a-style and an bx-style.

      ... `.bx{text-decoration:none;cursor:hand;width:18px;height:18px}` &&

      `a{width:18px;height:18px}` ...

      Oh boy ...

      (In fact I'm fighting with that crap everyday for providing the ADT version of the ABAP Docu ...)

      Author's profile photo Former Member
      Former Member

      Thanks for the correction. Got the same Problem with jawbreaker and minesweeper, too.

      With the correction it works fine 😉

      Author's profile photo Kris Claes
      Kris Claes

      Nice,

      I copied the code but get an error during activation:

      21-01-2016 9-28-54.jpg

      I didn't change anything in the declarations ...

      Regards.

      Kris

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Hey, some 7.50 features crept in ...

      Object Component Selector After Table Expressions


      In the 7.40 documentation, there's a 740 runnable code.


      😛


      Author's profile photo Kris Claes
      Kris Claes

      OK.

      Problem solved!

      Kris

      Author's profile photo Matthew Billingham
      Matthew Billingham

      This reminds me. 17 years ago just before Christmas 1999 things were a little slow at work, so, on a 31H system, I wrote a game in ABAP using this report's autorefresh technique.

      There was a ship going across the top of the screen from which you could drop depth charges on the submarine moving randomly at the bottom of the screen.

      It was a rehash of a game I first wrote in 1982 for a ZX81. Autorefresh there was bit easier!

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Missing (and not in action): Classical Dynpro as APC-client.

      Author's profile photo Former Member
      Former Member

      "Missing (and not in action)"?

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Not available up to now, APC for refreshing dynpro screens. You need user interaction on a dynpro screen in order to pass contol to ABAP.

      Author's profile photo Former Member
      Former Member

      Oh, that minor issue.

      Who uses classic SAP GUI anyway? 😉

      Author's profile photo Leonardo Buryan Teixeira
      Leonardo Buryan Teixeira

      Once a User requested a report ALV, the result should be updated without user action.

      Immediately I used the functionality of my ZTETRIS.

      Author's profile photo Former Member
      Former Member

      did you thought about putting it on GitHub?

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      SCN should be sufficient ...

      Author's profile photo Leonie Kleineick
      Leonie Kleineick

      I cannot access the code for systems below 7.4. Would you be so kind and update the link, or upload the code somewhere else?

      Author's profile photo Former Member
      Former Member

      Nice stuff 🙂

      Thanks for sharing it.

      Author's profile photo Peter Inotai
      Peter Inotai

      Hi,

      It seems program DEMO_GAME_2048_700 has some dependencies on version of  cl_demo_input=>add_field( ). In 7.40 SP7 parameter as_checkbox is missing.

      After commenting it out, it works fine however 🙂

      Best regards,

      Peter

      Author's profile photo Horst Keller
      Horst Keller
      Blog Post Author

      Yes, its all about demos and games, delivered, but not under the constraints for productive coding ...

      Author's profile photo Stevens Jennifer
      Stevens Jennifer

      Among Us is a game that is being played by a lot of people today. The game is easy to play with beautiful and funny graphics that attract a lot of users. I think you will like it.