You are on page 1of 20

ECC 6.

0
SAP Development ABAP Training

Data Interfaces: Exercises

The following exercises are designed to help you understand:


Background processing
Working with files (either on the application server or the presentation server)
Batch input process.
Before you begin the Data Interfaces exercises, you must create a new Package and a
new Change Request, so your work is stored as it might be on a client project.
To do this, find the sheet used for your first Package and Change Request Exercise and use this
if you need it to help you through the abbreviated instructions below:
Create a new Package, by going to the Repository Browser (transaction SE80), and typing YXXD
in the Package field (where XX is the last two digits of your logon id). Click on the display
pushbutton, and create the new Package, calling it something like Data Interfaces Package for
<your name>.
NOTE: When you click the save button; do not use your previous Change Request.
Instead, when the Change Request Query Screen appears, click on the Create Request
pushbutton, enter a short description, such as Data Interfaces Change Request for <your
name>, and save.
Write down the number of your change request here: ____________________________
Use the green arrow to go back to your new Package, and ensure that all your programs in the
Data Interfaces section of the course are stored in this Package.

Page 1

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapter 1
The purpose of these exercises is for you to create some background jobs and to evaluate
background job logs.
Before proceeding with the exercises for this chapter, change your user defaults (System > User
profile > Own data menu path, then the Defaults index tab) so that you will not print
immediately.
Exercise 1
In this exercise, you will create a background job with one job step. Use the Define Background
Job function (System > Services > Jobs > Define job menu path or transaction SM36) to
create the following background job:
Background Job:
Job Step #1:

ABAPxxJOB1
YAPXX05_1

(where xx is the last two digits of your logon id)

This background job should be scheduled to start immediately.


After the background job has completed, analyze the job log and spool list using the Job
Overview function (System > Services > Jobs > Job overview menu path or transaction
SM37). If there is no spool list, you probably forgot to turn off the print immediately and the list
was sent to the printer.
Did the background job execute successfully? If not, why?

Page 2

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 2
In this exercise, you will create a background job with one job step. Use the Define Background
Job function (System > Services > Jobs > Define job menu path or transaction SM36) to
create the following background job:
Background Job:
Job Step #1:

ABAPxxJOB2
YAPXX05_1

(where xx is the last two digits of your logon id)

This background job should be scheduled to start at in 5 minutes.


After the background job has completed, analyze the job log and spool list.
Did the background job execute successfully? If not, why?

Page 3

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 3
In this exercise, you will create a background job with one job step. Before creating the
background job, copy program YAPXX10_4 to ZBACKxx (where xx is the last two digits
of your logon id). Because this program has a selection screen, you will need to create a variant
for it. Execute your ZBACKxx program and create the variant VARIANTxx (where xx is the
last two digits of your logon id) with a valid Year. (You can do with your other programs also
which has selection screen)
Use the Define Background Job function (System > Services > Jobs > Define job menu path
or transaction SM36) to create the following background job:
Background Job:
ABAPxxJOB3
Job Step #1:
ZBACKxx
Variant:
VARIANTxx

(where xx is the last two digits of your logon id)

This background job should be scheduled to start immediately.


After the background job has completed, analyze the job log and spool list.
Did the background job execute successfully? If not, why?

Page 4

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 4
In this exercise, you will create a background job with two job steps. Use the Define Background
Job function (System > Services > Jobs > Define job menu path or transaction SM36) to
create the following background job: (You can take any 2 of your valid programs to do the
exercise)
Background Job:
Job Step #1:
Job Step #2:

ABAPxxJOB4
YAPXX05_1
YAPXX10_4

(where xx is the last two digits of your logon id)

This background job should be scheduled to start immediately.


After the background job has completed, analyze the job log and spool list.
Did the background job execute successfully? If not, why?

Page 5

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 5
Program Name:YDIxx1-5

(where xx is the last two digits of your logon id)

In this exercise, you will write an ABAP program that creates a background job with one job step.
Use the function modules JOB_OPEN, JOB_SUBMIT, and JOB_CLOSE to create the
following background job:
Background Job:
Job Step #1:

ABAPxxJOB5
YAPXX05_1

(where xx is the last two digits of your logon id)

This background job should be scheduled to start immediately.


After the background job has completed, analyze the job log and spool list.
Did the background job execute successfully? If not, why?

After finishing the exercises for this chapter, you can turn on your print immediately function
again if you want (System > User profile > Own data menu path, then the Defaults index tab).

Page 6

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapter 2
The purpose of these exercises is for you to learn how to process (i.e. create and read)
sequential files on the application server.
Exercise 1
Program Name:YDIxx2-1
(where xx is the last two digits of your logon id)
File:
./ file1xx
(the file will be created under DIR_SAPUSERS)
In this exercise, you will write an ABAP program to create a sequential file on the application
server. This sequential file should be structured in lines (or records).
The layout for each record of the file is:
VENDNUM
LIKE
COMPANY
LIKE
ACCTGROUP
LIKE
NAME
LIKE
SORT
LIKE
CITY
LIKE
ZIPCODE
LIKE
COUNTRY
LIKE
REGION
LIKE
LANG
LIKE

YVENDOR-VENDNUM
YVENDOR-COMPANY
YVENDOR-ACCTGROUP
YVENDOR-NAME
YVENDOR-SORT
YVENDOR-CITY
YVENDOR-ZIPCODE
YVENDOR-COUNTRY
YVENDOR-REGION
YVENDOR-LANG

The data for this file should be extracted from the YVENDOR table. Examine the structure of
this table. Notice that one of the key fields is UNAME. You should use this key field to extract
only those records for your user name. In other words, the SELECT statement should be
coded as follows:
SELECT * FROM ZVENDOR WHERE UNAME = SY-UNAME.
The YVENDOR table is not one of SAPs master vendor tables. We created this table for the
purpose of your ABAP exercises (notice that it starts with a Y). Some of SAPs master vendor
tables include LFA1, LFB1, and LFC1.

Page 7

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 2
Program Name:YDIxx2-2
File:
./ file1xx

(where xx is the last two digits of your logon id)


(the file will be kept under DIR_SAPUSERS)

In this exercise, you will write an ABAP program to read data from the sequential file created in
the previous example and to create a list with this information. You can choose the layout of
your list.
Remember that the learning point for this exercise is to be able to read a sequential file on the
application server, not to be able to create a nice looking report. In other words, do not spend
time formatting the report.
The file created in the previous example is used in future exercises. When you execute this
program to read the file, make sure that the contents of your file are correct:
Record #1
Record #2
Vendor Number *
ABAPxx-001 ABAPxx-002
Company Code
0001
0001
Account Group
0001
0001
Name
Vendor001
Vendor002
Sort Term
ABAP
ABAP
City
Philadelphia
Boston
Zip code
19103
02116
Country
US
US
Region
PA
MA
Language
E
E
where xx is the last two digits of your logon id

Page 8

Record #3
ABAPxx-003
0001
0001
Vendor003
ABAP
Miami
33143
US
FL
E

Record #4
ABAPxx-004
0001
0001
Vendor004
ABAP
Chicago
60601
US
IL
E

Record #5
ABAPxx-005
0001
0001
Vendor005
ABAP
London
SW1 8DL
GB
LO
E

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 3
Program Name:YDIxx2-3
File:
./file2xx

(where xx is the last two digits of your logon id)

In this exercise, you will write an ABAP program to create a sequential file on the application
server. This sequential file should be structured in lines (or records).
The layout for each record of the file is:
CUSTNUM
LIKE
NAME
LIKE
STREET
LIKE
PHONE
LIKE
FAX
LIKE

KNA1-KUNNR
KNA1-NAME1
KNA1-STRAS
KNA1-TELF1
KNA1-TELFX

The data for this file should be entered as parameters on the selection screen. You can use any
defaults for these parameters.
Each time this program is executed, a new record should be added to the file. In other words,
the file should be extended, not re-created, each time the program is executed.
Execute the program several times to populate the file with multiple records.

Page 9

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 4
Program Name:YDIxx2-4
File:
./file2xx

(where xx is the last two digits of your logon id)

In this exercise, you will write an ABAP program to read data from the sequential file created in
the previous example and to create a list with this information. You can choose the layout of
your list.
Remember that the learning point for this exercise is to be able to read a sequential file on the
application server, not to be able to create a nice looking report. In other words, do not spend
time formatting the report.

Page 10

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapter 3
The purpose of these exercises is for you to learn how to process (i.e. create and read) files on
the presentation server.
Exercise 1
Program Name:YDIxx3-1
File:
c:\file3xx

(where xx is the last two digits of your logon id)

In this exercise, you will write an ABAP program to create a file on the presentation server. This
sequential file should be structured in lines (or records). You should create this file in the same
manner that you created the file for Exercise 1 in Chapter 2. The only difference in the two files
is the location. This one is on the presentation server, not the application server.
The layout for each record of the file is:
VENDNUM
LIKE
COMPANY
LIKE
ACCTGROUP
LIKE
NAME
LIKE
SORT
LIKE
CITY
LIKE
ZIPCODE
LIKE
COUNTRY
LIKE
REGION
LIKE
LANG
LIKE

YVENDOR-VENDNUM
YVENDOR-COMPANY
YVENDOR-ACCTGROUP
YVENDOR-NAME
YVENDOR-SORT
YVENDOR-CITY
YVENDOR-ZIPCODE
YVENDOR-COUNTRY
YVENDOR-REGION
YVENDOR-LANG

The data for this file should be extracted from the YVENDOR table. Examine the structure of
this table. Notice that one of the key fields is UNAME. You should use this key field to extract
only those records for your user name. In other words, the SELECT statement should be
coded as follows:
SELECT * FROM YVENDOR WHERE UNAME = SY-UNAME.
After you execute this program, make sure the file exists on your hard drive.

Page 11

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 2
Program Name:YDIxx3-2
File:
c:\file3xx

(where xx is the last two digits of your logon id)

In this exercise, you will write an ABAP program to read data from the file created in the previous
example and to create a list with this information. You can choose the layout of your list.
Remember that the learning point for this exercise is to be able to read a sequential file on the
presentation server, not to be able to create a nice looking report. In other words, do not spend
time formatting the report.

Page 12

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapter 4
The purpose of these exercises is for you to learn how to research a transaction and how to fill
the BDC table with the appropriate information. You will build upon these exercises in chapter 5
to actually perform batch input.
Exercise 1
Research the Create Vendor transaction (Transaction FK01). You can access this vendor
transaction using the Accounting > Financial accounting > Accounts payable > Master records >
Create menu path from the initial SAP screen (transaction S000 will take you to the initial SAP
screen). Fill in the BDC table on the next page with this transactions information.
To research the transaction, you will have to fill in the appropriate fields in order to proceed in the
transaction. Use the following table as your guideline to fill the fields:
Enter this value when
Field Description
researching the transaction
Vendor
ABAPxx-nnn *
Company code
0001 (these are zeroes, not the letter O)
Account group
0001
Name
Vendor
Search term
NUM
City
Miami
Postal code
33143
Country
US
Region
FL
Language
EN
* When you enter a vendor number, use the following convention: NUMxx-nnn (where xx is the
last two digits of your logon id and nnn is a unique number each time you go through the
transaction).

At the end of the transaction, you should save the new vendor record. Do not forget to indicate
this action in the BDC table on the next page.

Page 13

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Create Vendor Transaction Code: __________


PROGRAM

DYNPRO

DYNBEGIN

FNAM

FVAL *

* Just use the values from the previous page for FVAL. Ultimately, these values will be coming
from the sequential file you created in Exercise 1 of Chapter 2.

Page 14

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 2
Program Name:YDIxx4-2

(where xx is the last two digits of your logon id)

In this exercise, you will write an ABAP program to fill the BDC table with the values from your
answer to the previous exercise. You should use the two-subroutine method to fill the BDC
table.
This program will only fill the BDC table. To make sure that you are filling it correctly, you can
create a list with the contents of the BDC table.
Your main program (i.e. START-OF-SELECTION event) should look as follows:
START-OF-SELECTION.
PERFORM FILL_BDC_TAB.
*
code to write out contents of BDC table

Page 15

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapters 5 - 6
The purpose of these exercises is for you to learn how to perform batch input by creating a batch
input session with the contents of the BDC table. In order to test the success of your BDC
programs, you will have to process the batch input session (see chapter 6).
Exercise 1
Program Name:YDIxx5-1
(where xx is the last two digits of your logon id)
Batch Input Session:
SESSION1-xx
In this exercise, you are going to code a BDC program (i.e. create a batch input session) by
building on your last program. You should copy your YDIxx4-2 program to create program
YDIxx5-1.
In this exercise, you will use the information from the file you created in Exercise 1 of Chapter 2
(./file1xx). This file contains new vendor information. You should read in the contents of the
file, fill the BDC table for each record, and create a batch input session.
Do not forget to change the values being entered into the BDC table. In this exercise, these
values should be coming from the file, not the hard-coded values from the previous example.
After executing this BDC program, you must process the batch input session to make sure your
program is correct. To process the batch input session, use the System > Services > Batch
input > Edit menu path (or transaction SM35). The best processing mode for testing is the
foreground-processing processing mode so you can step through each screen to ensure that
the proper values are being entered into the appropriate fields. Chapter 6 contains information
on processing batch input sessions.
Note: Once you successfully process the batch input session, you will have inserted five new
vendors into the SAP system. If you attempt to process another session, you will encounter
errors because you will be trying to insert vendors that already exist. In this case, you can just
change the vendor numbers online while you are processing the batch input session in the
foreground or display errors only processing mode.
Exercise 2
Program Name:YDIxx5-2
(where xx is the last two digits of your logon id)
File:
./ file4xx
Batch Input Session:
SESSION2-xx
In this exercise, you will create a batch input session to change existing vendors. For this
program to work correctly, you must have successfully completed the previous exercise. In other
words, you must have successfully processed the previous batch input session to insert five
vendors into the system.
Change the existing vendors name, sort and country in the custom table YVENDOR and then
write a program to download those in the application server file ./file4xx. The File will be created
in the directory DIR_SAPUSERS.
The layout for each record of the file is:

Page 16

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

VENDNUM(16)
NAME(30)
SORT(20)
COUNTRY(3)

TYPE
TYPE
TYPE
TYPE

C
C
C
C

Research the Change Vendor transaction (FK02) to determine how to fill the BDC table. You
should enter an existing vendor on the first screen and check the address check box. On the
second screen, you should fill in values for the Name, Sort, and Country fields.
PROGRAM

DYNPRO

DYNBEGIN

FNAM

FVAL

After researching the Change Vendor transaction, code the BDC program. You should read in
the contents of the file ./file4xx, fill the BDC table for each record, and create a batch input
session.
After executing this BDC program, you must process the batch input session to make sure your
program is correct. To process the batch input session, use the System > Services > Batch
input > Edit menu path (or transaction SM35). The best processing mode for testing is the
foreground-processing processing mode so you can step through each screen to ensure that
the proper values are being entered into the appropriate fields. Chapter 6 contains information
on processing batch input sessions.

Page 17

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapter 7
The purpose of these exercises is for you to learn how to use the other two batch input methods:
CALL TRANSACTION USING and CALL DIALOG.
Exercise 1
Program Name:YDIxx7-1
File:
./file5xx

(where xx is the last two digits of your logon id)

In this exercise, you will perform batch input to change existing vendors. Instead of creating a
batch input session, you will use the CALL TRANSACTION USING batch input method.
You should copy your YDIxx5-2 program to create program YDIxx7-1.
Edit the program to use the CALL TRANSACTION USING method instead of creating a batch
input session. Also, make sure that you are reading in the new file ./file5xx. Change the
existing vendors name, sort and country in the custom table YVENDOR and then write a
program to download those in the application server file ./file5xx.The layout for each record of
this file is identical to the one in the previous exercise:
VENDNUM(16) TYPE C
NAME(30)
TYPE C
SORT(20)
TYPE C
COUNTRY(3) TYPE C
As each record is processed with CALL TRANSACTION USING, this program should generate
a report indicating the success or failure of the update.
To test this batch input method, use the display all mode of the CALL TRANSACTION USING
statement so you can step through each screen to ensure that the proper values are being
entered into the appropriate fields.
Bonus: How would you create an error file with the unsuccessful records? (do not code)

Page 18

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Exercise 2
How would the previous program change if you were using the CALL DIALOG method instead
of the CALL TRANSACTION USING batch input method (assume that the dialog module is
named Z_DIALOG_FK02)?
Do not code this CALL DIALOG program.

Page 19

Dec-2008

ECC 6.0
SAP Development ABAP Training

Data Interfaces: Exercises

Chapter 8
The purpose of this exercise if for you to learn how to identify function codes associated with
pushbuttons on the screen and function codes associated with menu paths.
Exercise 1
Go to the initial screen of the ABAP Editor (transaction SE38).
(1) What is the function code associated with the Display pushbutton on the screen?
(2) What is the function code associated with the Utilities > Split screen editor menu path?

Page 20

Dec-2008

You might also like