You are on page 1of 10

ABAP Basics

Internal Tables
ABAP Basics – Internal Tables

Create the following programs using ABAP Workbench tool


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 Customer City


number name
C001 JOHN NEW YORK
C002 MIKE LONDON
C003 ARNOLD MINNESOTA

c. Get the following output using the internal table.


C002 MIKE LONDON
C003 ARNOLD MINNESOTA
C001 JOHN NEW YORK

2.
a. Create an internal table to store the following data.

Customer Customer Amount


number name
C001 JOHN 5000
C002 MIKE 2000
C003 ARNOLD 2000
C002 MIKE 2000
C001 JOHN 1000
C003 ARNOLD 3000

b. Get the following output.

C001 JOHN 6000


C002 MIKE 4000
C003 ARNOLD 5000

3.

a. Create an internal table to contain the following purchase details and populate
the internal table.

Purchase Customer Quantity Customer


order number number name
6001 C001 10
6002 C002 20
6003 C003 15

b. Create an internal table to contain the following customer details and populate
the internal table.

- Page 1 of 9 -
ABAP Basics – Internal Tables

Customer Customer City


Number name
C001 JOHN NEW YORK
C002 MIKE LONDON
C003 ARNOLD FLORIDA

c. Process the internal tables and get the following output from Purchase details
table (only).

6001 C001 10 JOHN


6002 C002 20 MIKE
6003 C003 15 ARNOLD

4. Create an internal table to contain the following data and populate it:

Airline Flight Flight Date


Carrier id Connection id
AA 0017 12.12.1999
DL 1984 06.05.2000
AA 0026 04.08.1999
UA 0941 11.11.2000
LH 1699 01.02.2000
LH 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.

5. Create an internal table and populate the following data in it.

Airline Flight Seats Max


Carrier id Connection id Occupied Seats
AA 0017 200 200
DL 0009 100 150
AA 0017 200 200
DL 0009 100 150
UA 1914 300 300
LH 0941 195 200
UA 1914 300 300
LH 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 150
DL 0009 100 150
UA 1914 300 300
UA 1914 300 300

- Page 2 of 9 -
ABAP Basics – Internal Tables

b. Process the internal table to get the following output.


AA 0017 200 200
DL 0009 100 150
LH 0941 195 200
UA 1914 300 300

6.
a. Create an internal table to contain the following data and populate it.

Employee number Employee name Salary


E001 MADHAVI 5000
E002 SEEMA 2000
E003 GEETA 3000
E001 MADHAVI 2500
E002 PRANATHI 2000
E003 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).

7.
a. Create a nested internal table to contain the following data and populate it.

Student Id Student Name Subject Marks


001 RAVI HINDI 55
ENGLISH 65
MATHEMATICS 80
PHYSICS 60
CHEMISTRY 72
002 RADHA HINDI 30
ENGLISH 39
MATHEMATICS 67
PHYSICS 35
CHEMISTRY 56
003 RAMA HINDI 78
ENGLISH 84
MATHEMATICS 99
PHYSICS 89
CHEMISTRY 90
004 RAMESH HINDI 45
ENGLISH 39
MATHEMATICS 38
PHYSICS 53
CHEMISTRY 67

- Page 3 of 9 -
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.

8.
a. Create an internal table to hold the following data.

Airline Flight Maximum Seats


Flight date Plane type
carrier ID connection ID capacity occupied
LH 400 02/28/1995 A319 350 100
LH 400 02/28/1996 A319 350 100
LH 400 02/28/2001 A319 350 100
LH 400 12/01/2001 A319 150 100

b. Display the contents of the internal table in the following tabular format.

9.
a. Create a field string of the following structure:

- Page 4 of 9 -
ABAP Basics – Internal Tables
Customer number Customer name Amount
C001 JOHN 5000
C002 MIKE 2000
C003 ARNOLD 3000
C004 ADAM 1000
C005 TOM 2000
C006 PATRICK 6000
C007 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,000
C001 JOHN 5,000
C006 PATRICK 6,000
C002 MIKE 2,000
C005 TOM 2,000
C003 ARNOLD 3,000
C004 ADAM 1,000
d. Delete all customers whose amount is greater than 3000 and output the contents
of the internal table.

10. 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 Proficiency


ALTAF 07/02/1961 CLIPPER
ANAND 04/12/1966 PASCAL
JULIANA 01/31/1968 COBOL
KAMALA 10/30/1968 C
MARY 06/24/1970 CPP
NELSON 09/11/1985 COBOL

11. Create an internal table to hold the following data.

EmpNo Ename Department


100 Soha AA
101 Sona CC
102 Soma BB
103 Somi BB
104 Sana BB
105 Sama CC
106 Sima AA
107 Simi BB
108 Suma CC
109 Somu BB
110 Soni AA

- Page 5 of 9 -
ABAP Basics – Internal Tables
a. Without sorting the above internal table display the employees who belong
to the same department together.

12. With out using the COLLECT statement display the output specified in question
#2.

13. Create two internal tables with the same structure and populate them with the
following data.

Contents of the first internal table:

Airline Flight
carrier id connection id
AA 0017
AI 0021
DL 1984
UA 0941
LH 1699

Contents of the second internal table:

Airline Flight
carrier id connection id
AA 0017
DL 1984
LI 0263
LH 1699

Store all the records that are present in only one of the above internal tables, in
another internal table, as follows:

Airline Flight Table row


carrier id connection id
AI 0021 A2
UA 0941 A4
LI 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.

14. Create two internal tables with the following structures and populate them as
follows:
Cust Id Name Hno Street City State Pin
1001 Rajesh 12 Wellington Road Hyd AP 500033
1002 Dravid 103 Arlington Road AP 500026
1003 Sachin 99 Gandhi Marg Secd AP 500021

- Page 6 of 9 -
ABAP Basics – Internal Tables

Cust Id Item
1001 P0001
1001 P0002
1001 P0003
1001 P0004
1001 P0005
1001 P0006
1001 P0007
1002 P0001
1002 P0002
1003 P0001
1003 P0002
1003 P0003
1003 P0004

Display the data in the following format:


Customer Address Items

1001 Rajesh P0001


12 Wellington Road P0002
Hyd P0003
A.P – 500033 P0004
P0005
P0006
P0007
1002 Dravid P0001
103 Arlington Road P0002
AP – 500026

1003 Sachin P0001


9 Gandhi Marg P0002
Secd P0003
AP - 500021 P0004

15. Create an internal table with the following structure:

Emp Id Dept No Emp name Designation Salary


E001 10 Rama Clerk 3000
E002 20 Reema Manager 25000
E003 20 Roma Accountant 4000
E004 10 Reshma Manager 35000
E005 20 Ria Clerk 2000
E006 10 Raksha Accountant 5000
E007 10 Rani Clerk 3000

- Page 7 of 9 -
ABAP Basics – Internal Tables
Output the contents of the internal table in the following format:

Dept No

Emp name Designation Salary

10
Rama Clerk 3000
Reshma Manager 35000
Raksha Accountant 5000
Rani Clerk 3000

Total number of Employees in department 10: 4

20
Reema Manager 25000
Roma Accountant 4000
Ria Clerk 2000

Total number of Employees in department 20: 3

16. Create an internal table to contain the following data:

Material Purchase PO Date Quantity Unit


order
MAT_001 6001 04.03.2002 10 EA
MAT_001 6002 01.19.2002 5 CA
MAT_003 6003 01.19.2002 20 EA
MAT_001 6004 05.10.2002 15 EA
MAT_003 6005 05.08.2002 6 CA
MAT_002 6006 01.30.2002 40 EA
MAT_003 6007 02.24.2002 10 CA
MAT_002 6008 02.24.2002 5 EA

Output the contents of the internal table in the following format:

Material
Purchase order PO Date Quantity Unit

MAT_001
6001 04.03.2002 10 EA
6004 05.10.2002 15 EA
6002 01.19.2002 5 CA

Total quantity ordered 25 EA


5 CA

- Page 8 of 9 -
ABAP Basics – Internal Tables
MAT_002
6006 01.30.2002 40 EA
6008 02.24.2002 5 EA

Total quantity ordered 45 EA

MAT_003
6003 01.19.2002 20 EA
6005 05.08.2002 6 CA
6007 02.24.2002 10 CA

Total quantity ordered 20 EA


16 CA

********************The End*********************

- Page 9 of 9 -

You might also like