Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

pablo_nieto
New Contributor II

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

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

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.

7 Replies
tomasz_tru
Valued Contributor

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

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

Tomasz

pablo_nieto
New Contributor II

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

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

Thanks Tomasz.

marcus_malinow
Valued Contributor III

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

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

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

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.

pablo_nieto
New Contributor II

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

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

marcus_malinow
Valued Contributor III

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

I stand corrected! Thanks for the clarification Peter

pablo_nieto
New Contributor II

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

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