Skip to Content

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN PUSHBUTTON /10(3) push1 USER-COMMAND push1 MODIF ID p1.

SELECTION-SCREEN PUSHBUTTON 14(3)  push2 USER-COMMAND push2 MODIF ID p2.

SELECTION-SCREEN PUSHBUTTON 18(3)  push3 USER-COMMAND push3 MODIF ID p3.

SELECTION-SCREEN PUSHBUTTON /10(3) push4 USER-COMMAND push4 MODIF ID p4.

SELECTION-SCREEN PUSHBUTTON 14(3)  push5 USER-COMMAND push5 MODIF ID p5.

SELECTION-SCREEN PUSHBUTTON 18(3)  push6 USER-COMMAND push6 MODIF ID p6.

SELECTION-SCREEN PUSHBUTTON /10(3) push7 USER-COMMAND push7 MODIF ID p7.

SELECTION-SCREEN PUSHBUTTON 14(3)  push8 USER-COMMAND push8 MODIF ID p8.

SELECTION-SCREEN PUSHBUTTON 18(3)  push9 USER-COMMAND push9 MODIF ID p9.

SELECTION-SCREEN END OF BLOCK b1.

DATA       : t_range TYPE RANGE OF char02.

PARAMETERS : p_play       TYPE char08 MODIF ID pl.

PARAMETERS : p_result     TYPE char20 MODIF ID rt.

DATA       :     v_action TYPE syucomm,

                 v_play   TYPE i,

                 v_won    TYPE char01,

                 v_count  TYPE i.

INITIALIZATION.

      MOVE :  ‘PLAYER 1’  TO p_play,

              ‘1’         TO v_play.

AT SELECTION-SCREEN OUTPUT.

  PERFORM read_only.

  PERFORM get_event.

AT SELECTION-SCREEN.

  PERFORM get_event_1.

*&———————————————————————*

*&      Form  GET_EVENT

*&———————————————————————*

*       Get Events

*———————————————————————-*

FORM get_event .

  CASE v_action.

    WHEN ‘PUSH1’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P1’.

    WHEN ‘PUSH2’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P2’.

    WHEN ‘PUSH3’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P3’.

    WHEN ‘PUSH4’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P4’.

    WHEN ‘PUSH5’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P5’.

    WHEN ‘PUSH6’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P6’.

    WHEN ‘PUSH7’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P7’.

    WHEN ‘PUSH8’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P8’.

    WHEN ‘PUSH9’.

      PERFORM pass_value.

      PERFORM set_read USING ‘P9’.

  ENDCASE.

  PERFORM check_result USING ‘X’.

  PERFORM check_result USING ‘O’.

ENDFORM.                    ” GET_EVENT

*&———————————————————————*

*&      Form  READ_ONLY

*&———————————————————————*

*       Inactive element

*———————————————————————-*

FORM read_only .

  LOOP AT SCREEN.

    CHECK screen-group1 EQ ‘PL’.

    screen-input = ‘0’.

    MODIFY SCREEN.

  ENDLOOP.

  LOOP AT SCREEN.

    CHECK screen-group1 EQ ‘RT’.

    screen-input = ‘0’.

    MODIFY SCREEN.

  ENDLOOP.

ENDFORM.                    ” READ_ONLY

*&———————————————————————*

*&      Form  SET_READ

*&———————————————————————*

*       Set Inactive

*———————————————————————-*

FORM set_read  USING value(p_0128).

  DATA : lx_selopt TYPE selopt.

  CLEAR lx_selopt.

  MOVE : ‘I’    TO lx_selopt-sign,

       ‘EQ’   TO lx_selopt-option,

       p_0128 TO lx_selopt-low.

  APPEND lx_selopt TO t_range.

  IF v_play EQ 1.

    ADD 1 TO v_play.

    MOVE : ‘PLAYER 2’ TO p_play.

  ELSE.

    MOVE 1 TO v_play.

    MOVE : ‘PLAYER 1’ TO p_play.

  ENDIF.

  LOOP AT SCREEN.

    CHECK screen-group1 IN t_range.

    screen-input = ‘0’.

    MODIFY SCREEN.

  ENDLOOP.

ENDFORM.                    ” SET_READ

*&———————————————————————*

*&      Form  GET_EVENT_1

*&———————————————————————*

*       Action

*———————————————————————-*

FORM get_event_1 .

  CLEAR v_action.

  MOVE sy-ucomm TO v_action.

ENDFORM.                    ” GET_EVENT_1

*&———————————————————————*

*&      Form  PASS_VALUE

*&———————————————————————*

*       Pass Value

*———————————————————————-*

FORM pass_value.

  ADD 1 TO v_count.

  CASE v_action.

    WHEN ‘PUSH1’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push1.

        WHEN 2.

          MOVE ‘O’ TO push1.

      ENDCASE.

    WHEN ‘PUSH2’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push2.

        WHEN 2.

          MOVE ‘O’ TO push2.

      ENDCASE.

    WHEN ‘PUSH3’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push3.

        WHEN 2.

          MOVE ‘O’ TO push3.

      ENDCASE.

    WHEN ‘PUSH4’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push4.

        WHEN 2.

          MOVE ‘O’ TO push4.

      ENDCASE.

    WHEN ‘PUSH5’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push5.

        WHEN 2.

          MOVE ‘O’ TO push5.

      ENDCASE.

    WHEN ‘PUSH6’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push6.

        WHEN 2.

          MOVE ‘O’ TO push6.

      ENDCASE.

    WHEN ‘PUSH7’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push7.

        WHEN 2.

          MOVE ‘O’ TO push7.

      ENDCASE.

    WHEN ‘PUSH8’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push8.

        WHEN 2.

          MOVE ‘O’ TO push8.

      ENDCASE.

    WHEN ‘PUSH9’.

      CASE v_play.

        WHEN 1.

          MOVE ‘X’ TO push9.

        WHEN 2.

          MOVE ‘O’ TO push9.

      ENDCASE.

  ENDCASE.

ENDFORM.                    ” PASS_VALUE

*&———————————————————————*

*&      Form  CHECK_RESULT

*&———————————————————————*

*       Value

*———————————————————————-*

FORM check_result  USING    value(p_0219).

  IF push1 = p_0219     AND push2 = p_0219 AND push3 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push4 = p_0219 AND push5 = p_0219 AND push6 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push7 = p_0219 AND push8 = p_0219 AND push9 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push1 = p_0219 AND push4 = p_0219 AND push7 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push2 = p_0219 AND push5 = p_0219 AND push8 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push3 = p_0219 AND push6 = p_0219 AND push9 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push1 = p_0219 AND push5 = p_0219 AND push9 = p_0219.

    MOVE ‘X’ TO v_won.

  ELSEIF push3 = p_0219 AND push5 = p_0219 AND push7 = p_0219.

    MOVE ‘X’ TO v_won.

  ENDIF.

  IF v_won EQ ‘X’ AND p_result IS INITIAL.

    CASE p_0219.

      WHEN ‘X’.

        MOVE ‘PLAYER 1 Won’ TO p_result.

        CLEAR p_play.

      WHEN ‘O’.

        MOVE ‘PLAYER 2 Won’ TO p_result.

        CLEAR p_play.

    ENDCASE.

  ELSEIF v_won EQ space AND p_result IS INITIAL AND v_count EQ 9.

    MOVE ‘GAME OVER’ TO p_result.

    CLEAR p_play.

  ENDIF.

ENDFORM.                    ” CHECK_RESULT

To report this post you need to login first.

1 Comment

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

  1. Paul Bakker

    Sorry, why did you post this? It’s just straight ABAP code with no preamble or comments…

    Are you demonstrating an issue, solving a problem, looking for feedback ….?

    confused,

    Paul

    (0) 

Leave a Reply