recursive Routine

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
dsnovice
Participant
Posts: 38
Joined: Thu Jul 22, 2004 11:56 pm
Location: Mclean, VA
Contact:

recursive Routine

Post by dsnovice »

Hello All,

For most of my querries I found the search button very useful but once in a while I meet with some problems that seem to be dead end with out a helping hand.

I need to write a recursive function that looks up a hash table for a given key

The routine has been defined as below
RoutineName = 'GetWorkDayFromHash'

Common /HashLookup/ FileHandles(100), FilesOpened

Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"
Deffun GetWorkDayFromHash(Argument1,Argument2) CALLING 'DSU.GetWorkDayFromHash'

HashTable = Arg1
HashKey = Arg2
FOUND = @FALSE

CALL DSLogInfo(Arg1,Arg2,'GetWorkDayFromHash')


IF OCONV(HashKey,"DW") = 6 or OCONV(HashKey,"DW") = 7 Then
HashKey=HashKey+1
GetWorkDayFromHash(HashTable,HashKey)
--------------------------------------------------------------------------------
but I get the following Error message
Compiling: Source = 'DSU_BP/DSU.GetWorkDayFromHash', Object = 'DSU_BP.O/DSU.GetWorkDayFromHash'
***???
0037 GetWorkDayFromHash(HashTable,HashKey)

^
"DEFNAM" unexpected, Was expecting: Array Name, Variable name,


--------------------------------------------------------------------------------

I Found the link to this answer

"You need to define the function within itself,

Code:
MyFunction(Arg1)
DEFFUN MyFunction(argument1) CALLING 'DSU.MyFunction'

CALL DSLogInfo(Arg1,'MyFunction')
IF Arg1 > 0 THEN MyFunction(Arg1-1)


_________________
- Arnd "
but this doesnt work for me,

Any help would be appreciated
thank you,

dsnovice
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Your DEFFUN is fine, but a function returns a value, so needs to be part of an assignment statement. You need to specify a line like:

Code: Select all

Ans = GetWorkDayFromHash(HashTable,HashKey)
ailuro
Participant
Posts: 21
Joined: Wed Sep 10, 2003 11:09 pm
Location: GMT+8

Post by ailuro »

Try assigning the value returned by your Routine to a variable, i.e.

Code: Select all

YourVar = GetWorkDayFromHash(HashTable,HashKey)
คาร์โล ตัน
dsnovice
Participant
Posts: 38
Joined: Thu Jul 22, 2004 11:56 pm
Location: Mclean, VA
Contact:

Post by dsnovice »

ArndW wrote:Your DEFFUN is fine, but a function returns a value, so needs to be part of an assignment statement. You need to specify a line like:

Code: Select all

Ans = GetWorkDayFromHash(HashTable,HashKey)
Thank you ArndW, I am able compile it with out errors

Thank you,

dsnovice
Post Reply