10-12-2006 4:54 PM
Hi Friends,
I want to read a record by record through my final internal table, can any one please send me the code for that.
Thanx in advance,
Venu.
10-12-2006 4:58 PM
Hi,
Use LOOP AT to read the records in the final internal table..
LOOP AT IT_FINAL..
ENDLOOP.
Thanks,
Naren
10-12-2006 4:56 PM
Hi
You can loop at the itab right.
loop at itab into wa_itab
logic
endloop.
or if you want to read
DESCRIBE TABLE itab lines count.
cnt = 1.
Do count times.
READ TABLE itab into wa_itab index count.
Logic you want...
cnt = cnt + 1.
ENDDO.
Hope this is what you want
10-12-2006 4:58 PM
Hi,
Use LOOP AT to read the records in the final internal table..
LOOP AT IT_FINAL..
ENDLOOP.
Thanks,
Naren
10-12-2006 4:59 PM
Hi
I don't understand what you need:
Read the records of internal table: use LOOP/ENDLOOP or READ TABLE statament:
LOOP AT ITAB.
ENDLOOP.
or
DO.
READ TABLE ITAB INDEX SY-INDEX.
IF SY-SUBRC <> 0. EXIT. ENDIF.
ENDDO.
You need to read a record using e record of the same table:
DATA: WA LIKE ITAB.
LOOP AT ITAB.
READ TABLE ITAB INTO WA WITH KEY ....
ENDLOOP.
Max
10-12-2006 5:09 PM
Hi Max,
I have coded it like this but it is not working.
LOOP AT lt_final INTO lw_final.
READ TABLE lt_final INTO lw_final WITH KEY delnum = lw_final-delnum.
IF sy-subrc = 0.
can you tell me what is error in this.
Regards,
Venu.
10-12-2006 5:14 PM
Hi
You have to use another workarea:
DATA: LW_FINAL2 LIKE LW_FINAL.
LOOP AT lt_final INTO lw_final.
READ TABLE lt_final INTO lw_final2 WITH KEY delnum = lw_final-delnum.
IF sy-subrc = 0.
But you risk to obtein the same record, try this:
DATA: LW_FINAL2 LIKE LW_FINAL,
TABIX TYPE SY-TABIX.
LOOP AT lt_final INTO lw_final.
TABIX = SY-TABIX.
LOOP AT lt_final INTO lw_final2
WHERE delnum = lw_final-delnum.
IF SY-TABIX <> TABIX.
EXIT.
ENDIF.
ENDLOOP.
IF LW_FINAL2 <> LW_FINAL.
Max
10-12-2006 5:23 PM
Hi Venu,
U r looping and reading the same table which does not make any sense.
pl find eg below:
loop at t_table1 into lw_table1 .
read table t_table2 with
key <field name>=lw_table1-Field name.(if require)
if sy-subrc = 0.
write Logic
else.
write Logic
endif.
endloop.
Cheers.
10-12-2006 5:01 PM
use
loop at itab.
endloop.
a better way if you are sure that you need only specific data, then use 'where' along with the loop.
loop at itab where<condition>.
<code>
endloop.