Posts

Showing posts with the label sample program on Collect keyword

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

Image
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)...

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

Image
Submitted By: Shilpa Gunjan (LnT Infotech) This sample code will help you to understand better how collect keyword works or functions. SAMPLE CODE: REPORT zcollect. TYPES: BEGIN OF x_mara, mtart TYPE mara-mtart, matkl TYPE mara-matkl, brgew TYPE mara-brgew, ntgew TYPE mara-ntgew, END OF x_mara. DATA: it_mara type STANDARD TABLE OF x_mara, wa_mara TYPE x_mara. SELECT mtart matkl brgew ntgew FROM mara UP TO 5 ROWS INTO TABLE it_mara WHERE mtart = 'HAWA' AND matkl NE '' AND brgew NE '' AND ntgew NE ''. wa_mara-mtart = 'HAWA'. wa_mara-matkl = 'C01143'. wa_mara-brgew = 100. wa_mara-ntgew = 200. COLLECT wa_mara INTO it_mara. WRITE: / 'Test Program - Collect Keyword - Standard Internal Table. '. LOOP AT it_mara INTO wa_mara. WRITE:/ wa_mara-mtart, wa_mara-brgew, wa_mara-ntgew. ENDLOOP. OUTPUT: Say the five records in the table are: HAWA       P03              100.000     100.000 HAWA ...