Skip to Content
0
Former Member
Mar 31, 2011 at 08:11 AM

Aggregation with FOR ALL ENTRIES (I know it's not possible, but...)

2151 Views

Hi Experts,

I try to tune a statement on a big table by removing it from a LOOP (50.000 statement calls)

The SELECT list contains a complicated aggregation that I want ro reuse somehow.

Old code:

Loop at datapackage assigning <f-dp> .
       Select single  
            soursystem
            doc_number
            s_ord_item.
            Max(i2) Max(i3) Min(date) Max(date) Sum(qty) Min(lt1) ....  and  alot of others....
         INTO 
           (wa-soursystem,
            wal-doc_number,
            wa-s_ord_item, 
         ....)
           from  /bic/abh_dso
          WHERE
            soursystem = <f_dp>-soursystem AND
            doc_number = <f_dp>-doc_number AND
            s_ord_item = <f_dp>-s_ord_item 
    GROUP BY
            soursystem
            doc_number
            s_ord_item.

...

Endloop.

The table datapackage (50.0000 rows) can be used with a For all entries to filter the rows in

only a few calls (depending on FAE configuration) from the DB table into an internal table RES_TAB

wich has (of course) the detailed records.

BUT I want to reuse the aggregation used in the statement SELECT list - wich is not allowed for a FAE.

but I guess it's a pain to rebuilt the aggregation with the internal table and could be really annoying

and source code would be really hard to understand (wich isn't when using the SELECTs aggregations).

Is there any clue HOW avoid that ?