Very simple code...I thought

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
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Very simple code...I thought

Post by JDionne »

I am trying to write a very simeple bit of code as follows
quote:
Harmitem = Arg1
Ans = ''
If Harmitem = '116' then Found = @True else Found = @False
If Found Then Ans = 'R'
End

when i compile the job i get the following errors
quote:
Compiling: Source = 'DSU_BP/DSU.JOCImportRedefinedReefer', Object = 'DSU_BP.O/DSU.JOCImportRedefinedReefer'

0007 RETURN(Ans)

^
WARNING: Text found after final END statement


Compilation Complete.


There isnt even any blank spaces after the end statment
what is wrong here?
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Remove the END statement and it will compile. The END statment is confusing the compiler since this is a function.

Regards,

Michael Hester
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post by JDionne »

Thanx Worked like a charm
Jim

quote:Originally posted by mhester
[br]Remove the END statement and it will compile. The END statment is confusing the compiler since this is a function.

Regards,

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

Post by ray.wurlod »

IF, most of the I/O statements and a number of other statements can be in "single-line format" or "multi-line format". The rule that governs it can be stated as follows:

If the clause-introducing keyword (for example ON ERROR, LOCKED, THEN or ELSE) is the final word on the line in which it appears, then a corresponding END statement is mandatory.
If the clause-introducing keyword is not the final word on the line in which it appears, then a corresponding END statement is prohibited.

So your code could have been written as:
Harmitem = Arg1
Ans = ''
If Harmitem = '116' then Found = @True else Found = @False
If Found Then
Ans = 'R'
End
In this example, the first IF statement is in "single-line format" while the second IF statement is in "multi-line format" (even though there is only one statement controlled by the IF condition).
Your code could more efficiently have been written as:
Ans = (If Harmitem = "116" Then "R" Else "")


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply