04-21-2006 3:11 PM
Hi friends,
I have an Internal table I_tab and j_tab with matnr as a field,
for each entry in I_tab, I need to check j_tab ,is there is repeating matnr in j_tab.
04-21-2006 3:17 PM
hi Karhik,
Use <b>for all corresponding fields of j_tab</b> statement in the select statement
or
sort: l_tab , j_tab.
loop at l_tab.
<b>read table j_tab with key matnr = l_tab-matnr</b>
endloop.
Regards,
Santosh
04-21-2006 3:17 PM
try this..
sort: l_tab,j_tab.
loop at l_tab.
read table j_tab with key matnr = l_tab-matnr
binary search.
if sy-sub rc eq 0.
* entry exists in j_tab.
endif.
endloop.
Regards,
Suresh Datti
04-21-2006 3:18 PM
Hi,
Loop at I_tab.
read table J_tab with key matnr = i_tab-matnr.
if sy-subrc = 0
Success
endif.
endloop.
If you are looking for more than one entry in J_tab ...
Loop at I_tab.
loop at J_tab where matnr = i_tab-matnr.
if sy-tabix = 2
Success
endif.
endloop.
endloop.
Regards,
Ravi
Note : Please close the thread of the issue is resolved.
04-21-2006 3:24 PM
Hi Ravi
You can't check SY-TABIX, because it indicates the number of the record you're elaborating and not how many records (with a certain value) are in the table.
max
04-21-2006 3:18 PM
Hi,
Use the following code.
Loop at I_tab into wa_tab1.
Read table j_tab into wa_tab2
with key matnr = wa_itab1-matnr.
if sy-subrc eq 0.
There is an entry for matnr in both the tables
Do your processing
endif.
endloop.
Hope this helps.
Please reward some points if it helps.
Regards,
Amit Mishra
Message was edited by: Amit Mishra
04-21-2006 3:19 PM
Hi
You need to read j_tab with field MATNR
DATA: COUNT TYPE I.
LOOP AT I_TAB.
COUNT = 0.
LOOP AT J_TAB WHERE MATNR = ITAB-MATNR.
COUNT = COUNT + 1.
IF COUNT > 2. EXIT. ENDIF.
ENDLOOP.
ENDLOOP.
max
04-21-2006 3:19 PM
Hi Kalimuthu,
You can use ABAP command <b>SEARCH itab</b>.
SEARCH itab FOR pattern [IN {BYTE|CHARACTER} MODE]
[STARTING AT idx1] [ENDING AT idx2]
[ABBREVIATED]
[AND MARK].
and check the return value
SY-SUBRC Relevance
0 Pattern found in itab.
4 Pattern not found in itab.
Hope this will help.
Regards,
Ferry Lianto
04-21-2006 3:27 PM
Just to be different...
data: j_tab_temp LIKE j_tab OCCURS 0,
count TYPE i.
LOOP AT i_tab.
j_tab_temp[] = j_tab[].
DELETE j_tab_temp WHERE matnr <> i_tab-matnr.
DESCRIBE TABLE j_tab_temp LINES count.
IF count > 1.
*-- more than one entry exists in j_tab for this MATNR
ENDIF.
CLEAR j_tab_temp[].
ENDLOOP.
04-21-2006 3:38 PM
Have a look at <a href="/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops">this.</a>
Rob
04-22-2006 1:13 PM
Hi Kalimuthu,
You can use the following Logic. I have given the sample code.
DATA : count TYPE i.
SORT i_tab BY matnr.
SORT j_tab BY matnr.
CLEAR count.
LOOP AT i_tab.
LOOP AT j_tab WHERE matnr = i_tab-matnr.
count = count + 1.
IF count GT 1.
"Repeating matnr do your processing here
EXIT.
ENDIF.
ENDLOOP.
CLEAR count. "Clear the count for next matnr in i_tab
ENDLOOP.
Regards,
Arun S.