Page 1 of 1

Routine return value

Posted: Tue Jun 07, 2005 10:37 pm
by nkln@you
I have created a routine Before/After Subroutine .

It has two parametrs: InputArg and ErrorCode

It's code is

ErrorCode = 0 ;* set this to non-zero to stop the stage/job

Cmd ='SELECT UNKNOWN_NUM FROM ':InputArg:';'

Call DSExecute('UV',Cmd,Value,Error);

ErrorCode =Value

InputArg will have a hash file name.


My requirement is i have to return the Routine output i,e value of ErrorCode. If that value is not 0 then i have to trigger the output link.

When i tried to test the routine, test button is disabled.

I used a routine activity stage namely "hash_sales_rep_key" and called this routine.In the trigger tab i used Custom -(Conditional) and the expression is hash_sales_rep_key.$ReturnValue>0. The problem is i checked the value for 'SELECT UNKNOWN_NUM FROM ':InputArg:'; It is 0. But the output link for the routine activity is triggering. It means hash_sales_rep_key.$ReturnValue>0 is true. How is this happening. Can you please tell me where i went wrong.


Thanks

Re: Routine return value

Posted: Wed Jun 08, 2005 1:26 am
by JeanPierreHaddad
Hello

You probably wrote your routine as a Before/After routine. In order to get more flexibility, you can redefine your routine as a Transform function. Then the ErrorCode can be passed either as a parameter as you do now or within the Ans. The Ans is the code returned by the activation of the routine during runtime.

Good luck
Jean-Pierre
nkln@you wrote:I have created a routine Before/After Subroutine .

It has two parametrs: InputArg and ErrorCode

It's code is

ErrorCode = 0 ;* set this to non-zero to stop the stage/job

Cmd ='SELECT UNKNOWN_NUM FROM ':InputArg:';'

Call DSExecute('UV',Cmd,Value,Error);

ErrorCode =Value

InputArg will have a hash file name.


My requirement is i have to return the Routine output i,e value of ErrorCode. If that value is not 0 then i have to trigger the output link.

When i tried to test the routine, test button is disabled.

I used a routine activity stage namely "hash_sales_rep_key" and called this routine.In the trigger tab i used Custom -(Conditional) and the expression is hash_sales_rep_key.$ReturnValue>0. The problem is i checked the value for 'SELECT UNKNOWN_NUM FROM ':InputArg:'; It is 0. But the output link for the routine activity is triggering. It means hash_sales_rep_key.$ReturnValue>0 is true. How is this happening. Can you please tell me where i went wrong.


Thanks

Posted: Wed Jun 08, 2005 1:58 am
by ArndW
As Jean-Pierre stated, a Before/After subroutine cannot be tested like a function. I usually write and test my routine as a function by changing the parameters around to match the function format, and when I'm ready I cut-and-paste the code portion (because by switching from routine to function and vice-versa you will lose all of your code). Apart from that slight anomaly Jean-Pierre's method works like a charm.

Posted: Wed Jun 08, 2005 6:09 am
by nkln@you
Thanks ArnDw and Jean,

I tried Transform function, and chaged small code . Now it is suiting my requirement.