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: 

Reading an internal table by index

Former Member
0 Kudos

Hi.

Is it possible in ABAP Programming to read an internal table by is index?

For example in JAVA we can do something like that:

var = my_table[index];

How can we access data by specifying the row we need in ABAP?

Thanks for your help.

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos

read table itab index <line number>.

is the syntax.

Regards,

Ravi

5 REPLIES 5

former_member181962
Active Contributor
0 Kudos

read table itab index <line number>.

is the syntax.

Regards,

Ravi

Former Member
0 Kudos

Yes,

READ TABLE ITAB INDEX N.

N Being the index number.

REgards,

Ravi

Note : Please close the post if the question is answered

Former Member
0 Kudos

Hai Helder

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>.

thanks & Regards

Sreenivasulu P

Former Member
0 Kudos

Hi helder,

1. Simple

2. Read TABLE ITAB INDEX 5.

regards,

amit m.

Former Member
0 Kudos

HI

GOOD

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.

FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.

DO 4 TIMES.

LINE-COL1 = SY-INDEX.

LINE-COL2 = SY-INDEX ** 2.

INSERT LINE INTO TABLE ITAB.

ENDDO.

READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.

<FS>-COL2 = 100.

LOOP AT ITAB INTO LINE.

WRITE: / LINE-COL1, LINE-COL2.

ENDLOOP.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm

THANKS

MRUTYUN