Insert data into sorted table

Insert data into sorted table

With a sorted table, it is not possible to use statement APPEND to add line in a table.
APPEND will resquest to add the line at the end, which will perturbate the sort of table.
Use statement INSERT, which will automatically manage in which index will be inserted the line.

Use this code:


  DATA : li_table TYPE SORTED TABLE OF ts_structure WITH NON-UNIQUE KEY key_field,
         ls_table TYPE ts_structure.

  INSERT ls_table INTO TABLE li_table.

 

Search tag: table triée, insérer

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply