Routine to write file - problems

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
teddycarebears
Participant
Posts: 18
Joined: Wed May 12, 2010 11:57 pm

Routine to write file - problems

Post by teddycarebears »

Hello,

I am having a hard time to figure out several things in my first routine. Basically I have to write a routine that runs after a job completes and I have the following issues:

1. Routine should start right AFTER job completes but DSJ.JOBSTATUS returns 0 which means the job is still running. How could I call this routine to indicate a status that indicates the job is finished ? RUNOK, RUNWARN etc don't matter too much, it is important not to be running.

2. I want to append a file but I can't figure it out why the code bellow is just overwriting the file and is not appending it.

Code: Select all

DirName = InputArg
FileName = "MyFile.csv"
FilePath = DirName:"/":FileName
FileLine = "some text"

OpenSeq FilePath to Temp.FVar
Else Create Temp.FVar Else Abort

WeofSeq Temp.FVar

WriteSeq FileLine to Temp.FVar else Stop

CloseSeq Temp.FVar

I am new to DataStage and I have just discovered Universe Basic language. Any help will be appreciated. Thanks in advance.
Able was I ere I saw Elba
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.
1. You need to interrogate the "interim status".
2. A long time ago I posted a routine called OpenSequentialFile which shows, among other things, how to position to end-of-file using SEEK statement.
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 »

1. Exactly, check the INTERRIMSTATUS which is what the job will finish with, provided your after-job routine doesn't blow up of course. :wink:

2. In addition to the missing SEEK issue, the fact that the first thing you are doing is writing an EOF to the file effectively truncates it. FYI.
-craig

"You can never have too many knives" -- Logan Nine Fingers
teddycarebears
Participant
Posts: 18
Joined: Wed May 12, 2010 11:57 pm

Post by teddycarebears »

I should kiss you both but probably the rest will look too strange at us after :)

1. yes, DSJ.JOBINTERIMSTATUS offered a much more accurate status and it works ok now.

2. I've read here how it should be. In my example I was using the code from the Help and I believed WeofSeq just positions me to the end of the file. Very strange that SEEK is not documented. My working code looks like this :

Code: Select all

FileName = "MyFile.csv"
FilePath = DirName:"/":FileName
FileLine = "some text"

OpenSeq FilePath to Temp.FVar
Else Create Temp.FVar Else Abort

SEEK Temp.FVar, 4, 2 Else
Call DsLogWarn("failed to go to the end of file ":FileName, "MyRoutineName")
End

WriteSeq FileLine to Temp.FVar else Stop

WeofSeq Temp.FVar

CloseSeq Temp.FVar
ps: Ray, I am reading this forum since April and I would gladly look at a lot more of its content but some of it is available only for Premium Members and ... that is another story :)
Able was I ere I saw Elba
Post Reply