Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

How to write code(logic)

Former Member
0 Kudos

I have one internal table with data

a 1

b 1

c 1

d 2

e 2

and another internal table with data

A 1

B 1

C 2

D 2

E 2

Now my requirement is i want to combine these 2 tables to get the result like

a 1 A

b 1 B

c 1 -

d 2 C

e 2 D

- 2 E

can anyone tell me how to write the code to get this


Active Contributor
0 Kudos

What have you come up with so far?

Former Member
0 Kudos

data : begin of itab1 occurs 0,

field1 type c,

field2 type c,

end of itab1 .

data : begin of itab2 occurs 0,

field1 type c,

field2 type c,

end of itab2 .

data : begin of itab3 occurs 0,

field1 type c,

field2 type c,

field2 type c,

end of itab3 .

....get the values to itab1 and 2...

loop at itab1.

read table itab2 ignoring case with key field1 = itab1-field1 field2 = itab1-field2 ignoring case .

if sy-subrc = 0.

itab3-field3 = itab2-field1.


itab3-field1 = itab1-field1.

itab3-field2 = itab1-field1.

append itab3.

cleat itab3.

delete itab1.


loop at itab2.

read table itab3 with key field3 = itab2-field1 field2 = itab2-field2 .

if sy-subrc <> 0

itab3-field2 = itab2-fiedld2.

itab3-field3 = itab2-fiedld1.

append itab3.

clear itab3.



Message was edited by:

Arjun Puthuruthy