Intro to ABAP - Chapter 06Exercise by Guihong


More Info
									Introduction to ABAP        ABAP Exercises

                Chapter 6
Introduction to ABAP                                                   ABAP Exercises

Exercise (Chapter 6):
In this exercise, you will write a simple program to test your understanding of the select

After completing this exercise, you will be able to:
   Understand how the select statement works

Estimated time to complete this exercise: 60 minutes

The following exercise provides practice working with the concepts learned in Chapter 6.

Exercise 1:
Name your program YIN005_XX. Create the following output using a basic select *
statement. We are only using select * because we are selecting all the columns from the
table, otherwise using a field list would be much more efficient. Just a reminder that your
data may seem incomplete due to the lack of data in the table. To make sure your results
are correct, go to table YMOVIE, and then go to Utilities  Table Contents and execute.
Finally, you can compare the data in the table with your resulting list.

Don’t forget to check sy-subrc to make sure that a record was successfully retrieved from
the database. Let the user know if no records were found with a message based on the
value of sy-subrc. Your output should resemble the screen shot below. Refer to Program
YIN005 in Development Class YINTRODUCTION for the solution.
Introduction to ABAP                                                   ABAP Exercises

Exercise 2:
Create a new program and name it YIN006_XX. Using another select statement write out
a list of all the winners of the best picture category. Refer to Program YIN006 for the
solution. Your list should be similar to the screen shot below.

Exercise 3:
Now copy YIN006_XX as YIN007_XX and use a field list instead of SELECT *. Refer
to Program YIN007 for the solution. You should get the same output as in the previous

Exercise 4
Copy your last program as YIN008_XX. The client has asked that that same list be
produced, but this time, there should be formatting changes to more clearly highlight
different records on the list:
 The movie winners in election years and those in the year after election year should
  now be highlighted in different colors than the other winners. (Note: In the United
  States, elections are held every 4 years.)
 Also, the client asked that winners in the year directly before election years be left out
  all together.
       For example, the movie winners in 1931 should not appear at all on the list
       created, the winners in 1932 (an election year) should appear in one color and the
       winners from the following year (1933) should be in another color, as should the
       winner from 1934.
Introduction to ABAP                                               ABAP Exercises

Use control statements to code the request. Refer to Program YIN008 for one possible
Hint: Use FORMAT COLOR <n>. to change the highlighting of the next outputted line.
You may want to look into the MOD operator.

Exercise 5
Copy your last program as YIN009_XX. The client has also asked that there be a list
NOT limited to the PIC category, and that an underline be placed between each new year,
with two underlines occurring when any year had no categories associated with it. Refer
to the graphic below for help and to Program YIN009 for one possible solution.

To top