‎2007 Aug 26 1:30 PM
I have two internal tables IT_A and IT_B.
IT_A contains fields as P, Q, R and IT_B contains fields Q,R.
The contents are
IT_A
P Q R
P1 q1 r1
P2 q2 r1
P3 q3 r2
P4 q4 r1
P4 q4 r2
And that of IT_B is
Q R
q1 r1
q1 r2
q2 r1
q3 r1
q4 r1
I want to find all the values of IT_A with respect to IT_B which are not common. The output should be P3 and P4.
Could you please help me out!!!!
‎2007 Aug 26 4:51 PM
Hi Pravin,
try this with help ogf sorted table.:
data:
it_b_sort like table of it_b with unique key q r.
it_b_sort = it_B[].
loop at it_a.
read table it_b_sort with table key q = it_a-q r = it_a-r.
if sy-subrc = 0.
write: 'This is not common'.
endif.
endloop.
Regards,
Clemens
‎2007 Aug 26 1:36 PM
Hi pavin,
select * from itab for all entries in itab1 where <condition>.
try this.
reward if useful.
kishore
‎2007 Aug 26 1:45 PM
Reading your question as "I want all entries in IT_A that do not have an entry in IT_B" then you could try (not syntax checked):
sort IT_B by q r. "for binary search
loop at IT_A. "assume header line
read table it_b
with key q = it_a-q
r = it_a-r
binary search
transporting no fields.
if not sy-subrc is initial.
write: / 'No IT_A entry in IT_B for', it_a-p, it_a-q, it_a-r.
endif.
endloop.
‎2007 Aug 26 4:51 PM
Hi Pravin,
try this with help ogf sorted table.:
data:
it_b_sort like table of it_b with unique key q r.
it_b_sort = it_B[].
loop at it_a.
read table it_b_sort with table key q = it_a-q r = it_a-r.
if sy-subrc = 0.
write: 'This is not common'.
endif.
endloop.
Regards,
Clemens
‎2007 Aug 26 6:53 PM
Thanks a lot Clemens !!!!!!!!!!
I put in the code and it worked. Appreciate your help..
Cheers!!!
Pravin
‎2007 Aug 27 11:37 AM
... but not exactly. Should have been
read table it_b_sort transporting no fields with table key q = it_a-q r = it_a-r.
Regards,
Clemens
Thanks anyway!