Routine Code

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

DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Routine Code

Post by DS_MJ »

Hello:

I am quite new to writing a routine on a Server 7.5.

My job calls for club. Say the club's represent Fiction (f).

In my transform job properties I have defined the following parameters:

Parameter name.....Prompt.....................Type........Default Value
Club......................Enter Club name........String...........f

In Routine CODE - I have written a routine that say's the following:

If Club = 'c' THEN COUNTRY_CDE = '2' else '0'

In Arguments Tab - have the Argument Name as Club

But I get ERRORS while compiling the routine. They are:

Compiling: Source = 'DSU_BP/DSU.AddressRtn', Object = 'DSU_BP.O/DSU.AddressRtn'

0003 If Club = 'c' THEN COUNTRY_CDE = '2' else '0'
^
String Constant unexpected, Was expecting: Array Name,
Variable name,New variable name, ';', Statement label, "ABORT", "ABORTE", "ABORTM",
"BEGIN", "BREAK", "CALL", "CHAIN", "CLEAR", ......"SETIT", "SEND",
"UPRINT", "AUXMAP"

1 Errors detected, No Object Code Produced.

Thanks in advance.

DS_MJ
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You must return your answer in a variable called 'Ans'.

Code: Select all

If Club = 'c' THEN Ans = '2' else Ans= '0' 
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Routine Code

Post by chulett »

DS_MJ wrote:If Club = 'c' THEN COUNTRY_CDE = '2' else '0'
Your syntax is invalid... else what is zero? :wink:

Plus you need to set the value of Ans as that is what is returned when you call the routine. Are you doing that somewhere?
-craig

"You can never have too many knives" -- Logan Nine Fingers
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Hi kcbland:

Thank you very much. It worked. :D

DS_MJ
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Hi chulett:

Thanks so much ...yep it worked.

DS_MJ
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

However, this syntax is valid:

Code: Select all

Ans = If Club = 'c' THEN COUNTRY_CDE = '2' else '0'
Some people prefer to use parentheses to indicate that a conditional expression, rather than a conditional statement, has been used.

Code: Select all

Ans = (If Club = 'c' THEN COUNTRY_CDE = '2' else '0')
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Valid, perhaps... but does it make any sense? :? What exactly would we be setting Ans to when Club equals 'c'? TRUE?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The expression (If Club = 'c' THEN COUNTRY_CDE = '2' else '0') can only return "2" or "0".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, just because this is bugging me and I really want to understand this Wurlod Nugget o' Fun... how does it return a '2'? :?

I can see how it returns the '0' on the other side the 'else' but it actually sets a variable called COUNTRY_CDE to '2', not 'Ans' when the expression is true - hence the puzzlement on my part. I guess the simplest way to play with this would be in a routine of my own making and see what comes out the other end.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not sure if you have a question here or not... but I'd suggest sticking with the syntax that works. :wink:

Code: Select all

If Club = 'c' THEN Ans = '2' else Ans ='0'
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

ray.wurlod wrote:The expression (If Club = 'c' THEN COUNTRY_CDE = '2' else '0') can only return "2" or "0".

Ray's statement is wrong. He should not have the "COUNTRY_CDE = '2'", just " the '2' portion. Craig has been trying to point this out.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

Hi chulett:

Nope. It was not a question. Just that my code works using the following expression:

If Club = 'c' THEN Ans = '2' else Ans ='0'

Thanks,
DS_MJ
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The perils of inattentive copy/paste programming! SHould have been:

The expression (If Club = 'c' THEN '2' else '0') can only return "2" or "0".

Good catch Ken.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

THAT I would have believed. :roll: :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
chalasaniamith
Participant
Posts: 36
Joined: Wed Feb 16, 2005 5:20 pm
Location: IL

Re: Routine Code

Post by chalasaniamith »

If Club = 'c' THEN Ans = '2' else Ans ='0'

bcoz the argument in routine is Ans so its better to use Ans not to confuse and to not to do errors.
Any way nice work by all the participants
Post Reply