Page 3 of 3

Posted: Sat Jul 09, 2011 10:11 am
by chulett
pandeesh wrote:So, is there any equivalent function available in 7.x for finding recent starting event id? i don't think we can get the recent starting event via DSGetNewestLogID. Because it returns the last event of the recent run
Of course there is a way and it's what I've been harping on you about from the beginning. Read the documentation I linked to which starts you off right at that function. Examine the nine different valid values for the EventType argument. You've stubbornly been sticking with DSJ_LOGANY when there are eight others to choose from, including DSJ_LOGSTARTED.

Posted: Sun Jul 10, 2011 5:05 am
by pandeesh
Craig, Now i am filtering the logs between DSJ_LOGSTARTED and DSJ_LOGANY.
Now the issue is ,once the job gets aborted the log becomes like:

Code: Select all


Control  Starting Job........
....
....

warnings
......
fatal
.........
Control Job aborted...
[Seq...] finished under control...


Now DSJ_LOGANY fetches the last line "finished under control"
But DSJ_LOGSTARTED retrieves "Job aborted" since it's control message.
But i expect DSJ_LOGSTARTED should fetch the first line "Starting..."

Is there any way to make the job aborted message as fatal in stead of control message?

Thanks

Posted: Sun Jul 10, 2011 6:58 am
by chulett
pandeesh wrote:But i expect DSJ_LOGSTARTED should fetch the first line "Starting..."
As would I. If it's not doing that, I'll have to defer that issue to your official support provider.

Also, if you want to post the latest and greatest code we can make sure nothing seems amiss there.

Posted: Sun Jul 10, 2011 8:02 am
by pandeesh

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H
JobName = Arg1

hJob = DSAttachJob(JobName, DSJ.ERRNONE)

iLatestLogID = DSGetNewestLogId(hJob, DSJ.LOGANY)
iStartID=DSGetNewestLogId(hJob, DSJ.LOGSTARTED)

For iEventID =iStartID to  iLatestLogID 
   vEventDetail = DSGetLogEntry(hJob1, iEventID)
   Ans<-1> = vEventDetail
Next iEventID

iIgnore = DSDetachJob(hJob)
I am not able to connect datastage at this time.
I guess the final code i tried was the above one.
while mailing the dynamic array vEventDetail , i am getting only the last two lines:

Code: Select all

job aborted
[seq..] job under control finished
That was the last 2 lines in the log

Posted: Sun Jul 10, 2011 10:38 am
by chulett
Update your post when you can get back on DataStage, I really don't want to discuss something you guess might be like sorta your final code. :wink:

At this stage I'd also suggest dropping 'breadcrumbs' in your code so you know what it is doing each step of the way. Check the status of each function call, when it is a -1 the call failed and you can use DSGetLastError() to find out what happened if you like. Worst case, just use DSLogInfo() to put each value into the job's log so you know both the starting id and the ending id. While you are debugging this, I'd also log the current iEventID inside the loop and each individual vEventDetail value the same way, just so you can see the progression of the code while it loops.

Comment it out once this finally works.

Posted: Sun Jul 10, 2011 11:31 am
by pandeesh
Hi Craig,

Yesterday itself i tried with a simple test.

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H
JobName = Arg1

hJob = DSAttachJob(JobName, DSJ.ERRNONE)

iLatestLogID = DSGetNewestLogId(hJob, DSJ.LOGANY)
iStartID=DSGetNewestLogId(hJob, DSJ.LOGSTARTED)

Ans=iStartID
iIgnore = DSDetachJob(hJob) 
This returns the value of 433.

While assigning iLatestLogID to Ans it returns 434.

I am curious to know how DSJ.LOGSTARTED internally works.
Does it go and find the recent id based on the keyword"Starting Job" or based on the type of log entry(in this case "Control").?

Because both the log entries "Starting Job" and "Job aborted" belong to Control sort of log entries.

Since DSGetNewestLogEntry fetches most recent entry, it's fetching "Job aborted"

Correct me if my assumption is incorrect.

Thanks.

Posted: Sun Jul 10, 2011 12:34 pm
by pandeesh
i have connected to datastage and the code is:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
JobName = Arg1 


hJob = DSAttachJob(JobName, DSJ.ERRNONE) 

NewestStartId = DSGetNewestLogId(hJob, DSJ.LOGSTARTED)
 NewestLogId = DSGetNewestLogId(hJob, DSJ.LOGANY) 


 For iEventID =  NewestStartId to NewestLogId  Step+1
   
vEventDetail<-1> = iEventID:DSGetLogEntry(hJob, iEventID) 

next iEventID

Mail = DSSendMail("From:DataStage@bcd.com\nTo:avc@xd.com\nServer:b01\nSubject:\nBody:Please find the log":vEventDetail ) 

Ans = Mail

iIgnore = DSDetachJob(hJob)
 
in the mail i have recieved the below entries:

Code: Select all

774  2011-07-09 13:17:36\eadm\5\Job Report has been reset.
775  2011-07-09 13:17:36\eadm\7\(SeqReport) <- Report: Job under control finished.

From this , it's clear that DSJ.LOGSTARTED is not fetching as per our expectation.

The next test confirms that:

i have chosen one "finished " job.
i have passed that job name as the argument for the below code:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
JobName = Arg1 
hJob = DSAttachJob(JobName, DSJ.ERRNONE) 

NewestStartId = DSGetNewestLogId(hJob, DSJ.LOGSTARTED)
 NewestLogId = DSGetNewestLogId(hJob, DSJ.LOGANY) 

vEventDetail<-1> = NewestStartId :DSGetLogEntry(hJob, NewestStartId)
Ans= vEventDetail
As usual, the result is not "Starting job".
It gives the last control entry:

Code: Select all

292011-07-08 07:21:01\eadm\5\Finished Job agg.

The behaviour of DSJ.LOGSTARTED is puzzling.
is this the bug in 7.5.1 or am i doing incorrectly?

Please share your thoughts

Posted: Mon Jul 11, 2011 6:24 am
by chulett
pandeesh wrote:The behaviour of DSJ.LOGSTARTED is puzzling.
is this the bug in 7.5.1 or am i doing incorrectly?
Nothing is jumping out at me as incorrect, so again I'd suggest putting all this information in front of your official support provider.

Posted: Mon Jul 11, 2011 7:29 am
by pandeesh
chulett wrote: I'd suggest putting all this information in front of your official support provider.
Sure Craig!!

Posted: Tue Oct 11, 2011 10:38 pm
by evee1
Pandeesh,
Did you manage to solve this issue?
The same thing is happening to me and the routing can't properly locate the latest starting event for the job. This happens when I use the the syntax, you are using i.e.

Code: Select all

hJob = DSAttachJob(JobName, DSJ.ERRNONE)
NewestStartId = DSGetNewestLogId(hJob, DSJ.LOGSTARTED)
NewestLogId = DSGetNewestLogId(hJob, DSJ.LOGANY) 
However, when I changed the routine to do the following instead:

Code: Select all

NewestStartId = DSGetNewestLogId(DSJ.ME, DSJ.LOGSTARTED)
NewestLogId = DSGetNewestLogId(DSJ.ME, DSJ.LOGANY) 
the routine is able to locate the starting event correctly.
Unfortunately, it has to be run from within the job and makes it impossible to test "dry".

Maybe it will help you. Unfortunately, it does not solve my issues entirely, as I need to extract the name of another job from the log event, and then attach to that job, so I need to use the job handle method.

Posted: Wed Oct 12, 2011 1:17 pm
by ray.wurlod
Write the routine so that it works backwards in the log until it finds a genuine starting event. Then work forwards from there.