Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

Tags:
Former Member
Former Member replied

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.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question