help required in routine

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

Moderators: chulett, rschirm, roy

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

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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.
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

chulett wrote: I'd suggest putting all this information in front of your official support provider.
Sure Craig!!
pandeeswaran
evee1
Premium Member
Premium Member
Posts: 96
Joined: Tue Oct 06, 2009 4:17 pm
Location: Melbourne, AU

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
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