open the file in the project default directory and read

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
parvathi
Participant
Posts: 103
Joined: Wed Jul 05, 2006 4:48 am
Contact:

open the file in the project default directory and read

Post by parvathi »

Hi all,

I am reading a file which is in Project default location and try to concate tha values.

Please see the code that i have used. correct where ever it is wrong

Code: Select all

OPEN "","JobRunInfoParms" TO v_connectionParamsDataFile 
    ON ERROR Call DSLogWarn('Failed to open file JobRunInfoParms. Error':STATUS(), c_routineName ); Return
    ELSE Call DSLogWarn('Failed to open file JobRunInfoParms. Error':STATUS(), c_routineName ); Return

openseq v_connectionParamsDataFile To ParamFileVar 
   On Error 
       Call DSLogWarn('Error opening parameters file': Status(), c_routineName ); Return
 
  Else  Call DSLogWarn('Cannot open parameters file': Status(), c_routineName) ; Return

End


Loop 
      While ReadSeq Line From ParamFileVar 
      Result := Line
      Exit
      End
Repeat
CloseSeq ParamFileVar 
is this code correct?[/code]
parvathi
Participant
Posts: 103
Joined: Wed Jul 05, 2006 4:48 am
Contact:

Post by parvathi »

when i run this code in the routine i get the following error message

Compiling: Source = 'DSU_BP/DSU.ReadParamsFile', Object = 'DSU_BP.O/DSU.ReadParamsFile'
?
0005 ON ERROR Call DSLogWarn('Failed to open file DSParams. Error':STATUS(), c_routineName ); Return

^
WARNING: no RETURN value specified, null used.

0006 ELSE Call DSLogWarn('Failed to open file DSParams. Error':STATUS(), c_routineName ); Return

^
WARNING: no RETURN value specified, null used.

0010 Call DSLogWarn('Error opening parameters file': Status(), c_routineName ); Return

^
WARNING: no RETURN value specified, null used.

^
"ELSE" unexpected, Was expecting: ';', End of Line
0017 Loop

^
WARNING: Text found after final END statement


1 Errors detected, No Object Code Produced.

can anybody please help me on this
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You are in a function, so all of your RETURN statements need to look like RETURN({some value}). You also have an exit statement in your loop that would get executed after the 1st read, and an unbalanced END in there as well.
parvathi
Participant
Posts: 103
Joined: Wed Jul 05, 2006 4:48 am
Contact:

Post by parvathi »

Is code to open the sequential file and read it from the project default directry correct?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

No.
1. You are opening up a local hashed file called "JobRunInfoParms".
2. You then try to open a sequential file, but instead of the giving path you are using the file handle from (1). This cannot work. The file is a hashed file or a sequential one, but not both.
3. Assuming you are reading the sequential file, you need to remove your "exit" and superfluous "end" statements.



Loop
While ReadSeq Line From ParamFileVar
Result := Line
Exit
End
Repeat
CloseSeq ParamFileVar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Note also that the Else clause can be taken in an OpenSeq statement even though the file is open for writing. This indicates that the file does not yet exist; the successful open is indicated by Status() returning 0.

Search the forum for OpenSequentialFile which illustrates all the possibilities when opening a file for sequential access.

Please post a specification (in English, not in code) for what you want this routine to achieve. Without that it's impossible to fulfil your original request to indicate whether your code is correct.

Where do you intend to use this routine? If it's per-row in a job, do you really want the overhead of opening and closing the file each time? There is a better solution in this case, but we need to know exactly what you want to accomplish.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
parvathi
Participant
Posts: 103
Joined: Wed Jul 05, 2006 4:48 am
Contact:

Post by parvathi »

ArndW wrote:No.
1. You are opening up a local hashed file called "JobRunInfoParms".
2. You then try to open a sequential file,
Can any other file be opened from the loca as open a hashed file?

The only thing i want to do I am able to open a hashed file from local ?
similarly can i open any ther file like DSParams or anything and read the contents from it?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

We still have no idea what you are trying to accomplish, so it's very difficult to give well-directed advice.
  • Open is for hashed files or directories with a pointer in the VOC file.

    OpenPath is for hashed files or directories generally.

    OpenSeq is for operating system files opened for sequential access.
Warning: once you can open things, you can do damage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply