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: 

SYNTAX FOR READING INTERNALTABLE

Former Member
0 Kudos

WHEN WE READ AN INTERNAL TABLE WITH THE FOLLOWING SYNTZX LIKE

READ TABLE ITAB WITH KEY K1 = ' '.

SHOULD THE KEY K1 SHOULD NECCESARILY BE PRIMARY KEY ?

IN MY SCENARIO

READ TABLE TKOMV WITH KEY KNUMV = GT_LIKP-KNUMV.

KNUMV IS NOT PRIMARY KEY.

TKOMV IS A TABLE OF TYPE KOMK WHICH IS A STRUCTURE

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI pavan,

It need not be a primary key

<b>

Regards,

Azhar</b>

6 REPLIES 6

Former Member
0 Kudos

The key with which you are reading the table need not be the primary key. In case there are multiple entries with the same value for the same field, then READ statement returns the first matching entry. If no entry is found, sy-subrc is set to 4.

Please mark points if the solution was useful.

Regards,

Manoj

Former Member
0 Kudos

HI pavan,

It need not be a primary key

<b>

Regards,

Azhar</b>

0 Kudos

Hi,

It need not be PRIMARY KEY , WITH KEY is similar to WHERE clause of SELECT statement.

If you want to read using the KEY of the internal table then use WITH TABLE KEY.

Like this

READ TABLE itab into WA WITH TABLE KEY ... .

Regards,

Sesh

former_member404244
Active Contributor
0 Kudos

Hi ,

No need to have primary key

Regards,

nagaraj

Former Member
0 Kudos

Hello,

U can use any key there. It need not be the primary key.

regards,

LIJO

varma_narayana
Active Contributor
0 Kudos

Hi Pawan...

READ TABLE is a statement to Read a Single line from internal Table.

Internal Table will not have any primary key. Only Database table will have it.

So

Read Table <itab> With Key <field> = <value> .

Here the <field> can be any field in the ITAB.

You can Check the Sy-subrc after this statement to know if the Read is successful.

Paste your code if have any problem still...

<b>Reward if Helpful</b>