Application Development and Automation 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: 
Read only

SYNTAX FOR READING INTERNALTABLE

Former Member
0 Likes
822

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
Read only

Former Member
0 Likes
779

HI pavan,

It need not be a primary key

<b>

Regards,

Azhar</b>

6 REPLIES 6
Read only

Former Member
0 Likes
779

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

Read only

Former Member
0 Likes
780

HI pavan,

It need not be a primary key

<b>

Regards,

Azhar</b>

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
779

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

Read only

former_member404244
Active Contributor
0 Likes
779

Hi ,

No need to have primary key

Regards,

nagaraj

Read only

Former Member
0 Likes
779

Hello,

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

regards,

LIJO

Read only

varma_narayana
Active Contributor
0 Likes
779

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>