Routine return value

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
nkln@you
Premium Member
Premium Member
Posts: 271
Joined: Wed Nov 17, 2004 5:15 am
Location: US

Routine return value

Post 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
Aim high
JeanPierreHaddad
Participant
Posts: 18
Joined: Mon Nov 25, 2002 3:23 am
Location: Switzerland

Re: Routine return value

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
nkln@you
Premium Member
Premium Member
Posts: 271
Joined: Wed Nov 17, 2004 5:15 am
Location: US

Post by nkln@you »

Thanks ArnDw and Jean,

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