Page 1 of 1

Calling Routine though varibale

Posted: Mon Sep 29, 2008 1:34 am
by shershahkhan
I want to call a routine from another routine and the name and parameters of the first routine is passed as parameter value.

Code: Select all

After Routine: FirstRoutine - SecondRoutine(0,0); ThridRoutine(0,0)
INSIDE Routine

Code: Select all

fRoutine= Field(InputArg, ";", 0, 1) ;
sRoutine= Field(InputArg, ";", 1, 1) ;

CALL DSU.fRoutine;
CALL DSU.sRoutine;
Can we do this

Posted: Mon Sep 29, 2008 2:40 am
by DS_SUPPORT
Yes , you can do that. Define the first routine inside the second routine, by using DEFUN.

Code: Select all

DEFFUN FirstRoutine(Arg1) Calling "DSU.FirstRoutine"
And then in your code, you can just get the values like

Code: Select all

    TVar = FirstRoutine(SomeVal) 
Or If this doesnt solve your purpose, Ray Recently posted some routines which work for Rule based. Search For the String '@RuleSubr"

Posted: Mon Sep 29, 2008 2:41 am
by ray.wurlod
Yes.

You use "indirect call", which allows the value of the routine name to be loaded into a variable before the CALL statement is executed.

Find out more from the DataStage BASIC manual. You will also find examples if you Search DSXchange.