Language ABAP
(Use of Forms and Macros)
Date: | 11/19/08 |
Author: | David Lacorre |
URL: | n/a |
Comments: | 1 |
Info: | n/a |
Score: | (2.88 in 8 votes) |
*&---------------------------------------------------------------------* *& Report Z99_BOTTLES *&---------------------------------------------------------------------* * Author : David Lacorre *&---------------------------------------------------------------------* REPORT z99_bottles . DATA w_index TYPE i. *----------------------------------------------------------------------* * Allow users to change the maximum bottle capacity on the wall * Default walls contains up to 99 bottles *----------------------------------------------------------------------* PARAMETERS pa_max TYPE i DEFAULT 99. *----------------------------------------------------------------------* * Main Program *----------------------------------------------------------------------* START-OF-SELECTION . DO pa_max TIMES . w_index = pa_max - sy-index + 1. PERFORM : describe_bottles USING w_index , take_one_down CHANGING w_index , describe_bottles_on_wall USING w_index . SKIP. ENDDO. * PERFORM : describe_bottles USING 0 , go_to_store , describe_bottles_on_wall USING pa_max . *----------------------------------------------------------------------* * Forms (Abap functions) and MACROS *----------------------------------------------------------------------* *----------------------------------------------------------------------* * MACRO beg_describe : Data definition for "describe" Forms *----------------------------------------------------------------------* DEFINE beg_describe . DATA : l_nb(10) , l_bottle(7) , l_line(80) . PERFORM find_text_number USING p_nb_bottles CHANGING l_nb. PERFORM find_text_bottle USING p_nb_bottles CHANGING l_bottle. END-OF-DEFINITION. *&---------------------------------------------------------------------* *& Form describe_bottles_on_wall *&---------------------------------------------------------------------* FORM describe_bottles_on_wall USING p_nb_bottles TYPE i . beg_describe. CONCATENATE l_nb l_bottle 'of beer on the wall.' INTO l_line SEPARATED BY space . WRITE l_line. ENDFORM. "describe_bottles *&---------------------------------------------------------------------* *& Form describe_bottles *&---------------------------------------------------------------------* FORM describe_bottles USING p_nb_bottles TYPE i . beg_describe. CONCATENATE l_nb l_bottle 'of beer on the wall,' l_nb l_bottle 'of beer.' INTO l_line SEPARATED BY space . WRITE / l_line. ENDFORM. "describe_bottles *&---------------------------------------------------------------------* *& Form take_one_down *&---------------------------------------------------------------------* FORM take_one_down CHANGING p_nb_bottles TYPE i . SUBTRACT 1 FROM p_nb_bottles. WRITE / 'Take one down and pass it around,'. ENDFORM. "take_one_down *&---------------------------------------------------------------------* *& Form go_to_store *&---------------------------------------------------------------------* FORM go_to_store . WRITE / 'Go to the store and buy some more,'. ENDFORM. "take_one_down *&---------------------------------------------------------------------* *& Form find_text_number *&---------------------------------------------------------------------* FORM find_text_number USING p_nb_bottles CHANGING p_txt . CASE p_nb_bottles. WHEN 0. WRITE 'no more' TO p_txt. WHEN OTHERS. WRITE p_nb_bottles TO p_txt. ENDCASE. CONDENSE p_txt. ENDFORM. "find_text_number *&---------------------------------------------------------------------* *& Form find_text_bottle *&---------------------------------------------------------------------* FORM find_text_bottle USING p_nb_bottles CHANGING p_txt . CASE p_nb_bottles. WHEN 1. WRITE 'bottle' TO p_txt. WHEN OTHERS. WRITE 'bottles' TO p_txt. ENDCASE. ENDFORM. "find_text_bottle
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
standard version | Dominik Ritter | 04/20/05 | 0 | |
object-oriented version | Dominik Ritter | 04/20/05 | 0 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
backup text messagelo said on 07/28/10 08:56:22