Routine Variable Limitation

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
katz
Charter Member
Charter Member
Posts: 52
Joined: Thu Jan 20, 2005 8:13 am

Routine Variable Limitation

Post by katz »

We have the following bit of code as part of a routine

**********************************************************
writeJobLogToFile:

v_jobLogFileName = v_FileNamePrefix : '_JobLog.txt'
v_maxEventID = DSGetNewestLogId ( v_jobHandle, DSJ.LOGANY)

if ((v_maxEventID <= 0) or (v_maxEventID = DSJE.BADTYPE)) then
v_logSummary = ""
call DSLogWarn("Error Accessing Max Event ID for JobLog", c_routineName)
end
else
v_logSummary = DSGetLogSummary ( v_jobHandle, DSJ.LOGANY, DSJobStartTimestamp, "" , c_maxLogLines)
end


* Loop to get each Job Log Event Detail and concatenate into v_logText
v_logText = 'Event Timestamp\User\Event Type\Event Details'
v_eventDetail = ''

i = 1
v_eventID = Field(v_logSummary<i>, '\', 1)
Loop While v_eventID<>''
v_eventDetail = DSGetLogEntry (v_jobHandle, v_eventID)

if v_eventDetail = DSJE.BADVALUE then
call DSLogWarn("Error Accessing Event ID ":v_eventID, c_routineName)
Exit
end
else
v_logText := CHAR(10) : Exchange(Exchange(v_eventDetail, '0D', 'FF'), '0A', 'FF')
end

i = i+1
v_eventID = Field(v_logSummary<i>, '\', 1)
Repeat

Openpath v_logFolder to t.fvar2 then
write v_logText to t.fvar2, v_jobLogFileName else
call DSLogWarn("Failed to write file ":v_jobLogFileName:" to directory ":v_logFolder, c_routineName)
GoTo ExitWriteJobLogToFile
end
end
else
call DSLogWarn("Failed to open directory ":v_logFolder, c_routineName)
GoTo ExitWriteJobLogToFile
end

close t.fvar2

ExitWriteJobLogToFile:

Return
**********************************************************

As you see in this we concate all the event messages into one variable v_logText . We came across a warning in the DS Log that is more than varchar(2000). Whenever we get this message this routine is aborting.

Was wondering if it is beacuse the concatenated value has exceeded the size that this variable can hold.

Any suggestions pls.

Katz
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

instead of routine you should have posted the warning or error message first.
katz
Charter Member
Charter Member
Posts: 52
Joined: Thu Jan 20, 2005 8:13 am

Post by katz »

Well, the error message is 'Abort raised in <Jobname>..Afterjob

Does it help?
Dsnew
Participant
Posts: 90
Joined: Tue Apr 19, 2005 2:08 pm

Post by Dsnew »

Katz,

Your routine captures the job log into a file? Did i understand it right?

It looks good !

Can you please explain what this routine does.
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 put code tags around it so we can see the indentation. Thanks.
Mamu Kim
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

katz wrote:Well, the error message is 'Abort raised in <Jobname>..Afterjob

Does it help?
Do a "reset" of your job and you will see an entry titled "from previous run" and it will give you the actual error message.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Make sure there is no space between any function name and its opening (left) parenthesis. DataStage BASIC can be finicky about this.

There is no limit to the length of a string variable in DataStage BASIC until you run out of virtual memory. By assembling the entire log into a single string to be written with a single WRITE statement this may be happening (unrelated to any particular log event, but certainly exacerbated thereby).

A better approach would be one that writes a single line at a time into your output file. Open with OpenSeq (or, better, with the OpenSequentialFile function that can be found on the forum), and write lines with WriteSeq. Remember to CloseSeq any file thus opened.
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