Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Partner - Creator III
Partner - Creator III

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;

View solution in original post

15 Replies
alexandros17
Partner - Champion III
Partner - Champion III

It should work.

luis_pimentel
Partner - Creator III
Partner - Creator III

I think your code its fine. It should work.

Anonymous
Not applicable
Author

Plz go through my code....

Anonymous
Not applicable
Author

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

jonathandienst
Partner - Champion III
Partner - Champion III

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
jonathandienst
Partner - Champion III
Partner - Champion III

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
Partner - Creator III
Partner - Creator III

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
Partner - Creator III
Partner - Creator III

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
Author

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