2014 Jul 18 12:53 PM
HI,
I have an internal table ITAB with fields HKONT, BELNR, BUZEI & DMBTR. I want a sum of DMBTR for the same HKONT. Is it possible to do thi without looping ?...or Please suggest a better way to do this ?
I will have millions of records in this internal table.
Thanks.
HI,
I have an internal table ITAB with fields HKONT, BELNR, BUZEI & DMBTR. I want a sum of DMBTR for the same HKONT. Is it possible to do thi without looping ?...or Please suggest a better way to do this ?
I will have millions of records in this internal table.
Thanks.
2014 Jul 18 1:02 PM
Hi,
When u volume of data is large & u want sum of dmbtr for individual HKONT, then why u re populating ur ITAB with belnr and buzei,
Use Aggregate function SUM to retrieve data.
Regards
2014 Jul 18 1:03 PM
Hi ,
Use Collect statement..............
or while selecting from database table you can use SUM aggregate function
Regards
Yogendra Bhaskar
2014 Jul 18 1:05 PM
sort the internal table by HKONT and loop at internal table,
in loop u can use
at end of HKONT.
sum.
i don't know if it is possible without using loop.
2014 Jul 18 2:34 PM
Hi,
I guess you will get a problem when populating your internal table with "millions of records" because of the restriction of the main memory. So, I would also suggest using an aggregate function.
If you need the data in the internal table absolutely, you should read the data in packages by using a cursor:
DATA: g_cursor TYPE cursor,
OPEN CURSOR WITH HOLD g_cursor FOR
SELECT ... FROM ...
DO.
FETCH NEXT CURSOR g_cursor
INTO TABLE gt_internal_table
PACKAGE SIZE 1000.
* do something with the internal table
......
IF sy-subrc <> 0.
CLOSE CURSOR g_cursor.
EXIT.
ENDIF.
ENDDO.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |