Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

himanshukr403
New Contributor II

Can we use call function within a subroutine to call another subroutine??

//1st subroutine

Sub createanddrop (vTableName)

Store $(vTableName) into [$(vTableName).qvd];

Drop Table [$(vTableName)];

End Sub

// 2nd subroutine

sub pop

FOR  i=1 to NoOfTables();

LET vTable=TableName($(i) -1);

CALL createanddrop($(vTable));

NEXT i

END SUB

//Main call to subroutine

Call pop;

This is my code....I want to use call within a subroutine, so that I can pass parameter to another subroutine.

Thanks

1 Solution

Accepted Solutions
luis_pimentel
Contributor III

Re: Can we use call function within a subroutine to call another subroutine??

Solved. Here it is:

//1st subroutine

Sub createanddrop (vTableName)

Store $(vTableName) into [$(vTableName).qvd];

Drop Table $(vTableName);

End Sub

// 2nd subroutine

SUB pop

FOR  i=1 to NoOfTables() -1;

LET vTable=TableName($(i) -1);

CALL createanddrop(vTable);

NEXT i

END SUB

// CALL

CALL pop;

15 Replies

Re: Can we use call function within a subroutine to call another subroutine??

It should work.

luis_pimentel
Contributor III

Re: Can we use call function within a subroutine to call another subroutine??

I think your code its fine. It should work.

himanshukr403
New Contributor II

Re: Can we use call function within a subroutine to call another subroutine??

Plz go through my code....

himanshukr403
New Contributor II

Re: Can we use call function within a subroutine to call another subroutine??

its not working.......I am not able to bring my table name to 1st subroutine

MVP
MVP

Re: Can we use call function within a subroutine to call another subroutine??

Hi

Try

CALL createanddrop(vTable);

or

CALL createanddrop('$(vTable)');


HTH

Jonathan

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

Re: Can we use call function within a subroutine to call another subroutine??

I would also modify line 2

Store [$(vTableName)] into [$(vTableName).qvd] (qvd);

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

Re: Can we use call function within a subroutine to call another subroutine??

Solved. Here it is:

//1st subroutine

Sub createanddrop (vTableName)

Store $(vTableName) into [$(vTableName).qvd];

Drop Table $(vTableName);

End Sub

// 2nd subroutine

SUB pop

FOR  i=1 to NoOfTables() -1;

LET vTable=TableName($(i) -1);

CALL createanddrop(vTable);

NEXT i

END SUB

// CALL

CALL pop;

luis_pimentel
Contributor III

Re: Can we use call function within a subroutine to call another subroutine??

Use

FOR  i=1 to NoOfTables() -1;

instead of

FOR  i=1 to NoOfTables() ;

AND

CALL createanddrop(vTable);

instead of

CALL createanddrop($(vTable));

Luis.

Not applicable

Re: Can we use call function within a subroutine to call another subroutine??

Not sure it will work

If you delete a table, what will be the next time the result of TableName (counter) when you increment your counter. I think you will skip some tables.

Certainly, you have to get your table to export and delete through a simple TableName(0). And do a loop as you did (certainly by storing NoOfTable into a variable)

Fabrice

Community Browser