Monday, 21 May 2018

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

STEP 2

Create a screen with type normal

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

STEP 3

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

STEP 4

Go to flow logic and build the query

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

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

STEP 5

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

GUI Status

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

GUI Title

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

TOP INCLUDE

Data Declaration

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

TRANSACTION

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

STEP 6

Run the transaction

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

STEP 7

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.

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

STEP 8

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

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

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.


SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Learning

No comments:

Post a Comment