BASIC Compilation Error

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
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

BASIC Compilation Error

Post by muascdev »

I modified the hashLookUp program and its giving compile error. This is my 1st BASIC program ever tried to compile.

it gives 'End of file unexpected, Was expecting : Array Name, Variable Name'

can somebody tell me what the problem is.. thanks

*************************************************************************

* Author: David Thompson

* Date: 16th December 2003

* This function adapted from Ascential's UtilityHashLookup (see notice below)

*************************************************************************



*************************************************************************

* Copyright (c) 1997-2001 Ascential Software Inc. - All Rights Reserved.*

* This code may be copied on condition that this copyright *

* notice is included as is in any code derived from this source. *

*************************************************************************



*************************************************************************

*

* Executes a lookup against a hashed file using a key, composited from two arguments

*

* Input Parameters : Arg1 = Hash Table Path & Name

* Arg2 = Hash Key Value 1

* Arg3 = Hash Key Value 2

* Arg4 = Column Position to return

* If empty, return entire row in a dynamic array.

*

* Return Values: If no record found, return value is: @NULL

* If hash file not found, return value is: "**TABLE NOT FOUND**"

*

*

**************************************************************************





RoutineName = 'HashLookUp'



Common /HashLookup/ FileHandles(100), FilesOpened



ErrorCode = 0



FileName = Field(InputArg,';',1)

Key1 = Field(InputArg,';',2)

Key2 = Field(InputArg,';',3)







HashTable = FileName

HashKey = Key1:@TM:Key2

PositionReturn = 0



* Attempt to find the table name in our cache.



Locate HashTable in FilesOpened Setting POS Then

Read Rec From FileHandles(POS), HashKey Then

Call DSLogInfo("Record: ":Rec<3>, "MyRecord")

End Else

* Table is not in cache of opened tables, so open it.

OpenPath HashTable To FileHandles(POS) Then

FilesOpened<-1> = HashTable

Read Rec From FileHandles(POS), HashKey Else

Rec = @NULL

End

Ans = Rec

Call DSLogInfo("Record: ":Rec<3>, "MyRecord")

End Else

Rec = "**TABLE NOT FOUND**"

Ans = Rec

End

END
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Please edit your post and add code tags in front and at the end. Make sure your code is indented first.
Mamu Kim
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

It looks as if there is one too many END statements.
Mamu Kim
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

Post by muascdev »

kduke wrote:It looks as if there is one too many END statements.
yes I fixed them.. when i was starting to indent I realized that.. thx kduke
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: There's a formatting tool in the server routines editor.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

Re: BASIC Compilation Error

Post by muascdev »

now the code is working .. it even displays the last message 'ended else'
but it throwing a warning ' Attempting to Cleanup after ABORT raised in stage HashSeq.JobControl'.

Code: Select all

      Call DSLogWarn("Processing", "MyRecord") 

 

      RoutineName = 'HashLookUp'

 

      Common /HashLookup/ FileHandles(100), FilesOpened

 

      ErrorCode = 0

 

      FileName = Field(InputArg,';',1)

      Key1 = Field(InputArg,';',2)

      Key2 = Field(InputArg,';',3)

 

 

 

      HashTable = FileName

      HashKey = Key1

      PositionReturn = 0

 

* Attempt to find the table name in our cache.

 

      Locate HashTable in FilesOpened Setting POS Then

         Read Rec From FileHandles(POS), HashKey Then

              Call DSLogInfo("Record: ":Rec<3>, "MyRecord") 

         end else

              Ans = @NULL

         end

      End Else

* Table is not in cache of opened tables, so open it.

         OpenPath HashTable To FileHandles(POS) Then

            FilesOpened<-1> = HashTable

            Read Rec From FileHandles(POS), HashKey then

               Ans = Rec

                Call DSLogInfo("Record: ":Rec<3>, "MyRecord") 

            end else

               Call DSLogInfo("else ", "MyRecord") 

 

               Rec = @NULL

            End

                        

         End Else

            Call DSLogInfo("end else ", "MyRecord") 

            Rec = "**TABLE NOT FOUND**"

            Ans = Rec

        End

      END

      Call DSLogInfo("ended else ", "MyRecord")

Last edited by muascdev on Thu Oct 12, 2006 4:08 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Wasn't the only change you made to the sdk routine one from 'Open' to 'OpenPath'? Something else going on here that I'm missing?

Your problem looks to be the fact that you specifically log a warning on the first line of the routine. Why would you want to do that? Change it to a DSLogInfo call - or better yet remove it as it doesn't really serve any purpose.

And you do realize there's no reason to quote the entire message you reply to each time, yes?
-craig

"You can never have too many knives" -- Logan Nine Fingers
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

Post by muascdev »

well I changed DSLogWarn to DSLogInfo and its still aborting.. i just copied this code from the form, and modified little bit. I wrote this as a after/before subroutine. if i write this as a Transform Function. Its working fine. I want to write it as a Subroutine.. any help!!
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The "Ans = ..." lines are not used when called as part of job control. Can you write a 2-liner routine that defines and calls this before/after job one and see if you still get the same error. Also, the output of what caused the termination might be found in the &PH& log file for the run.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

muascdev wrote:I want to write it as a Subroutine.. any help!!
Ah... you need to mention little details like this, as the 'rules' are different between the two types. And I should have noted you parsing the InputArg - that's a big clue.

A 'Before/After' routine takes only one input argument and can only return a status, so you'll need to take that into account when writing one. You've handled the former, and Arnd noted the latter, so anything else would require a health dose of debugging.

Have you tried 'Resetting' the aborted job from the Director to see if a message labelled 'From previous run...' is pulled into the job? As Arnd notes (these messages come from &PH&) they can provide more clues as to the nature of the problem.
-craig

"You can never have too many knives" -- Logan Nine Fingers
muascdev
Charter Member
Charter Member
Posts: 51
Joined: Tue Oct 10, 2006 5:48 pm

Post by muascdev »

Ans did the trick .. thank you all
Post Reply