Hi Lars,
basically we get a lot of external data into the system. We load these data every 5 min and in peak periods we need to be able to handle 25.000 received records within the 5 min slot.
The external data contains some key component that I use in the SQL the where clause, namely a so called Trade ID (basically a sort of customer number), a material number and a controlling date.
Now for each of these records (based on trade id, material and controlling date) I need to find the latest billing item available (need to perform some joins to get there in order to get only based on a certain sales order type etc.).
But basically, if could use below statement for each of the external data records I receive - however that will be 25.000 calls toward the HANA every 5 min and I guess that is insufficient as well (ok, my current approach seems to be insufficient as well).
As you see it is TOP 1 selection (I only need to first record returned - there might actually be many records but I do only need the first one - I know I only need the first one due to the order by clause). I have high lighted the controlling parts, namely the trade id, the material and a controlling date that is to be used to find the billing data I need to get for a external record received.
I dont know if there is a smarter way to do it than what I do today - the problem with my current SQL (shown below - I pass on 25.000 records at a time in a for all entries statement) is that it returns WAY more records than I need. I basically just need the first record for each Trade ID, Material, Controlling date conbination I prove in the gi_material internal table.
IF gi_material IS NOT INITIAL.
SELECT b~bill_num b~bill_item b~bill_date b~doc_currcy
b~material
t~/bic/trade_id c~/bic/cushier6 c~cust_sales
b~netval_inv b~bill_qty c~datefrom c~dateto
INTO CORRESPONDING FIELDS OF TABLE lt_temp_table
FROM /bic/ansd300000 AS b
INNER JOIN /bi0/mcust_sales AS c
ON b~sold_to EQ c~cust_sales
INNER JOIN /bic/mtrade_id AS t
ON c~/bic/cushier6 = t~/bic/cushier6
INNER JOIN /bic/ansd260000 as o
on b~doc_number EQ o~doc_number
FOR ALL ENTRIES IN gi_material
WHERE t~/bic/trade_id EQ gi_material-tradeid AND
b~bill_type EQ 'ZF2' AND
o~doc_type EQ 'ZOR' AND
b~material EQ gi_material-material AND
c~dateto GE gi_material-date1 AND
b~bill_date LE gi_material-date1.
ENDIF.