Writing job log event entries repeatedly to the file

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Writing job log event entries repeatedly to the file

Post by DSRajesh »

Hi All

I am using below code for writing log entries into the file but the log entries are writing repeatedly.

Code: Select all

PENSEQ InFile to output_file    
                 
ElSE CREATE output_file                               
ELSE ERRORCODE=1

For x = 1 to LCnt  
                           
LId = LogIdList<x>                                    

vEventDetail = vEventDetail:Field(DSGetLogEntry(hJob,LId),"\",4) 
WRITESEQF vEventDetail to output_file                             
ELSE STOP
WEOFSEQ output_file
Next 

CLOSESEQ output_file
is there any issue with code which is writing to file.
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Re: Writing job log event entries repeatedly to the file

Post by ArndW »

The following should clear up your problem

Code: Select all

OPENSEQ InFile to output_file
THEN
   WEOFSEQ output_file   
END
ELSE 
   CREATE output_file ELSE ERRORCODE=1
END

For x = 1 to LCnt  
   LId = LogIdList<x>                                    
   vEventDetail = vEventDetail:Field(DSGetLogEntry(hJob,LId),"\",4) 
   WRITESEQ vEventDetail ON output_file ELSE STOP "Bad Write"
   ** WEOFSEQ output_file !! Don't do this, it writes an end-of-file marker and truncates the file
NEXT X
CLOSESEQ output_file
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

premium membership got expired and unable to see the content.

Request you please post the same as visble and i will renew the membership in a week
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The WEOFSEQ command truncates the sequential file each time it is executed, you have that statement inside your loop. Otherwise I just cleaned up the code a little.
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Thanks Arndw,

I am able to cleanup the file and write without repeated log entries in the file.

But the entries are writing one after another on the same line rather than writing on new line for each new entry.

what needs to be added to write the each log entry in next line ..

Please suggest me on this
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Writing to a sequential file using WRITESEQ will terminate each line. Could it be that your server is on UNIX and you are viewing in Windows? (UNIX uses <LF> while Windows uses <CR><LF>). If that is the case, try using wordpad.exe or notepad++.exe to read the sequential file. If you need windows-type termination when writing in UNIX, add the "Char(13)" to each string line you write with WRITESEQ.
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Arndw,

The server is on unix.
I am able to see the characters  before and after each entry.
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Make a test copy of the routine that writes only 2 (preferably short) lines to a file, then use the UNIX "od" command to dump that to see what you are getting as control characters. I would expect to see only char(10) (<LF>) after the data.
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Arndw,

Whenever logentry has (...) end the end which has expandable content in the log,i am getting these characters and the line termination is proper
RD
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I can't check right now, but assume that your log entries contain either a field-mark or value-mark. If you mask those with spaces, i.e. with "vEventDetail = vEventDetail:CONVERT(@FM:@VM,' ',Field(DSGetLogEntry(hJob,LId),"\",4))" what does your output look like?
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

Thanks Arndw,

This is working fine and those control charcaters were removed and entries are showing correctly.
RD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

We had this same 'control character' conversation back in your "Extract of log file using DSGetLogEntry not working" thread. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSRajesh
Premium Member
Premium Member
Posts: 297
Joined: Mon Feb 05, 2007 10:37 pm

Post by DSRajesh »

That was for diff conversion
RD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Same principle, though.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply