Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have generated yearly QVDs based on the year field present in the file.
Now, i have to store the QVDs prior to 2013 into an archive folder and the QVDs after 2013 in the current folder.
I have used the below code for generating yearly QVDs
temp:
load min(Year) as MinY,
max(Year) as MaxY
resident tab;
let MI= peek('MinY', 0 , 'temp');
let MA= peek('MaxY' , 0, 'temp');
for i= $(MI) to $(MA)
tabtemp:
noconcatenate
load * resident tab where Year=$(i);
store * from tabtemp into ../../Abc_$(i).qvd(qvd)
drop table tabtemp;
How do i modify the above code so that it stores the QVDs prior to 2013 in Archvie folder and the QVDs genertaed after 2013 in another folder.
if $(I) <2013 then
store tabtemp into ..\archive\Abc_$(i).qvd (qvd);
else
store tabltemp into ..\othefolder\Abc_$(I).qvd (qvd);
endif
Hi Marcus,
When i am using if else in the below code,
for i =$(MI) to $(MA)
tabtemp:
noconcatenate
load * resident tab where Year=$(i);
if $(i) >=year(today()) -1 then
store * from tabtemp into ../.. ABC_$(i).qvd(qvd);
else
store * from tabtemp into ../../ABC_$(i).qvd(qvd);
endif
next
In the above case the qvds are getting stored into different folders, but all the QVDs contain the data only for 2012 i.e. the minimum year.
When if else statement is removed it works fine.
ok, in the code above you have a syntax issue on your first store statement
store * from tabtemp into ../.. ABC_$(I).qvd (qvd);
I'd also maybe add a trace statement inside the loop.
Trace $(i);
Just to make sure your MI and MA variables are being set correctly.
But when the if else part is removed from the code, it works perfectly fine...
GHi
Try below
for i =$(MI) to $(MA)
tabtemp$(i):
noconcatenate
load * resident tab where Year=$(i);
if $(i) >=year(today()) -1 then
store * from tabtemp$(i) into ../.. ABC_$(i).qvd(qvd);
else
store * from tabtemp$(i) into ../../ABC_$(i).qvd(qvd);
endif
next
ok possibly an issue on your if condition
Try
if $(i) >= (Year(Today()) - 1) then
also add
drop table tabtemp;
after the endif
Is this now working?
If so, please mark as answered.