
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Exit for when condition is met
Hi guys,
I'm loading n xml files into QV and searching for a string (which is in an auxiliary table) in a field from these xml.
The problem is that I need to stop searching for the string when I first find it, which would be something like 'exit for', and jump to the next file. Any ideas?
Tried EXIT FOR when Len(nr_liq)>0 but no luck
Thanks!
LET NumRows=NoOfRows('Criteria');
FOR each FILE in filelist (Root&'\*.xml')
FOR i=0 to $(NumRows)-1
LET vTexto=Peek('TEXTO',$(i),'Criteria');
LET vCaract=Peek('CARACT',$(i),'Criteria');
xml:
//NFe_mod1:
LOAD
Trim(Replace(Mid([NFe/infNFe/infAdic/infCpl],Index([NFe/infNFe/infAdic/infCpl],'$(vTexto)'),$(vCaract)),'$(vTexto)','')) as nr_liq,
Num(replace([NFe/infNFe/total/ICMSTot/vNF],'.',','),'#.##0,##') as vlr_xml0,
[NFe/infNFe/emit/CNPJ] as CNPJ,
FileName([FILE]) as nome_arquivo
FROM [$(FILE)](XmlSimple, Table is [nfeProc])
WHERE Index([NFe/infNFe/infAdic/infCpl],'$(vTexto)')<>0;
//NFe_mod2:
LOAD
Trim(Replace(Mid([infNFe/infAdic/infCpl],Index([infNFe/infAdic/infCpl],'$(vTexto)'),$(vCaract)),'$(vTexto)','')) as nr_liq,
Num(replace([infNFe/total/ICMSTot/vNF],'.',','),'#.##0,##') as vlr_xml0,
[infNFe/emit/CNPJ] as CNPJ,
FileName([FILE]) as nome_arquivo
FROM [$(FILE)](XmlSimple, Table is [Nfe])
WHERE Index([infNFe/infAdic/infCpl],'$(vTexto)')<>0;
****Exit For would be here*****
NEXT
NEXT FILE


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Claudio,
There's the exit for statement inside the for command, see the link For..next ‒ QlikView
For counter = expr1 to expr2 [ step expr3 ]
[statements]
[exit for [ ( when | unless ) condition ]
[statements]
Next [counter]
Felipe.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The reason for your exit for is not working because "nr_liq" is a Field and
the condition EXIT FOR when Len(nr_liq)>0 will not see the field nr_liq as it is not accessable out side the load statement.
You will have to use Peek function to get a record value
hth
Sasi
