Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Can I use a mapping table created inside a subroutine outside the subroutine?

See the example below:

Sub Mappings

     Codesmap:

     Mapping LOAD * Inline [

     Code, Description

     01, Code 01

     02, Code 02

     03, Code 03

     ];

End Sub

Call Mappings;

Table1:

Load

     Field1,

     Applymap('Codesmap',Field1) as CodeDescription,

     Field2,

     Field3

FROM

[Stuff.xlsx]

(ooxml, embedded labels, table is StuffData);

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

QlikView has no real concept of scope, ...

For tables and fields that may be true. But don't be mistaken: SUBs have a very strict concept of scope. And so do loops. All of them.

View solution in original post

7 Replies
tomasz_tru
Specialist
Specialist

Do you have any problems with that script? It should be working.

Tomasz

Anonymous
Not applicable
Author

My script is more complex than the one I used as an example. Let me check my script again.

Thanks Tomasz.

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Pablo,

QlikView has no real concept of scope, so yes, that would work just fine.

The only proviso, is that obviously you must create your mapping table prior to referencing it!

Marcus

Peter_Cammaert
Partner - Champion III
Partner - Champion III

QlikView has no real concept of scope, ...

For tables and fields that may be true. But don't be mistaken: SUBs have a very strict concept of scope. And so do loops. All of them.

Anonymous
Not applicable
Author

Do you mean that a mapping table created in SUB cannot be used outside the SUB?

marcus_malinow
Partner - Specialist III
Partner - Specialist III

I stand corrected! Thanks for the clarification Peter

Anonymous
Not applicable
Author

I've done this test:

Sub Mappings

     Codesmap:

     Mapping LOAD

     Code, Description

     FROM (ooxml, embedded labels, table is Sheet2);

End Sub

Call Mappings();

Table1:

LOAD

Field1,

Applymap('Codesmap',Field1, 'NO MAP') as CodeDescription,

Field2,

Field3

FROM (ooxml, embedded labels, table is Sheet1);

And it works without problems.

Thanks for your help