2.3 abap basics - internal tables
TRANSCRIPT
Exercise 02.03 - ABAP BasicsInternal Tables
Exercise 02.03 - ABAP Basics – Internal Tables
Create the following programs using ABAP Workbench tool
Note: All the following objects to be created should follow a naming convention YEMPID_##$$%%, where ##$$ indicates the exercise number and %% indicates the question number in the exercise (0203 in this case) and EMPID indicates the employee ID.
1.a. Create a field string according to the following structure. b. Create an internal table using the above field string and populate it with the
following data.
Customer number
Customer name
City
C001 JOHN NEW YORKC002 MIKE LONDONC003 ARNOLD MINNESOTA
c. Get the following output using the internal table.C002 MIKE LONDONC003 ARNOLD MINNESOTAC001 JOHN NEW YORK
2.a. Create an internal table to store the following data.
Customer number
Customer name
Amount
C001 JOHN 5000C002 MIKE 2000C003 ARNOLD 2000C002 MIKE 2000C001 JOHN 1000C003 ARNOLD 3000
b. Get the following output.
C001 JOHN 6000C002 MIKE 4000C003 ARNOLD 5000
a. Create an internal table to contain the following purchase details and populate the internal table.
Purchase order number
Customer number
Quantity Customer name
6001 C001 106002 C002 206003 C003 15
- Page 1 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
b. Create an internal table to contain the following customer details and populate the internal table.
Customer Number
Customer name
City
C001 JOHN NEW YORKC002 MIKE LONDONC003 ARNOLD FLORIDA
c. Process the internal tables and get the following output from Purchase details table (only).
6001 C001 10 JOHN6002 C002 20 MIKE6003 C003 15 ARNOLD
3. Create an internal table to contain the following data and populate it:
Airline Carrier id
Flight Connection id
Flight Date
AA 0017 12.12.1999DL 1984 06.05.2000AA 0026 04.08.1999UA 0941 11.11.2000LH 1699 01.02.2000LH 0026 01.29.1977
a. Display the following details from internal table. (Don’t use WHERE clause)AA 0026 04.08.1999
b. Display all the “Lufthansa” flights’ information.c. Display all the flights’ information that are scheduled after 01.05.2000.
4. Create an internal table and populate the following data in it.
Airline Carrier id
Flight Connection id
Seats Occupied
Max Seats
AA 0017 200 200DL 0009 100 150AA 0017 200 200DL 0009 100 150UA 1914 300 300LH 0941 195 200UA 1914 300 300LH 0941 195 200
a. Filter the contents to get the following output. (without using the where clause in the LOOP AT statement).
DL 0009 100 150DL 0009 100 150
- Page 2 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
UA 1914 300 300UA 1914 300 300
b. Process the internal table to get the following output.AA 0017 200 200DL 0009 100 150LH 0941 195 200UA 1914 300 300
5.a. Create an internal table to contain the following data and populate it.
Employee number Employee name SalaryE001 MADHAVI 5000E002 SEEMA 2000E003 GEETA 3000E001 MADHAVI 2500E002 PRANATHI 2000E003 GEETA 6000
b. Display the contents of this internal table.c. Modify the contents of the internal table such that it contains only one record
per employee number and display the contents of the internal table. (Numeric values need not be summed up).
6.a. Create a nested internal table to contain the following data and populate it.
Student Id Student Name Subject Marks001 RAVI HINDI 55
ENGLISH 65MATHEMATICS 80PHYSICS 60CHEMISTRY 72
002 RADHA HINDI 30ENGLISH 39MATHEMATICS 67PHYSICS 35CHEMISTRY 56
003 RAMA HINDI 78ENGLISH 84MATHEMATICS 99PHYSICS 89CHEMISTRY 90
004 RAJESH HINDI 45ENGLISH 39MATHEMATICS 38PHYSICS 53CHEMISTRY 67
- Page 3 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
b. Get the output in the following format: if a student gets less than 40 marks in any subject indicate it.
7.a. Create an internal table to hold the following data.
Airline carrier ID
Flight connection ID
Flight date Plane typeMaximum capacity
Seats occupied
LH 400 02/28/1995 A319 350 100LH 400 02/28/1996 A319 350 100LH 400 02/28/2001 A319 350 100LH 400 12/01/2001 A319 150 100
b. Display the contents of the internal table in the following tabular format.
8.a. Create a field string of the following structure:
- Page 4 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
Customer number Customer name AmountC001 JOHN 5000C002 MIKE 2000C003 ARNOLD 3000C004 ADAM 1000C005 TOM 2000C006 PATRICK 6000C007 ROBERT 12000
b. Create an internal table using this structure and populate it with the above data.c. Display the contents of the internal table as follows:
C007 ROBERT 12,000C001 JOHN 5,000C006 PATRICK 6,000C002 MIKE 2,000C005 TOM 2,000C003 ARNOLD 3,000C004 ADAM 1,000
d. Delete all customers whose amount is greater than 3000 and output the contents of the internal table.
9. Create an internal table to hold the following data. Ensure that there is no include statement or occurs clause in the program. Display the contents of the internal table.
Name of the Programmer Date of birth ProficiencyALTAF 07/02/1961 CLIPPERANAND 04/12/1966 PASCALJULIANA 01/31/1968 COBOLKAMALA 10/30/1968 CMARY 06/24/1970 CPPNELSON 09/11/1985 COBOL
10. Create an internal table to hold the following data.
EmpNo Ename Department100 Soha AA101 Sona CC102 Soma BB103 Somi BB104 Sana BB105 Sama CC106 Sima AA107 Simi BB108 Suma CC109 Somu BB110 Soni AA
- Page 5 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
a. Without sorting the above internal table display the employees who belong to the same department together.
11. With out using the COLLECT statement display the output specified in question #2.
12. Create two internal tables with the same structure and populate them with the following data.
Contents of the first internal table:
Airline carrier id
Flight connection id
AA 0017AI 0021DL 1984UA 0941LH 1699
Contents of the second internal table:
Airline carrier id
Flight connection id
AA 0017DL 1984LI 0263LH 1699
Store all the records that are present in only one of the above internal tables, in another internal table, as follows:
Airline carrier id
Flight connection id
Table row
AI 0021 A2UA 0941 A4LI 0263 B3
For the “table row” column, using A for the first table and B for the second table, concatenate it with the row number of the record in the corresponding internal table.
- Page 6 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
13. Create two internal tables with the following structures and populate them as follows:
Cust Id Name Hno Street City State Pin1001 Rajesh 12 Wellington Road Hyd AP 5000331002 Dravid 103 Arlington Road AP 5000261003 Sachin 99 Gandhi Marg Secd AP 500021
Cust Id Item1001 P00011001 P00021001 P00031001 P00041001 P00051001 P00061001 P00071002 P00011002 P00021003 P00011003 P00021003 P00031003 P0004
- Page 7 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
Display the data in the following format:Customer Address Items
1001 Rajesh P000112 Wellington Road P0002Hyd P0003A.P – 500033 P0004
P0005P0006P0007
1002 Dravid P0001103 Arlington Road P0002AP – 500026
1003 Sachin P00019 Gandhi Marg P0002Secd P0003AP - 500021 P0004
14. Create an internal table with the following structure:
Emp Id Dept No Emp name Designation SalaryE001 10 Rama Clerk 3000E002 20 Reema Manager 25000E003 20 Roma Accountant 4000E004 10 Reshma Manager 35000E005 20 Ria Clerk 2000E006 10 Raksha Accountant 5000E007 10 Rani Clerk 3000
Output the contents of the internal table in the following format:
Dept No
Emp name Designation Salary
10Rama Clerk 3000Reshma Manager 35000Raksha Accountant 5000Rani Clerk 3000
- Page 8 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
Total number of Employees in department 10: 4
20Reema Manager 25000Roma Accountant 4000Ria Clerk 2000
Total number of Employees in department 20: 3
15. Create an internal table to contain the following data:
Material Purchase order
PO Date Quantity Unit
MAT_001 6001 04.03.2002 10 EAMAT_001 6002 01.19.2002 5 CAMAT_003 6003 01.19.2002 20 EAMAT_001 6004 05.10.2002 15 EAMAT_003 6005 05.08.2002 6 CAMAT_002 6006 01.30.2002 40 EAMAT_003 6007 02.24.2002 10 CAMAT_002 6008 02.24.2002 5 EA
Output the contents of the internal table in the following format:
MaterialPurchase order PO Date Quantity Unit
MAT_0016001 04.03.2002 10 EA6004 05.10.2002 15 EA6002 01.19.2002 5 CA
Total quantity ordered 25 EA5 CA
- Page 9 of 10 -
Exercise 02.03 - ABAP Basics – Internal Tables
MAT_0026006 01.30.2002 40 EA6008 02.24.2002 5 EA
Total quantity ordered 45 EA
MAT_0036003 01.19.2002 20 EA6005 05.08.2002 6 CA6007 02.24.2002 10 CA
Total quantity ordered 20 EA16 CA
********************The End*********************
- Page 10 of 10 -