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 reading

Former Member
0 Kudos
109

Hi,

I have some data in my internal table.

Now my requirement is to read the table ITAB based on index as well as where clause.

So anybody will pls tell me how to code for the above requirement.

Pls tell me asap.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
90

check whether it works...

read table itab index n.

if sy-subrc eq 0.

if itab-xxx = aaa.

.

.

else.

..

.

endif.

endif.

10 REPLIES 10

Former Member
0 Kudos
90

hi,

1.............

U can use the statement

READ ITAB INDEX 2.

Here 2 is the index for which u want to read the value in ITAB

2...........

go through this document & Syntaxes

Read an internal table

- READ TABLE itab. / READ TABLE itab INTO wa.

Read a list line

- READ LINE lin.

- READ LINE lin OF CURRENT PAGE.

- READ LINE lin OF PAGE pag.

- READ CURRENT LINE.

Read a program

- READ REPORT prog INTO itab.

Read text elements

- READ TEXTPOOL prog ...INTO itab ...LANGUAGE lg.

Read a file

- READ DATASET dsn INTO f.

Read a database table

- READ TABLE dbtab.

Determine calendar information

- In R/2: READ CALENDAR.

read table <Intenal Table Name> index <line number>.

pls reward if it helpful

Thanks

Vana

Former Member
0 Kudos
90

Hi Neha,

You cannot use both at a time. because when you give index you mean specific record ( position).

Ex for where:

READ TABLE html_viewer_tab

WITH KEY table_line->parent = container

INTO html_viewer.

Ex for index:

READ TABLE sflight_tab INDEX sy-index INTO sflight_wa.

Regds,

Younus

<b>Reward Helpful Answers!!!</b>

Former Member
0 Kudos
90

Hi,

You can directly pur your where condition while looping the itab.

see this:

Loop at itab where <Condition>. "So that only those records are looped.

........" Now read stmt.

READ TABLE itab INDEX sy-tabix.

.........

endloop.

Hope this info helps.

Regards,

Kumar.

Former Member
0 Kudos
91

check whether it works...

read table itab index n.

if sy-subrc eq 0.

if itab-xxx = aaa.

.

.

else.

..

.

endif.

endif.

former_member588853
Active Contributor
0 Kudos
90

You can loop if you need to read all the data from internal table

else if you need to fetch a particular row depending on the conditions then you can user READ statement

1.Loop at itab into wa.

write : wa.. " WA contains the data

endloop.

2.

READ table ITAB into wa with key f1 = 'xx'

you can read Table with either index or with some keys both are not possible..

as per your requirement..

READ TABLE ITAB into wa index 'N'.

if sy-subrc = 0.

Now you can compare your fields

if wa-matnr = 'xx'.

write: / wa

endif.

endif.

rewards if useful

regards

nazeer

Message was edited by:

nazeer shaik

Former Member
0 Kudos
90

Hi,

Please refer to following link

Regards

Bala

Former Member
0 Kudos
90

hai neha ,

You can directly put your where condition while looping the itab.

Former Member
0 Kudos
90

you can do like this...

loop at itab where <..your where condition>.

if sy-tabix = <your value>.

<do something>

else.

continue.

endif.

endloop.

regards

shiba dutta

Former Member
0 Kudos
90

Hi Neha,

Refer this code :

Loop at itab where <condition>.

Read table itab index sy-tabix.

endloop.

Regards,

Hemant

Former Member
0 Kudos
90

hi neha,

Now my requirement is to read the table ITAB based on index as well as where clause.

So anybody will pls tell me how to code for the above requirement.

using read statement you can read data from internal table to work area as

read table [tablename] into [workarea] with index [indexno].

ex: read table itab into wa_itab

or

read table itab into wa_itab with key field = 'fieldname'

helpful reward some points.

with regards,

suresh babu aluri.