Sample Program On COLLECT Keyword / Statement - 2 (Performance Analysis).
Submitted By: Shilpa Gunjan (LnT Infotech)
This sample code on collect keyword will help to give an insight on performance analysis.
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 standard TABLE OF x_mara 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:
In this case, a standard internal table is used. Also the collect statement uses its own hash algorithm hence the performance is much better. In this case if a sorted internal table is used, the performance will not be that good.
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.