Routine outputs director log - record split problem

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
raewu
Premium Member
Premium Member
Posts: 5
Joined: Thu May 12, 2005 9:51 am
Location: københavn, DK

Routine outputs director log - record split problem

Post by raewu »

I have a routine which takes the name of a job and outputs the log for that job. Here it is below:

Code: Select all


      *Read Job Log

      hJob = DSAttachJob(Arg1, DSJ.ERRNONE)
      If hJob <> 0 then
         Job_Invocation = DSGetJobInfo (hJob,DSJ.JOBINVOCATIONID)
         Start_TS = DSGetJobInfo (hJob, DSJ.JOBSTARTTIMESTAMP)
         End_TS = DSGetJobInfo (hJob,DSJ.JOBLASTTIMESTAMP)
         If Trim(Start_TS) = "" Then Log_Start_TS = TimeStamp Else Log_Start_TS = Start_TS
         If Trim(End_TS) = "" Then Log_End_TS = TimeStamp Else Log_End_TS = End_TS
         Print "TimeStamp ":TimeStamp
         If TimeStamp >= Log_End_TS then

            Logs_Any = DSGetLogSummary (hJob, DSJ.LOGANY, Log_Start_TS, Log_End_TS, 50)
            Logs_Warn = DSGetLogSummary (hJob, DSJ.LOGWARNING, Log_Start_TS, Log_End_TS, 50)
            Logs_Fatal = DSGetLogSummary (hJob, DSJ.LOGFATAL, Log_Start_TS, Log_End_TS, 50)
            Logs_out = Logs_Any:"\": Logs_Warn:"\": Logs_Fatal
*           Logs_out = Change(Change (Logs_Any, @FM, LF),"\", "|") : LF : Change(Change (Logs_Warn, @FM, LF),"\", "|") : LF : Change(Change (Logs_Fatal, @FM, LF),"\", "|")



            OpenSeq LOGFileName To PathFvar
            Else
               CREATE PathFvar Else ABORT
               OpenSeq LOGFileName To PathFvar else ABORT
               WEOFSEQ PathFvar
               WRITESEQ Logs_out TO PathFvar ELSE STOP


            end

            ErrCode = DSDetachJob(hJob)

         end
      end

      Ans=Ereplace (Logs_out, Char(13), "|")


End:
It seems to work fine in test and produces the result I expect. If I produce a file and use datastage to read the file and load it, I have no problem.

The trouble is, I want to use this routine in a transform to then output the results which I can split into the relevant fields and load it to a database. But I seem to be having problems as I only seem to be able to output one row when I use the "Field (string, delimiter, instance [ ,number] )" function to try and split it out in the transform stage.

I also tried to remove all CR/LF from the output so I output one big line and try to split it that way, but I still only seem to have the first record showing in the results.

Is there something I am missing? Or a better way of doing this?

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Routine outputs director log - record split problem

Post by chulett »

raewu wrote:The trouble is, I want to use this routine in a transform to then output the results which I can split into the relevant fields and load it to a database. But I seem to be having problems as I only seem to be able to output one row when I use the "Field (string, delimiter, instance [ ,number] )" function to try and split it out in the transform stage.
Don't quite follow. One 'row'? Field() pulls out one or more contiguous fields from delimited data. It would help if you gave more details as to how you are using Field (your syntax for example) and details on the structure of the job you are trying to use it in.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Your Routine opens the sequential file else creates and then outputs. If the file already exists it doesn't write anything to it because it's outside your open-else structure. So, if this logic is called multiple times it won't output more than the first time called.

Your logic also gets only up to 50 log entries within the time range queried. Your logic also gets all of the log messages, changes the internal delimiter to LF and slashes to pipes.

Since you didn't post your logic for extracting information from this one huge line of log information, we can't help you figure out why that doesn't work. I can say that if you're putting 150 lines of log messages into a single variable and returning it to a Transformer stage you will have difficulty outputing 150 rows from the stage. I don't quite understand what you're trying to accomplish.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
raewu
Premium Member
Premium Member
Posts: 5
Joined: Thu May 12, 2005 9:51 am
Location: københavn, DK

Post by raewu »

kcbland wrote:If the file already exists it doesn't write anything to it because it's outside your open-else structure. So, if this logic is called multiple times it won't output more than the first time called.
thanks Kennenth, i changed that and it works fine now.
Post Reply