Page 1 of 1

Routine Variable Limitation

Posted: Wed Aug 16, 2006 9:01 am
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

Posted: Wed Aug 16, 2006 10:18 am
by Krazykoolrohit
instead of routine you should have posted the warning or error message first.

Posted: Wed Aug 16, 2006 5:25 pm
by katz
Well, the error message is 'Abort raised in <Jobname>..Afterjob

Does it help?

Posted: Wed Aug 16, 2006 5:33 pm
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.

Posted: Wed Aug 16, 2006 6:06 pm
by kduke
Please edit your post and put code tags around it so we can see the indentation. Thanks.

Posted: Thu Aug 17, 2006 2:14 am
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.

Posted: Thu Aug 17, 2006 8:23 am
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.