Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
kira_whopper
Creator
Creator

For each Semantic Error over QlikView versions

Hi there,

I'm experiencing a problem with QlikView 12 from SR3 to SR6.

Inside SR3, I'm running the following code:

FOR Each vYear in DirList('$(vSourceBacklog)Reports\*')

TRACE Lendo pasta: $(vYear);

FOR Each vMonth in DirList('$(vYear)\*')

TRACE Lendo pasta: $(vMonth);

FOR Each vExport in FileList('$(vMonth)\closed_requests_*.xlsx')

// Some code here

NEXT vExport;

NEXT vMonth;

NEXT vYear;

This runs perfectly fine, but when I open it on SR6 I get the following error:

Semantic error

The control statement is not correctly matched with its corresponding start statement

NEXT vExport

If I click "Ok" on the error message, it goes out of the For Each showing the same error for vMonth and vYear.

The only difference I noticed from both QlikView versions is that inside SR6 script, variables are not gray italic anymore (images attached).

Any thoughts?

7 Replies
vunguyenq89
Creator III
Creator III

That piece of script works fine in QV 12.20 SR7, might be a bug in some versions.

Upgrading QV should resolve the issue

Kalmer
Partner - Creator
Partner - Creator

Maybe that version does not like the variable in the end of NEXT.
have you tried just "next"
If i'm not mistaken, it dosen't even need the ";".

FOR Each vYear in DirList('$(vSourceBacklog)Reports\*')

TRACE Lendo pasta: $(vYear);

FOR Each vMonth in DirList('$(vYear)\*')

TRACE Lendo pasta: $(vMonth);

FOR Each vExport in FileList('$(vMonth)\closed_requests_*.xlsx')

// Some code here

NEXT

NEXT

NEXT

In my experience semantic error can also happen sooner than the script error actually occurs (even if it says "occured near next vExport").

Make an alternative app and just run this part of script to be sure it's none of the other next in any other part of the code.

kira_whopper
Creator
Creator
Author

Hello, thanks for the response.

The current version is actually QV 12.20.20700.0 SR6, downloaded today from: https://www.qlik.com/us/try-or-buy/download-qlikview

But the issue occurs on it.
And running on QV12 SR3 or QV11 SR12 goes ok.

kira_whopper
Creator
Creator
Author

Based on https://help.qlik.com/pt-BR/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptControlS...

you're actually correct, but even changing the sintax, the issue remains.

I tried to remove the internal loops (vExport and after, vMonth) and the external loops (vYear and after, vMonth), but it was no go.

While changing the syntax, it gives the same error informing only the "Next" statement without the variable in front of it.

My confusion here is that it runs fine on other QlikView version on the same computer without changing anything on the file.

kira_whopper
Creator
Creator
Author

I have QV12 12.10 SR9 and it works fine there too.

Kalmer
Partner - Creator
Partner - Creator

Sorry, if that seems to be the issue then i suggest you to upgrade the QV version.
Because trying to solve this with a work-around is not a best practice.
But never-the-less you can try another work-around:

SET ERRORMODE = 0;

*Your script here*

SET ERRORMODE = 1;

If it loads the data, then your problems are solved. Even if you upgrade it later the errorscript won't be an issue since the code in other versions is working flawlessly. If not, i would upgrade.


Good luck!

jonathandienst
Partner - Champion III
Partner - Champion III

The problem could lie inside the inner loop. Something like an If without an End If. This might be reported as an invalid Next, even though the Next is not causing the problem.

I would not recommend simply hiding the error until you know exactly why the error is occurring. If you are certain that it is a bug, upgrading would be a better option than hiding the error.

In recent versions, Qlik has tightened the semantic checks, so minor issues which the parser ignored are throwing errors now. See the September 2017 release notes for more information on this.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein