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: 
rustyfishbones
Master II
Master II

Is it possible to call an Include file within a Sub Routine

Hi,

Is it possible to call an include file within a Sub Routine like below example, which doesn't work?

SUB plt.Global(_Cust)

LET _Cust = IF(LEN('$(_Cust)') = 0 , 'EXIT SCRIPT;', '$(Must_Include=c:\qlikview\customers\$(_Cust)\bin\global.qvs)');

END SUB

CALL plt.Global('MyCustomer');

1 Solution

Accepted Solutions
albertovarela
Partner - Specialist
Partner - Specialist

Try:

Sub plt.Global(_Cust)

        If Len($(_Cust)) = 0 THEN
        Exit SCRIPT;
       ELSE
       $(Must_Include=c:\qlikview\customers\$(_Cust)\bin\global.qvs);
       ENDIF

END Sub

CALL plt.Global('MyCustomer');

View solution in original post

4 Replies
albertovarela
Partner - Specialist
Partner - Specialist

Try:

Sub plt.Global(_Cust)

        If Len($(_Cust)) = 0 THEN
        Exit SCRIPT;
       ELSE
       $(Must_Include=c:\qlikview\customers\$(_Cust)\bin\global.qvs);
       ENDIF

END Sub

CALL plt.Global('MyCustomer');

rustyfishbones
Master II
Master II
Author

Thanks, I will try tomorrow morning when I get back to it, thanks

rustyfishbones
Master II
Master II
Author

Thanks,

 

The "Must" throws an error as the Variable is not defined within the Sub Routine, so removing the Must part in the include statement allows the routine to run, the other issue is that if the global.qvs file does not exist, it will also not throw an error, but at least it works somewhat.

So the below works perfect

Sub plt.Global(_Cust)

If Len('$(_Cust)') = 0 THEN
Exit SCRIPT;
ELSE
$(Include=c:\qlikview\customers\$(_Cust)\bin\global.qvs);
ENDIF

END Sub

CALL plt.Global('MyCustomer');

albertovarela
Partner - Specialist
Partner - Specialist

I'm glad you made it work.