08-22-2007 10:44 AM
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
08-22-2007 10:46 AM
08-22-2007 10:45 AM
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
08-22-2007 10:46 AM
08-22-2007 10:46 AM
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
08-22-2007 10:50 AM
08-22-2007 10:53 AM
Hello,
U can use any key there. It need not be the primary key.
regards,
LIJO
08-22-2007 10:54 AM
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>