You are on page 1of 3

Lab Exercise #3: ABAP/4 Reports & OpenSQL Statements

In this lab, you will create ABAP/4 reports. To complete this exercise, you may use previous lecture
notes, as well as the course text book. This exercise will require you to access the ABAP/4 development
workbench from the R/3 system. You do not need to submit the lab handout since the programs will be
submitted directly into the SAP R/3 system. Good luck.

Part A

In Part A, you will create an ABAP report that queries an existing table (SBOOK) in the SAP R/3 system
and outputs the data. The code will include ABAP statements, system fields, text elements, and
header/lists elements. The estimated time to complete this exercise is 40 minutes.

Step 1 - From the Repository Browser, create a new ABAP/4 program. Once again, this will be a Local
Object with development class: $TMP. Use the following naming convention for part A:

Z_Project3_PartA_Lastname_XX

Step 2 – In this program, you will need to use the SBOOK table. Before writing the code, it is
recommended you open another session in R/3 and review the table structure (fields, domains, elements)
of the table.
Hint: use the Table command

Step 3 – Use the Select statement to get all records from the SBOOK table.

Step 4 – Output the following fields in your report (remember, use F8 as a shortcut to execute your
program):

Carrid
Connid
Fldate
Bookid
Luggweight
Wunit

Hint: when referring to a field in your code, you have to precede the field with the table name:
sbook-carrid

Step 5 – After you output the field names, make sure you use the system fields that display the date, time
and username. (hint: you did this for the first project).

Step 6 – Maintain the list and column headers appropriately. (Hint: goto, text elements).

CHALLENGE: edit your select statement to include only carrid = LH and connid = 0400.
Remember, you can extend your Select statement with keywords like ‘where’.

Look below for a sample of what your output should resemble:


Bookings of Airline LH

Airline ConnID Flight date Booking Weight of Weight


Number Baggage Unit

LH 0400 02/28/1995 00000001 20 KG


LH 0400 02/28/1995 00000002 20 KG
LH 0400 02/28/1995 00000003 30 KG

This list was created


on : 04/16/1997
at : 14:46:38
by : bc630a-00

Part B

In this ABAP/4 program, you will write a program that generates an interactive report. When the
program is executed, the user will be asked to insert an Airline Carrier ID. This example will include a
variable declaration to store the airline carrid that will be used later in the program. This ABAP/4
program should address the following problem/issue:

List all United Airlines flight information for flights scheduled after 11-01-1999.

Use the following naming convention for part B:

Z_Project3_PartB_Lastname_XX

Step 1 – use the table SFLIGHT for this exercise. Don’t forget to open a session in R/3 and examine the
structure of this table before you proceed.

Step 2 – Declare a variable that will bring up a listing of carrid’s from table sflight. Typically, the
ABAP/4 keyword for declaring variables is Data, but in this example, you will use the parameters
statement to allow the user to select from a list of values that already exist. The synax for this statement
is:
parameters variable_name like table-field_name

You can make up any variable name to used in Step 2 (it should be somewhat logical though).

Step 3 – Use the select statement to select all records from table sflight where the carrid = variable and
fldate is greater than November 1, 1999. When programming in this argument, use the following syntax
for the date: ‘yyyymmdd’.
Step 4 – Write out the following fields in your example:

Carrid
Connid
Fldate
Price
PlaneType
Seatsmax
Seatsocc
Paymentsum

Step 5 – Maintain headers for your report.

You might also like