Sample Program On COLLECT Keyword / Statement - 3 (Performance Analysis).



Submitted By: Shilpa Gunjan (LnT Infotech)

This sample code on collect keyword will help to give an insight on performance analysis. In this case a sorted internal table is used.

SAMPLE CODE:

REPORT ztest.

TYPES: BEGIN OF x_mara,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
brgew TYPE meng15,
ntgew TYPE meng15,
END OF x_mara.

DATA: it_mara TYPE SORTED TABLE OF x_mara WITH NON-UNIQUE KEY mtart matkl WITH HEADER LINE.

DATA: v_runtime1 TYPE i,
v_runtime2 TYPE i,
v_final TYPE i.

DATA: v_lines TYPE sy-tabix.

GET RUN TIME FIELD v_runtime1.

SELECT mtart matkl brgew ntgew
FROM mara
INTO it_mara .
COLLECT it_mara.
ENDSELECT.

DESCRIBE TABLE it_mara LINES v_lines.

DELETE ADJACENT DUPLICATES FROM it_mara COMPARING mtart matkl.
DELETE it_mara WHERE ( brgew IS INITIAL ) AND ( ntgew IS INITIAL ).
DESCRIBE TABLE it_mara LINES v_lines.

GET RUN TIME FIELD v_runtime2.
v_final = v_runtime2 - v_runtime1.

WRITE: 'Total No. Of rows In This Report: '.
WRITE: v_lines.
WRITE:/ 'Total Time Taken To Execute the program (in ms)'.
WRITE: v_final.
WRITE: / 'Summation Of Gross weight & Net weight For Same Material Type & Material group.'.
WRITE: /.

LOOP AT it_mara.
WRITE:/ it_mara-mtart,
it_mara-matkl,
it_mara-brgew,
it_mara-ntgew.
ENDLOOP.


OUTPUT:


Compare the result with the previous sample program. You will find a huge difference. Hence it can be concluded that standard internal table is much better than using sorted internal table in such cases.



ALSO READ:

- COLLECT Keyword - Introduction, Syntax & It's Importance.

- Sample Program On COLLECT Keyword / Statement - 1 (Standard Internal Table).


- Sample Program On COLLECT Keyword / Statement - 2 (Performance Analysis).


- Sample Program On COLLECT Keyword / Statement - 3 (Performance Analysis).



Your suggestions and comments are welcome in this section.

Please mail all your contributions to administrator@abapmadeeasy.com We request you to mention your Name, Designation, Experience & Organization you are working for. Your posts will be verified and posted in this site with your name.