7.10_ Data Interfaces Exercises
7.10_ Data Interfaces Exercises
0
Data Interfaces: Exercises SAP Development ABAP Training
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.
Use the green arrow to go back to your new Package, and ensure that all you programs in the
Data Interfaces section of the course are stored in this Package.
Dec-2008
Page 1
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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: ABAPxxJOB1 (where ‘xx’ is the last two digits of your logon id)
Job Step #1: YAPXX05_1
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.
Dec-2008
Page 2
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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: ABAPxxJOB2 (where ‘xx’ is the last two digits of your logon id)
Job Step #1: YAPXX05_1
After the background job has completed, analyze the job log and spool list.
Dec-2008
Page 3
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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 (where ‘xx’ is the last two digits of your logon id)
Job Step #1: ZBACKxx
Variant: VARIANTxx
After the background job has completed, analyze the job log and spool list.
Dec-2008
Page 4
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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: ABAPxxJOB4 (where ‘xx’ is the last two digits of your logon id)
Job Step #1: YAPXX05_1
Job Step #2: YAPXX10_4
After the background job has completed, analyze the job log and spool list.
Dec-2008
Page 5
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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: ABAPxxJOB5 (where ‘xx’ is the last two digits of your logon id)
Job Step #1: YAPXX05_1
After the background job has completed, analyze the job log and spool list.
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).
Dec-2008
Page 6
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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 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 SAP’s master vendor tables. We created this table for the
purpose of your ABAP exercises (notice that it starts with a “Y”). Some of SAP’s master vendor
tables include LFA1, LFB1, and LFC1.
Dec-2008
Page 7
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
Exercise 2
Program Name: YDIxx2-2 (where ‘xx’ is the last two digits of your logon id)
File: ./ file1xx (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:
Dec-2008
Page 8
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
Exercise 3
Program Name: YDIxx2-3 (where ‘xx’ is the last two digits of your logon id)
File: ./file2xx
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 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.
Dec-2008
Page 9
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
Exercise 4
Program Name: YDIxx2-4 (where ‘xx’ is the last two digits of your logon id)
File: ./file2xx
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.
Dec-2008
Page 10
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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 (where ‘xx’ is the last two digits of your logon id)
File: c:\file3xx
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 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.
Dec-2008
Page 11
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
Exercise 2
Program Name: YDIxx3-2 (where ‘xx’ is the last two digits of your logon id)
File: c:\file3xx
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.
Dec-2008
Page 12
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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 transaction’s 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:
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.
Dec-2008
Page 13
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
* 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.
Dec-2008
Page 14
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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.
START-OF-SELECTION.
PERFORM FILL_BDC_TAB.
* code to write out contents of BDC table
Dec-2008
Page 15
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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.
Dec-2008
Page 16
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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:
VENDNUM(16) TYPE C
NAME(30) TYPE C
SORT(20) TYPE C
COUNTRY(3) TYPE 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.
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.
Dec-2008
Page 17
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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 (where ‘xx’ is the last two digits of your logon id)
File: ./file5xx
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.
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)
Dec-2008
Page 18
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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”)?
Dec-2008
Page 19
ECC 6.0
Data Interfaces: Exercises SAP Development ABAP Training
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
(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?
Dec-2008
Page 20