2005 Dec 21 10:57 AM
Hi all,
I need to check two internal table fields are equal or not means which statement i can use.
Not internal table ,table contents i need to check i.e
it1-pernr = it2-pernr.
like this
if i put loop it'll check one table field for one loop.
if i put two loop means some fields reflecting 2 in it1 then it'll pring 4 times like that.i want to print whatever in internal table only .
pernr(0001) two times there in it1 means
it1-pernr = it2-pernr then
it's printing
0001
0001
0001
0001
like this but actually in it1 only two records.
Anybody know solution.tell me.
Thanks
Regards,
Nandha
2005 Dec 21 11:37 AM
Please,Any body can help me.Any way to get result according to my requirement.
Thanks
Nandha
2005 Dec 21 11:01 AM
Try the following,
loop at itab1.
read table itab2 index sy-tabix.
if itab1-field1 = itab2-field1.
Do something
endif.
endif.
Regards,
Ravi
2005 Dec 21 11:01 AM
Hi,
Loop at itab.
read table itab1 with key pernr = itab-pernr.
...........
...........
endloop.
Here it will read the records from itab1 where pernr equal to looping itab-pernr.
****************
Here in that loop you need to MOVE to another internal table.
With move command move to another internal table and the display from that internal table.
***********
Thanks.
If this helps you reward with points.
Message was edited by: Deepak333 k
2005 Dec 21 11:02 AM
Hi Nadha,
try this..
sort: it1 by pernr, it2 by pernr.
loop at it1.
read table it2 with key pernr = it1-pernr
binary search.
if sy-subrc eq 0.
write: / it1-pernr.
endif.
endloop.
Regards,
Suresh Datti
2005 Dec 21 11:03 AM
loop at it1.
read table it2 with key pernr = it1-pernr.
if sy-subrc <> 0.
record not equal...
endif.
endloop.
2005 Dec 21 11:07 AM
Hi nandha,
1. what i understood is that
u want to print only those pernr
which are EQUAL/EXIST in both tables.
2. If that is so,
that just use one loop.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY PERNR = ITAB1.PERNR.
IF SY-SUBRC = 0.
WRITE ITAB1-PERNR.
ENDIF.
ENDLOOP.
3. NO NEED TO USE 2ND LOOP ON ITAB2.
(BCOS LOOP1 TAKES CARE OF ALL THE COMMON PERNR)
4. If ur requirement is different,
then pls let me know.
Regards,
Amit M.
2005 Dec 21 11:16 AM
I want to check all fields not only one field in one table.
it1 having -- 0001
0001
0002
0003
it2 having--0001
0001
0002
I want to print it1 where it1-ernr equals it2 pernr
like
0001
0001
0002
here 0003 not equal so don't want to print
Thanks
REgards,
Nandha
2005 Dec 21 11:22 AM
Hi Nadha,
Can you give the complete structure of it1 & it2 or paste ur code?
Suresh
2005 Dec 21 11:54 AM
Hi again,
1. can u provide the code.
2. It seems u are missing something very small.
for eg.
READ TABLE ITAB2 WITH KEY PERNR = ITAB1-PERNR.
IF SY-SUBRC = 0. "<--- VERY IMPORTANT.
ENDIF.
regards,
amit m.
2005 Dec 21 11:35 AM
2005 Dec 21 11:37 AM
Please,Any body can help me.Any way to get result according to my requirement.
Thanks
Nandha
2005 Dec 21 11:40 AM
Hi Nandha,
PL refer to my earlier post & pate the code or give the structure for the 2 itabs..
Suresh
2005 Dec 21 11:41 AM
can you just give the structure fields and sample output..
vijay
2005 Dec 21 11:54 AM
Hi,
code for your view
data : begin of it1 occurs 0,
z_pernr like pa9012-pernr,
z_fac_c like pa9012-zz_fac_c,
end of it1.
data : it2 like Zsc1 occurs 0 with header line,
It1 data
pernr FAC C
0001 5555
0001 5555
0002 4444
0003 3333
0006 8888
It2 data
pernr FAC C
0001 5555
0001 5555
0005 6666
0003 3333
output(My code)
loop at it2 .
loop at it1 where pernr = it2-pernr.
write:/01 it1-1pernr,
10 it1-z_fac_c.
endloop.
endloop.
out put i need.
0001 5555
0001 5555
0002 4444
0003 3333
Thanks,
Nandha
2005 Dec 21 11:57 AM
Hi Nandha,
try this,,
sort: it1 , it2 ,
loop at it1.
read table it2 with key pernr = it1-pernr
FAC_C = it1-FAC_C
binary search.
if sy-subrc eq 0.
write: / it1-pernr, it1-fac_c.
endif.
endloop.
2005 Dec 21 11:53 AM
Hi Nandha Kumar,
Instead of printing in the list as soon as you find the answer.
You can follow this...
1. Declare a itab with the result field as it's structure.
2. Check whether itab1-field = itab2-field.
3. If they are equal then
check whether the field is present in the itab.
4. If present don't append it.
5. else append it.
6. At last display the itab contents for the result.
Hope this helps you.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B
2005 Dec 21 12:23 PM
Hi suresh,
Thankyou for the reply.I got result finally.so,i have given full point to you.
Thanks
Regards,
Nandha
2005 Dec 21 12:49 PM
hi,
use the read statement in the loop.
loop at itab1.
read table itab2 with key xyz = itab1-xyz.
if sy-subrc = 0. " Both are matching
endif.
endloop.
Satish
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |