2006 Jun 20 11:26 AM
Dear friends
I am trying to filter the internal table but it gaves me not proper values...
say i have three internal table
itab1 itab2 itab3
id details id details id details
1 ABCD 1 ABCD 2 EFGH
2 EFGH 3 IJKL
3 IJKL
here the above scenario i have main internal table called itab1 which has 3 entries where itab2 has 1 entry. I wish to move all the entry which is not in the itab2 from the itab1.
i have return a code but it gaves me repetative not correct entries... say
1 3 4 are the correct entries.. but after that it gaves me
5 1 2 3 4... in this manner 1 3 4 5 1 2 3 4... instead of this it should 1 3 4 ... please help me to sort out this problem .... any suggestion or code will be greate help of mine... I am giving you my code...
loop at itab_new into wa_itab_new.
loop at itab into wa_itab where id ne wa_itab_new-id.
move-corresponding wa_itab to itab2.
append itab2.
endloop.
endloop.
Regards
Naim
2006 Jun 20 11:40 AM
Hi try this.
loop at itab into wa_itab.
READ table itab_new with key id = wa_itab-id.
IF sy-subrc <> 0.
move-corresponding wa_itab to itab2.
append itab2.
ENDIF.
endloop.
Regards,
Wasim Ahmed
Dear friends
I am trying to filter the internal table but it gaves me not proper values...
say i have three internal table
itab1 itab2 itab3
id details id details id details
1 ABCD 1 ABCD 2 EFGH
2 EFGH 3 IJKL
3 IJKL
here the above scenario i have main internal table called itab1 which has 3 entries where itab2 has 1 entry. I wish to move all the entry which is not in the itab2 from the itab1.
i have return a code but it gaves me repetative not correct entries... say
1 3 4 are the correct entries.. but after that it gaves me
5 1 2 3 4... in this manner 1 3 4 5 1 2 3 4... instead of this it should 1 3 4 ... please help me to sort out this problem .... any suggestion or code will be greate help of mine... I am giving you my code...
loop at itab_new into wa_itab_new.
loop at itab into wa_itab where id ne wa_itab_new-id.
move-corresponding wa_itab to itab2.
append itab2.
endloop.
endloop.
Regards
Naim
2006 Jun 20 11:38 AM
Hi
I believe the problem is in WHERE condition, infact:
if you have 1 2 3 4 5 6 in first table 4 5 6 in second table, in the first loop the system'll load all record not equal to 4 (so 1,2,3,5,6), for the secod loop all record not equal to 5 (so 1,2,3,4,6) and so.....
loop at itab_new into wa_itab_new.
Check all records with ID not equal to NEW_ID
loop at itab into wa_itab where id ne wa_itab_new-id.
Now check if the ID isn't in ITAB_NEW
READ TABLE ITAB_NEW WITH KEY ID = WA_ITAB-ID
TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
Here you're sure this ID isn't in new table
READ TABLE ITAB2 WITH KEY ID = = WA_ITAB-ID
TRANSPORTING NO FIELDS.
IF SY-SUBRC <> 0.
Here you're sure this ID is loaded once
move-corresponding wa_itab to itab2.
append itab2.
ENDIF.
endif.
endloop.
endloop.
max
2006 Jun 20 11:40 AM
Hi try this.
loop at itab into wa_itab.
READ table itab_new with key id = wa_itab-id.
IF sy-subrc <> 0.
move-corresponding wa_itab to itab2.
append itab2.
ENDIF.
endloop.
Regards,
Wasim Ahmed
2006 Jun 20 11:54 AM
try this code it may work.....
itab1-id = 1.
itab1-detail = 'abcd'.
append itab1.
itab1-id = 2.
itab1-detail = 'hhhh'.
append itab1.
itab1-id = 3.
itab1-detail = 'gggg'.
append itab1.
itab1-id = 4.
itab1-detail = 'rere'.
append itab1.
itab2-id = 1.
itab2-detail = 'abcd'.
append itab2.
<b>loop at itab1.
read table itab2 with key id = itab1-id.
if sy-subrc <> 0.
move-corresponding itab1 to itab2.
append itab2.
endif.
endloop.</b>
2006 Jun 20 11:59 AM
Hi,
Do the following
SORT ITAB BY ID.
loop at ITAB_NEW into wa_itab_new.
Now check if the ID is in ITAB or not
READ TABLE ITAB WITH KEY ID = WA_ITAB_NEW-ID
BINARY SEARCH.
IF SY-SUBRC <> 0.
Here you're sure this ID isn't in ITAB
move-corresponding wa_itab_new to itab2.
ENDIF.
endloop.
Sameena
Message was edited by: sameena attarwala
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |