Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Internal table

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use LOOP AT to read the records in the final internal table..

LOOP AT IT_FINAL..

ENDLOOP.

Thanks,

Naren

7 REPLIES 7

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Use LOOP AT to read the records in the final internal table..

LOOP AT IT_FINAL..

ENDLOOP.

Thanks,

Naren

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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.