Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
Im developing an application where i first produce a list of field values that a later on send to a sub-routine that uses the field value when creating a table.
It works as expected if i do not create a table inside my sub-routine but the peek('fieldname',$(i)) I use to get the field value from the first table to send to the sub-routine only works for i = 0 (or the first peek() used.
Any suggestion that the issue could be?
I've attached a small qv app that shows the issue, setting the last parameter in the sub-routine call to 'Y' breaks the peek(). Setting it to 'N' everything is working as expected (as no table is created inside the sub-routine).
Script:
sub ffs(inputMonth,createTableYN)
trace inside sub-routine month is '$(inputMonth)';
if '$(createTableYN)' = 'Y' then
subTable:
load
'$(inputMonth)' as subMonth
autogenerate 1;
else
endif;
end sub;
months:
load
month(addmonths(yearstart(today()),recNo())) as month
autogenerate 12
;
// by creating a table in the sub-routine call (last parameter = 'Y') the peek will cease to function properly as only first value is fetched
for i = 0 to fieldvalueCount('month')-1
Let vMonth = peek('month',$(i));
call ffs('$(vMonth)','N');
next;
App has been tested in 11.2 SR4 and 11.2 SR6 with the same result.
Br Johan
The Peek() function always fetches data from the latest created table - unless you use the third parameter. So, the solution is probably to use the third parameter:
Let vMonth = peek('month',$(i),'months');
HIC
The Peek() function always fetches data from the latest created table - unless you use the third parameter. So, the solution is probably to use the third parameter:
Let vMonth = peek('month',$(i),'months');
HIC
I guess QlikView Script Engine isn't really re-entrant.
Ouch, what a newbie mistake!
Thanks Henric, and sorry for taking up your time with such simple questions
You probably need a Concatenate, like:
if '$(createTableYN)' = 'Y' then
Concatenate
subTable:
load
'$(inputMonth)' as subMonth
autogenerate 1;