Hi,
We have requirement to show Number of active customers by Calendar date in reporting. So using Valid From and Valid to we are determining number of Active Customers for the particular calendar date for last two months ( for every date we need to find respective values in view).
For this purpose we are creating Scripted calculation view. But we cannot get full result set we are getting only last loop results. My assumption is this is happening because :table variable is reference and it contains only last result set.
Is it possible to append/insert result set to some temporary table and only then assign to var_out?
Is there other way of achiving this requirement?
Following code is added:
DECLARE lv_analisys_start date;
DECLARE lv_today date;
DECLARE lv_date date;
DECLARE lv_int integer := 0;
DECLARE rowcount integer;
lv_analisys_start := to_date(left(to_dats(now()), 6)-1);
lv_today := current_date;
dates_table = select"DATE_SQL"from"_SYS_BI"."M_TIME_DIMENSION"
where date_sql >= :lv_analisys_start AND date_sql <= :lv_today;
SELECTcount(*) into rowcount from :dates_table;
WHILE :lv_int < rowcount DO
select"DATE_SQL"into lv_date from :dates_table LIMIT 1 OFFSET :lv_int;
table = select"PRDNR", "CITY",
sum(casewhen to_date(left("VALFR",8)) <= lv_date
AND to_date(left("VALTO",8)) >= lv_date then 1
else 0
end) AS"CM_ACTIVE_CUSTOMERS", lv_date asDATE
FROM"_SYS_BIC"."sap.development/CA_CUSTOMER_DATA"
groupby"PRDNR", "CITY";
lv_int := :lv_int + 1;
var_out = select * from :table;
ENDWHILE;
Thanks,
Markus