Posts

Showing posts with the label abap insert into sorted table

SAP ABAP - Sorted Internal Table With INDEX Access (With Example)

Submitted By: Shilpa Gunjan (L&T Infotech) Here's an example on sorted internal table using INDEX access. This example will help you to understand how to improve performance using Sorted Internal Tables. REPORT z_internal_table_test. *Sorted Internal Table (Performance) TYPES: BEGIN OF x_marc, matnr LIKE marc-matnr, werks LIKE marc-werks, pstat LIKE marc-pstat, flag TYPE c, END OF x_marc. *Internal Table Declaration DATA: it_marc TYPE SORTED TABLE OF x_marc WITH NON-UNIQUE KEY werks. * Table Workarea Declaration DATA: wa_marc TYPE x_marc. * Variable Declaration DATA: v_counter TYPE i, v_runtime1 TYPE i, v_runtime2 TYPE i, v_tabix LIKE sy-tabix. SELECT matnr " Material Number werks            " Plant pstat               " Maintenance status FROM marc INTO TABLE it_marc. GET RUN TIME FIELD v_runtime1. READ TABLE it_marc INTO wa_marc WITH KEY werk...

SAP ABAP - Sorted Internal Table With Key Access (With Example)

Submitted By: Shilpa Gunjan (L&T Infotech) Here's an example on sorted internal table to verify it's performance. REPORT z_internal_table_test. *Sorted Internal table (Performance) TYPES: BEGIN OF x_marc, matnr LIKE marc-matnr, werks LIKE marc-werks, pstat LIKE marc-pstat, flag TYPE c, END OF x_marc. *Internal Table Declaration DATA: it_marc TYPE SORTED TABLE OF x_marc WITH UNIQUE KEY matnr werks. * Table Workarea Declaration DATA: wa_marc TYPE x_marc. * Variable Declaration DATA: v_counter TYPE i, v_runtime1 TYPE i, v_runtime2 TYPE i, v_tabix LIKE sy-tabix. SELECT matnr       " Material Number werks                     " Plant pstat                       " Maintenance status FROM marc INTO TABLE it_marc. GET RUN TIME FIELD v_runtime1. LOOP AT it_marc INTO wa_marc WHERE werks EQ '1501'. ADD 1 TO v_counter. ENDLOOP. GET ...