7.10_ data interfaces exercises

25
ECC 6.0 Data Interfaces: Exercises SAP Development ABAP Training 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. Dec-2008 Page 1

Upload: bakkalibilal

Post on 07-Feb-2016

221 views

Category:

Documents


0 download

DESCRIPTION

7.10_ Data Interfaces Exercises

TRANSCRIPT

Page 1: 7.10_ Data Interfaces Exercises

ECC 6.0Data Interfaces: Exercises SAP Development ABAP Training

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.

Dec-2008Page 1

Page 2: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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

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?

Dec-2008Page 2

Page 3: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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

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?

Dec-2008Page 3

Page 4: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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: ZBACKxxVariant: VARIANTxx

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?

Dec-2008Page 4

Page 5: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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_1Job Step #2: YAPXX10_4

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?

Dec-2008Page 5

Page 6: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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

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).

Dec-2008Page 6

Page 7: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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 layout for each record of the file is:VENDNUM LIKE YVENDOR-VENDNUMCOMPANY LIKE YVENDOR-COMPANYACCTGROUP LIKE YVENDOR-ACCTGROUPNAME LIKE YVENDOR-NAMESORT LIKE YVENDOR-SORTCITY LIKE YVENDOR-CITYZIPCODE LIKE YVENDOR-ZIPCODECOUNTRY LIKE YVENDOR-COUNTRYREGION LIKE YVENDOR-REGIONLANG LIKE 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 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-2008Page 7

Page 8: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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:

Record #1 Record #2 Record #3 Record #4 Record #5Vendor Number * ABAPxx-001 ABAPxx-002 ABAPxx-003 ABAPxx-004 ABAPxx-005Company Code 0001 0001 0001 0001 0001Account Group 0001 0001 0001 0001 0001Name Vendor001 Vendor002 Vendor003 Vendor004 Vendor005Sort Term ABAP ABAP ABAP ABAP ABAPCity Philadelphia Boston Miami Chicago LondonZip code 19103 02116 33143 60601 SW1 8DLCountry US US US US GBRegion PA MA FL IL LOLanguage E E E E E where ‘xx’ is the last two digits of your logon id

Dec-2008Page 8

Page 9: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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 layout for each record of the file is:CUSTNUM LIKE KNA1-KUNNRNAME LIKE KNA1-NAME1STREET LIKE KNA1-STRASPHONE LIKE KNA1-TELF1FAX LIKE 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.

Dec-2008Page 9

Page 10: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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-2008Page 10

Page 11: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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 layout for each record of the file is:VENDNUM LIKE YVENDOR-VENDNUMCOMPANY LIKE YVENDOR-COMPANYACCTGROUP LIKE YVENDOR-ACCTGROUPNAME LIKE YVENDOR-NAMESORT LIKE YVENDOR-SORTCITY LIKE YVENDOR-CITYZIPCODE LIKE YVENDOR-ZIPCODECOUNTRY LIKE YVENDOR-COUNTRYREGION LIKE YVENDOR-REGIONLANG LIKE 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.

Dec-2008Page 11

Page 12: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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-2008Page 12

Page 13: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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:

Field DescriptionEnter this value when researching the transaction

Vendor ABAPxx-nnn *Company code 0001 (these are zeroes, not the letter “O”)Account group 0001Name VendorSearch term NUMCity MiamiPostal code 33143Country USRegion FLLanguage 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.

Dec-2008Page 13

Page 14: 7.10_ Data Interfaces Exercises

ECC 6.0Data Interfaces: Exercises SAP Development ABAP Training

‘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.

Dec-2008Page 14

Page 15: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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.

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

Dec-2008Page 15

Page 16: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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: ./ file4xxBatch 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.

Dec-2008Page 16

Page 17: 7.10_ Data Interfaces Exercises

ECC 6.0Data Interfaces: Exercises SAP Development ABAP Training

The layout for each record of the file is:VENDNUM(16) TYPE CNAME(30) TYPE CSORT(20) TYPE CCOUNTRY(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. 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.

Dec-2008Page 17

Page 18: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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.

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 CNAME(30) TYPE CSORT(20) TYPE CCOUNTRY(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-2008Page 18

Page 19: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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”)?

Do not code this “CALL DIALOG” program.

Dec-2008Page 19

Page 20: 7.10_ Data Interfaces Exercises

ECC 6.0Data 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

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?

Dec-2008Page 20