Skip to Content
Author's profile photo Former Member

Simple Number Game

During our childhood days we used to play the number game on paper. The same thing when I played with my kids, they were happy and excited. They used to ask me, dad, how you are telling the correct answers.

The same thing I developed in SAP using Dialog program. Kids can play this on SAP. Just for fun….

Steps to be followed

  •  Create a program in SE80 with type Module Pool
  •  Create a screen with type Normal
  •  Go to screen layout and design the output according to the requirement
  •  Go to flow logic and build the query
  •  Create GUI Status, Title, Top include for data declaration and Transaction code
  •  Run the transaction
  •  How to Play
  •  How it works

STEP 1

Create a program in SE80 with type Module Pool

 

STEP2

Create a screen with type normal

STEP3

Go to screen layout and design the output according to the requirement

The above design has the following components

1.Box

2.Text field

3.Input/Output field

4.Check box

5.Push button

Create function codes for check boxes and push buttons

In Element list you have to define the attribute ok_code to validate the user commands

STEP4

Go to flow logic and build the query

 

MODULE USER_COMMAND_0100
CASE OK_CODE.
  WHEN 'GET'.
    IF TICK4 = 'X' AND TICK3 = 'X' AND TICK2 = 'X' AND TICK1 = 'X'.
      ANSWER = 'Ten'.
    ELSEIF TICK4 = 'X' AND TICK3 = 'X' AND TICK2 = 'X'.
       ANSWER = 'Nine' .
    ELSEIF TICK4 = 'X' AND TICK3 = 'X' AND TICK1 = 'X'.
       ANSWER = 'Eight'.
    ELSEIF TICK4 = 'X' AND TICK3 = 'X'.
       ANSWER = 'Seven'.
     ELSEIF TICK4 = 'X' AND TICK2 = 'X'.
       ANSWER = 'Six'.
    ELSEIF TICK4 = 'X' AND TICK1 = 'X'.
       ANSWER = 'Five'.
     ELSEIF TICK3 = 'X' AND TICK1 = 'X'.
       ANSWER = 'Four'.
     ELSEIF TICK2 = 'X' AND TICK1 = 'X'.
       ANSWER = 'Three'.
     ELSEIF TICK2 = 'X'.
       ANSWER = 'Two'.
     ELSEIF TICK1 = 'X'.
       ANSWER = 'One'.
     ENDIF.
  WHEN 'CLEAR'.
    CLEAR ANSWER.
    CLEAR: TICK4,TICK3,TICK2,TICK1.
  WHEN 'BACK'.
    SET SCREEN 0.
    LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

STEP5

Create GUI Status, Titile, Top include for data declaration and Transaction code

GUI Status

GUI Title

In order to bring the GUI Status and Title in the output  you have to  set the PF status and Title bar in MODULE  STATUS_0100

TOP INCLUDE

Data Declaration

TRANSACTION

STEP6

Run the transaction

STEP7

How  to Play

Ask your kid to remember one number from the top of the BOX.

From the four boxes below, ask them to search the number on their mind and select the corresponding check boxes

Click the GET button to know the answer

For example

Remember the number four in your mind and it will be there in 2nd and 4th box.

Now click the button GET and you are getting answer as Four

STEP8

How it works

The boxes with checkboxes are arranged in descending order.

I.e. The first box will be counted as 4 and the okcode will be TICK4  and the second will be counted as 3 and the okcode will be 3 and it will go like that. => 4 + 3 + 2 + 1

As for as the example is concerned you have chosen the 2nd and 4th box, which means actually it is 3rd and 1st . So the count will be 3 + 1 = 4.

Simple logical expression

The clear button will clear the input/output and all the check boxes. Similarly when you click the back button it will come out of the transaction.

 

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Isn't this pretty much the same thing as your blog from few days ago? Module pool, basic algorithm implementation with IF... ENDIF and some buttons. Or am I missing something?

      If the goal of this post is to educate the beginners then wouldn't it make sense to present increasingly complex scenarios? Or even take the same scenario and see how it can be improved or implemented differently.

      Before posting a new blog, please consider checking for existing posts in Google using "abap games site:sap.com".

      Thank you.

      Author's profile photo Enno Wulff
      Enno Wulff

      I just wanted to add a reply that this is a perfect example of how to use multiple instances of an ALV-grid control so that the programming more variable. Then I recognised that this guy has signed off from the developer network...

      @Jelena Perfiljeva:

      yes, the game is simple and "stupid" in a way that there are only static elements and dumb IF-commands.

      Yes, it is similiar to his last post which here the code itself also was simple and dull.

      Yes, there is a lot to be improved.

      Yes, blog posts should be on a certain level.

      But:

      We are discussing for years how the people into blogging and sharing their knowledge. IMHO it's not useful to criticise a beginner in this grim way you did.

      For me the post was quite perfect from the blogging point of view:

      • He clearly described, what he wanted to present
      • He wrote very detailed which steps have to be done to build the application
      • A lot of screenshots have been added
      • He presented the relevant parts of the code
      • I also searched your suggested search term and did not find a similar game in ABAP. Did you?

      If we want to have this platform alive, we must take care of the beginners and learners. Blog posts are not only for educating and informing others but for a big part also for learning and improving oneself.

      I am also very demanding, but I experienced that you cannot urge someone to post his/ her knowledge. Either someone likes blogging or he/ she doesn't. I think it's easier to discuss with someone who's willing but not perfect than the other way round.

      The beginners of today are the mentors of tomorrow.

      jm2c

      Author's profile photo Enno Wulff
      Enno Wulff

      Sorry, @Jelena Perfiljeva ! I wrongly accused you to having scared this guy off.

      Obviously the "Former Member" appears if someone haven't accepted the new GDPR.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      What is "grim" about asking the questions about the blog? I'm confused... Didn't call anything "stupid" and didn't criticize OP personally. Not sure why you're interpreting my questions in such way...

      And yes, I actually did a Google search on this and found an old Wiki listing several ABAP game code snippets. But, unfortunately, most of those links were pointing to old SDN URLs and looks like they were lost in one of the migrations. One of the links was even for "numbers game" too but, sadly, it's dead now. Don't know if it was the same game. There are very many "numbers games" and OP didn't actually share the rules.

      There is also a good post from 2016. Both links can be found using Google keywords that I've mentioned.

      Author's profile photo Smule Sands
      Smule Sands

      During our childhood days we used number games on paper.  Same thing when I play with my children, they are happy and excited. They used to ask me, father, how do you convey the perfect answers. Read a lot more from here now.

      Author's profile photo Enno Wulff
      Enno Wulff

      Hi Jelena,

      Sorry for maybe being too critical. I just experienced that I nearly scared someone away although I didn‘t think I was crude. When I saw „Former member“ it triggered something...

      I didn‘t mean grim in an aggressive but more some kind of strict. Sorry, my english is not good enough to explain in these subtle differences.

      Also I didn‘t mean „stupid“ as kind of dull, more like simple, not very complicated.

       

      Your hint to checking existing blogs implies that there is a blog about exactly this game and he didn‘t check. So you accused him to having done something wrong. In my opinion he didn‘t.

      Anyway, you are someone who gives a response with your thoughts and tipps at least what is very valuable! Maybe you can consider to be less strict with beginners? Maybe I am to strict with you and your words and took things too literally. Then I am sorry for that! I also don‘t want to offend you. I just wanted to share my thoughts on this „post -  answer - combination“ (I mentioned why I reacted on that).

       

      The rules can be seen in step 7.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Funny thing: I didn't see your reply because we are only notified in very particular cases. Click a wrong "reply" button and might as well be talking to a wall. Nice functionality we have here, sigh...

      Didn't comment anything on the OP's first blog. One free pass is all I can do, sorry! 🙂

      Also it's my understanding that these days there is some kind of blogger approval process, similar to what we used to have on SDN. If it's the very first blog then it'll be reviewed by a moderator. At that point the moderator could suggest some improvements. Not sure what happened here (can't see OP's profile due to "formerization") but maybe some inexperienced authors with older profiles are not subject to that. Eh, Jamie Cantrell ?

      The reason for suggesting to look for existing blogs was not to avoid posting duplicate content (or at least not just for that) but to see what blogging style are other members using in such case. E.g. if I was planning to post about this, I would've found at least a recent Horst's blog and noticed that perhaps using a module pool to demonstrate my game is not really the best way.

      As a side note, regardless of opinions, at least we are having some discussion here and this blog already has 5 comments. How many get just [crickets] these days? That's the real sad part.

      Author's profile photo Jamie Langskov
      Jamie Langskov

      Hey @Jelena Perfiljeva - there aren't exceptions to the 2-post coaching process for new (or "new") bloggers. So, someone must have approved his/her initial two posts at some point.

      Best,

      Jamie