12-22-2008 4:57 PM
Hi folks,
I have to compare the fields value of f2, f3 in between rows of same internal table. how can I achieve this...Please help me out...
thanks in advance
12-22-2008 5:05 PM
Try something this way
itab_t[] = itab[].
loop at itab.
v_tabix = sy-tabix.
read table itab_t index v_tabix.
if itab_t-f2 = itab_t-f3.
" do your validation.
endif.
endloop.
a®
12-22-2008 5:05 PM
Try something this way
itab_t[] = itab[].
loop at itab.
v_tabix = sy-tabix.
read table itab_t index v_tabix.
if itab_t-f2 = itab_t-f3.
" do your validation.
endif.
endloop.
a®
12-22-2008 5:25 PM
Hi Kartikey,
What exactly is your requirement? Can you be little more specific.
Regards,
Bharati
12-22-2008 7:25 PM
hi,
i need to see that whether the value of f2 field is repeated in any other row or not
Edited by: KARTIKEY SINGH on Dec 22, 2008 8:25 PM
12-22-2008 10:00 PM
Try this way.
Suppose your inernal table has f1,f2,f3...f10 fields.
You want to check whether field f2 is repeated in any of the rows in the table.
t_data1[] = t_data[].
LOOP AT t_data INTO w_data.
LOOP AT t_data1 INTO w_data1 WHERE f2 = w_data-f2.
v_count = v_count + 1.
ENDLOOP.
IF v_count >= 1.
" Your validation
CLEAR: v_count.
ENDIF.
ENDLOOP.
If you dont want to put loop inside loop, try to have the field f2 as first field of the internal table and sort itab by f2. Then loop the table and use At end f2 logic..It will work..
Edited by: Shanthi Kumar Juluru on Dec 22, 2008 11:01 PM
12-23-2008 2:18 AM
Just some changes to Shanthi Kumar Juluru's post
LOOP AT t_data INTO w_data.
LOOP AT t_data INTO w_data1 WHERE f2 = w_data-f2.
if w_data1-f2 = w_data-f2.
v_count = v_count + 1.
endif.
ENDLOOP.
IF v_count > 1.
" f2 column has repeated value
CLEAR: v_count.
exit.
ENDIF.
ENDLOOP.