Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REPORT ZPAT_RANK.
- DATA : BEGIN OF pat, "1
- name(10) VALUE 'pat',
- score TYPE i,
- END OF pat.
- DATA : BEGIN OF fern, "2
- name(10) VALUE 'fern',
- score type i,
- END OF fern.
- DATA : BEGIN OF fah, "3
- name(10) VALUE 'fah',
- score TYPE i,
- END OF fah.
- DATA : BEGIN OF peet, "4
- name(10) VALUE 'peet',
- score TYPE i,
- END OF peet.
- DATA : begin of sai, "5
- name(10) VALUE 'sai',
- score TYPE i,
- END OF sai.
- DATA : BEGIN OF eve, "6
- name(10) VALUE 'eve',
- score TYPE i,
- END OF eve.
- DATA : BEGIN OF nut, "7
- name(10) VALUE 'nut',
- score TYPE i,
- END OF nut.
- DATA : BEGIN OF peter, "8
- name(10) VALUE 'peter',
- score TYPE i,
- end of peter.
- DATA result like QF00-RAN_INT.
- *-------------------------------------------------------
- do.
- IF ( pat-score >= 100 ) or
- ( fern-score >= 100 ) or
- ( fah-score >= 100 ) or
- ( peet-score >= 100 ) or
- ( sai-score >= 100 ) or
- ( eve-score >= 100 ) or
- ( nut-score >= 100 ) or
- ( peter-score >= 100 ) .
- exit.
- ENDIF.
- CALL FUNCTION 'QF05_RANDOM_INTEGER'
- EXPORTING
- RAN_INT_MAX = 8
- RAN_INT_MIN = 1
- IMPORTING
- RAN_INT = result
- EXCEPTIONS
- INVALID_INPUT = 1
- OTHERS = 2
- .
- IF SY-SUBRC <> 0.
- * Implement suitable error handling here
- ENDIF.
- IF result = 1.
- add 1 to pat-score.
- ELSEIF result = 2.
- add 1 to fern-score.
- ELSEIF result = 3.
- add 1 to fah-score.
- ELSEIF result = 4.
- add 1 to peet-score.
- ELSEIF result = 5.
- add 1 to sai-score.
- ELSEIF result = 6.
- add 1 to eve-score.
- ELSEIF result = 7.
- add 1 to nut-score.
- else.
- add 1 to peter-score.
- ENDIF.
- ENDDO.
- *----------------------------------------
- DATA:first TYPE i VALUE -9999,
- winner(10),
- second type i VALUE -9999,
- first_runner_up(10),
- third TYPE i VALUE -9999,
- second_runner_up(10).
- DATA : BEGIN OF it_winner OCCURS 0,
- name(10),
- score TYPE i,
- END OF it_winner.
- IT_WINNER-name = pat-name.
- it_winner-score = pat-score.
- APPEND it_winner.
- IT_WINNER-name = fern-name.
- it_winner-score = fern-score.
- APPEND it_winner.
- IT_WINNER-name = fah-name.
- it_winner-score = fah-score.
- APPEND it_winner.
- IT_WINNER-name = peet-name.
- it_winner-score = peet-score.
- APPEND it_winner.
- IT_WINNER-name = sai-name.
- it_winner-score = sai-score.
- APPEND it_winner.
- IT_WINNER-name = eve-name.
- it_winner-score = eve-score.
- APPEND it_winner.
- IT_WINNER-name = nut-name.
- it_winner-score = nut-score.
- APPEND it_winner.
- IT_WINNER-name = peter-name.
- it_winner-score = peter-score.
- APPEND it_winner.
- LOOP AT it_winner.
- IF it_winner-score > first.
- second = first.
- first_runner_up = winner.
- first = it_winner-SCORE.
- winner = it_winner-name.
- ELSEIF it_winner-score > second.
- third = second.
- second_runner_up = first_runner_up.
- second = it_winner-score.
- first_runner_up = it_winner-NAME.
- ELSEIF it_winner-score > third.
- second = it_winner-score.
- second_runner_up = it_winner-name.
- ENDIF.
- ENDLOOP.
- *---------------- Display ---------------
- DATA: concat_1(20), concat_2(20), concat_3(20),
- first_char(3),
- second_char(3),
- third_char(3).
- WRITE: first to first_char,
- second to second_char,
- third to third_char.
- CONCATENATE '1' winner 'score : ' first_char into concat_1 SEPARATED BY SPACE.
- CONCATENATE '2' first_runner_up 'score : ' second_char into concat_2 SEPARATED BY SPACE.
- CONCATENATE '3' second_runner_up 'score : ' third_char into concat_3 SEPARATED BY SPACE.
- *WRITE : concat_1 COLOR 5.
- WRITE : concat_1 COLOR 5,
- / concat_2 COLOR 3,
- / concat_3 COLOR 7.
Advertisement
Add Comment
Please, Sign In to add comment