|  | 
我的扫雷游戏~
| report  ztest08                                 . 
 tables : sscrfields.
 type-pools: icon.
 data: begin of wa_layout,
 row(1) type n,
 col(1) type n,
 id like icon-id,
 end of wa_layout.
 data: row-up type n,
 row-down type n,
 row-ul type n,
 row-ur type n,
 col-ul type n,
 col-ur type n,
 col-left type n,
 col-right type n,
 row-dl type n,
 row-dr type n,
 col-dl type n,
 col-dr type n.
 data: i_layout like standard table of wa_layout .
 data: ii_layout like standard table of wa_layout with header line.
 data: iii_layout like standard table of wa_layout with header line.
 data: l type i,
 j type i.
 data: n  type i,
 n1 type i,
 n2 type i,
 n3 type i.
 data: subrc type c.
 data: num type c.
 data : current_ucomm like sscrfields-ucomm,
 s1 like sscrfields-ucomm.
 field-symbols : <fs> type any.
 
 selection-screen begin of block b1 with frame no intervals.
 selection-screen pushbutton /2(4) pb11 user-command pb11.
 selection-screen pushbutton  7(4) pb12 user-command pb12.
 selection-screen pushbutton 12(4) pb13 user-command pb13.
 selection-screen pushbutton 17(4) pb14 user-command pb14.
 selection-screen pushbutton 22(4) pb15 user-command pb15.
 selection-screen pushbutton 27(4) pb16 user-command pb16.
 selection-screen pushbutton 32(4) pb17 user-command pb17.
 selection-screen pushbutton 37(4) pb18 user-command pb18.
 selection-screen pushbutton 42(4) pb19 user-command pb19.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb21 user-command pb21.
 selection-screen pushbutton  7(4) pb22 user-command pb22.
 selection-screen pushbutton 12(4) pb23 user-command pb23.
 selection-screen pushbutton 17(4) pb24 user-command pb24.
 selection-screen pushbutton 22(4) pb25 user-command pb25.
 selection-screen pushbutton 27(4) pb26 user-command pb26.
 selection-screen pushbutton 32(4) pb27 user-command pb27.
 selection-screen pushbutton 37(4) pb28 user-command pb28.
 selection-screen pushbutton 42(4) pb29 user-command pb29.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb31 user-command pb31.
 selection-screen pushbutton  7(4) pb32 user-command pb32.
 selection-screen pushbutton 12(4) pb33 user-command pb33.
 selection-screen pushbutton 17(4) pb34 user-command pb34.
 selection-screen pushbutton 22(4) pb35 user-command pb35.
 selection-screen pushbutton 27(4) pb36 user-command pb36.
 selection-screen pushbutton 32(4) pb37 user-command pb37.
 selection-screen pushbutton 37(4) pb38 user-command pb38.
 selection-screen pushbutton 42(4) pb39 user-command pb39.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb41 user-command pb41.
 selection-screen pushbutton  7(4) pb42 user-command pb42.
 selection-screen pushbutton 12(4) pb43 user-command pb43.
 selection-screen pushbutton 17(4) pb44 user-command pb44.
 selection-screen pushbutton 22(4) pb45 user-command pb45.
 selection-screen pushbutton 27(4) pb46 user-command pb46.
 selection-screen pushbutton 32(4) pb47 user-command pb47.
 selection-screen pushbutton 37(4) pb48 user-command pb48.
 selection-screen pushbutton 42(4) pb49 user-command pb49.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb51 user-command pb51.
 selection-screen pushbutton  7(4) pb52 user-command pb52.
 selection-screen pushbutton 12(4) pb53 user-command pb53.
 selection-screen pushbutton 17(4) pb54 user-command pb54.
 selection-screen pushbutton 22(4) pb55 user-command pb55.
 selection-screen pushbutton 27(4) pb56 user-command pb56.
 selection-screen pushbutton 32(4) pb57 user-command pb57.
 selection-screen pushbutton 37(4) pb58 user-command pb58.
 selection-screen pushbutton 42(4) pb59 user-command pb59.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb61 user-command pb61.
 selection-screen pushbutton  7(4) pb62 user-command pb62.
 selection-screen pushbutton 12(4) pb63 user-command pb63.
 selection-screen pushbutton 17(4) pb64 user-command pb64.
 selection-screen pushbutton 22(4) pb65 user-command pb65.
 selection-screen pushbutton 27(4) pb66 user-command pb66.
 selection-screen pushbutton 32(4) pb67 user-command pb67.
 selection-screen pushbutton 37(4) pb68 user-command pb68.
 selection-screen pushbutton 42(4) pb69 user-command pb69.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb71 user-command pb71.
 selection-screen pushbutton  7(4) pb72 user-command pb72.
 selection-screen pushbutton 12(4) pb73 user-command pb73.
 selection-screen pushbutton 17(4) pb74 user-command pb74.
 selection-screen pushbutton 22(4) pb75 user-command pb75.
 selection-screen pushbutton 27(4) pb76 user-command pb76.
 selection-screen pushbutton 32(4) pb77 user-command pb77.
 selection-screen pushbutton 37(4) pb78 user-command pb78.
 selection-screen pushbutton 42(4) pb79 user-command pb79.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb81 user-command pb81.
 selection-screen pushbutton  7(4) pb82 user-command pb82.
 selection-screen pushbutton 12(4) pb83 user-command pb83.
 selection-screen pushbutton 17(4) pb84 user-command pb84.
 selection-screen pushbutton 22(4) pb85 user-command pb85.
 selection-screen pushbutton 27(4) pb86 user-command pb86.
 selection-screen pushbutton 32(4) pb87 user-command pb87.
 selection-screen pushbutton 37(4) pb88 user-command pb88.
 selection-screen pushbutton 42(4) pb89 user-command pb89.
 selection-screen skip 1.
 selection-screen pushbutton /2(4) pb91 user-command pb91.
 selection-screen pushbutton  7(4) pb92 user-command pb92.
 selection-screen pushbutton 12(4) pb93 user-command pb93.
 selection-screen pushbutton 17(4) pb94 user-command pb94.
 selection-screen pushbutton 22(4) pb95 user-command pb95.
 selection-screen pushbutton 27(4) pb96 user-command pb96.
 selection-screen pushbutton 32(4) pb97 user-command pb97.
 selection-screen pushbutton 37(4) pb98 user-command pb98.
 selection-screen pushbutton 42(4) pb99 user-command pb99.
 
 selection-screen end of block b1.
 
 initialization.
 clear: wa_layout,subrc.
 refresh: i_layout,ii_layout.
 perform do_initial.
 
 at selection-screen output.
 
 if subrc = 4.
 message i000(z01).
 endif.
 
 
 at selection-screen.
 current_ucomm = sscrfields-ucomm.
 read table i_layout into wa_layout with key row =
 sscrfields-ucomm+2(1) col = sscrfields-ucomm+3(1).
 
 perform validate.
 
 
 *&---------------------------------------------------------------------*
 *&      Form  get_random
 *&---------------------------------------------------------------------*
 *       text
 *----------------------------------------------------------------------*
 *      -->P_I  text
 *----------------------------------------------------------------------*
 form get_random  changing    p_l p_j.
 clear: p_l,p_j.
 
 call function 'QF05_RANDOM_INTEGER'
 exporting
 ran_int_max         = 9
 ran_int_min         = 1
 importing
 ran_int             = p_l
 * EXCEPTIONS
 *   INVALID_INPUT       = 1
 *   OTHERS              = 2
 .
 if sy-subrc <> 0.
 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 endif.
 
 call function 'QF05_RANDOM_INTEGER'
 exporting
 ran_int_max         = 9
 ran_int_min         = 1
 importing
 ran_int             = p_j
 * EXCEPTIONS
 *   INVALID_INPUT       = 1
 *   OTHERS              = 2
 .
 if sy-subrc <> 0.
 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
 *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
 endif.
 
 endform.                    " get_random
 *&---------------------------------------------------------------------*
 *&      Form  do_initial
 *&---------------------------------------------------------------------*
 *       text
 *----------------------------------------------------------------------*
 *  -->  p1        text
 *  <--  p2        text
 *----------------------------------------------------------------------*
 form do_initial .
 
 clear: l,j.
 
 pb11 = pb12 = pb13 = pb14 = pb15 = pb16 = pb17 = pb18 =
 pb19 = icon_space.
 pb21 = pb22 = pb23 = pb24 = pb25 = pb26 = pb27 = pb28 =
 pb29 = icon_space.
 pb31 = pb32 = pb33 = pb34 = pb35 = pb36 = pb37 = pb38 =
 pb39 = icon_space.
 pb41 = pb42 = pb43 = pb44 = pb45 = pb46 = pb47 = pb48 =
 pb49 = icon_space.
 pb51 = pb52 = pb53 = pb54 = pb55 = pb56 = pb57 = pb58 =
 pb59 = icon_space.
 pb61 = pb62 = pb63 = pb64 = pb65 = pb66 = pb67 = pb68 =
 pb69 = icon_space.
 pb71 = pb72 = pb73 = pb74 = pb75 = pb76 = pb77 = pb78 =
 pb79 = icon_space.
 pb81 = pb82 = pb83 = pb84 = pb85 = pb86 = pb87 = pb88 =
 pb89 = icon_space.
 pb91 = pb92 = pb93 = pb94 = pb95 = pb96 = pb97 = pb98 =
 pb99 = icon_space.
 
 do 9 times.
 n1 = sy-index.
 do 9 times.
 n2 = sy-index.
 wa_layout-row = n1.
 wa_layout-col = n2.
 wa_layout-id  = '@5F@'.
 append wa_layout to i_layout.
 enddo.
 enddo.
 clear wa_layout.
 
 n = 0.
 do.
 perform get_random changing l j.
 
 loop at i_layout into wa_layout where row = l and col = j.
 wa_layout-row = l.
 wa_layout-col = j.
 wa_layout-id  = '@39@'.
 modify i_layout from  wa_layout.
 endloop.
 collect wa_layout into ii_layout.
 clear wa_layout.
 
 n = lines( ii_layout ).
 if n >= 10.
 exit.
 endif.
 enddo.
 clear wa_layout.
 
 loop at i_layout into wa_layout.
 write: wa_layout-row,wa_layout-col,wa_layout-id.
 endloop.
 endform.                    " do_initial
 *&---------------------------------------------------------------------*
 *&      Form  validate
 *&---------------------------------------------------------------------*
 *       text
 *----------------------------------------------------------------------*
 *  -->  p1        text
 *  <--  p2        text
 *----------------------------------------------------------------------*
 form validate .
 clear: iii_layout,row-up,row-down,col-left,col-right.
 refresh:iii_layout.
 read table ii_layout from wa_layout.
 if sy-subrc <> 0.
 assign (sscrfields-ucomm) to <fs>.
 if sy-subrc = 0.
 row-up    = wa_layout-row - 1.
 row-down  = wa_layout-row + 1.
 col-left  = wa_layout-col - 1.
 col-right = wa_layout-col + 1.
 row-ul = wa_layout-row - 1.
 row-dl = wa_layout-row - 1.
 row-ur = wa_layout-row + 1.
 row-dr = wa_layout-row + 1.
 col-ul = wa_layout-col + 1.
 col-dl = wa_layout-col - 1.
 col-ur = wa_layout-col + 1.
 col-dr = wa_layout-col - 1.
 loop at i_layout into iii_layout where
 ( row = row-up and col = wa_layout-col and id = '@39@' )
 or ( row = row-down and col = wa_layout-col and id = '@39@' )
 or ( row = wa_layout-row and col = col-left and id = '@39@' )
 or ( row = wa_layout-row and col = col-right and id = '@39@' )
 or ( row = row-ul and col = col-ul and id = '@39@' )
 or ( row = row-dl and col = col-dl and id = '@39@' )
 or ( row = row-ur and col = col-ur and id = '@39@' )
 or ( row = row-dr and col = col-dr and id = '@39@' ).
 append iii_layout.
 endloop.
 num = lines( iii_layout ).
 <fs> = num.
 endif.
 elseif sy-subrc = 0.
 loop at ii_layout.
 concatenate 'pb' ii_layout-row ii_layout-col into s1.
 assign (s1) to <fs>.
 <fs> = ii_layout-id.
 endloop.
 subrc = 4.
 endif.
 
 endform.                    " validate
 | 
 |