Skip to Content
avatar image
Former Member

SYNTAX FOR READING INTERNALTABLE

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 22, 2007 at 09:46 AM

    HI pavan,

    It need not be a primary key

    <b>

    Regards,

    Azhar</b>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 22, 2007 at 09: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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 22, 2007 at 09: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 22, 2007 at 09:50 AM

    Hi ,

    No need to have primary key

    Regards,

    nagaraj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 22, 2007 at 09:53 AM

    Hello,

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

    regards,

    LIJO

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 22, 2007 at 09: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>

    Add comment
    10|10000 characters needed characters exceeded