Skip to Content
avatar image
Former Member

Insert records into Sorted Internal Table

Hi,

I have an SORTED Internal table i_tab. I am inserting records into this table inside a loop as we should not use append records to a sorted table.

The internal table is declared as:

DATA: i_tab TYPE SORTED TABLE OF t_tab WITH NON-UNIQUE KEY matnr.

Insert is used as :

INSERT wa_tab INTO i_tab.

The code is getting activated but its giving a dump on execution.

Should I insert records using the key for sorted table?

Thanks,

Abhishek

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 01, 2008 at 07:20 AM

    Hi ,

    check this..

    DATA: BEGIN OF connection,
    cityfrom TYPE spfli-cityfrom,
    cityto TYPE spfli-cityto,
    distid TYPE spfli-distid,
    distance TYPE spfli-distance,
    END OF connection.
     
    DATA connection_tab LIKE sorted TABLE OF connection
    WITH unique KEY cityfrom
    with header line.
     
    SELECT cityfrom cityto distid distance
    FROM spfli
    INTO connection.
    INSERT connection INTO table connection_tab.  "Add table keyword here
    ENDSELECT.
    loop at connection_tab.
    write: / connection_tab-cityfrom, connection_tab-cityto, connection_tab-distid, connection_tab-distance.
    endloop.
     
    connection-cityfrom = 'Bangalore'.
    connection-cityto = 'Delhi'.
    connection-distid = 'KL'.
    connection-distance = '2500'.
     
    insert connection into table connection_tab .
    loop at connection_tab.
    write: / connection_tab-cityfrom, connection_tab-cityto, connection_tab-distid, connection_tab-distance.
    endloop. 
    

    Regards,

    Omkaram.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 07:22 AM

    hi

    use

    append

    instead of insert and that to be like this

    APPEND wa_itab TO itab SORTED BY matnr.

    Cheers

    Snehi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 09:34 AM

    INSERT wa_tab INTO table i_tab.

    Add comment
    10|10000 characters needed characters exceeded