Page 1 of 3

help required in routine

Posted: Thu Jul 07, 2011 5:38 am
by pandeesh
HI,

I have used the below routine for capturing fatals and mailing them.
But in the mail , thye full fatal is not displaying.
It's just dispalying as (....) .
Is there any way to expand that and view.

code:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 

***CallingProgName = DSJ.ME 

rJobHandle = DSAttachJob(Jobname, DSJ.ERRNONE) 
JobStartTime = DSGetJobInfo(rJobHandle, DSJ.JOBSTARTTIMESTAMP) 
JobEndTime = DSGetJobInfo (rJobHandle, DSJ.JOBLASTTIMESTAMP) 
SummaryArray = DSGetLogSummary(rJobHandle, DSJ.LOGFATAL, JobStartTime, JobEndTime, 0) 
Mail = DSSendMail("From:DataStage-Development@xys.com\nTo:abx@sant.com\nServer:wdims\nSubject:Jobs Failed !Please take care! \nBody:":SummaryArray) 
DetachResult = DSDetachJob(rJobHandle) 

Ans = Mail 

In the mail i am getting the messages like below:

Code: Select all

203\2011-07-07 06:13:18\3\Job_Activity_1\1\TL_RAW: GenericQuery:esqlErrorHandler (...)
204\2011-07-07 06:13:18\3\Job_Activity_1\1\TL_RAW: The provided query statement did not prepare correctly; (...)
205\2011-07-07 06:13:18\3\Job_Activity_1\1\main_program: Creation of a step finished with status = FAILED.


Any help appreciated

Thanks

Posted: Thu Jul 07, 2011 6:27 am
by chulett
That's because you are using DSGetLogSummary rather than DSGetLogDetail.

Posted: Thu Jul 07, 2011 6:55 am
by pandeesh
chulett wrote:That's because you are using DSGetLogSummary rather than DSGetLogDetail.
Hi ,

I have tried DSGetLogDetail, but it throws the syntax error.
I haven't found the syntax for DSGetLogDetail anywhere.

Code: Select all

SummaryArray = DSGetLogDetail(rJobHandle,DSJ.LOGFATAL, JobStartTime, JobEndTime, 0)
The error is:

Code: Select all

Compiling: Source = 'DSU_BP/DSU.maillog', Object = 'DSU_BP.O/DSU.maillog'
********************************************?
0009    SummaryArray = DSGetLogDetail(rJobHandle,DSJ.LOGFATAL, JobStartTime, JobEndTime, 0) 

                                                            ^
',' unexpected, Was expecting: '!', ')', '=', "AND", "OR", "LT", "LE", 

Posted: Thu Jul 07, 2011 7:05 am
by chulett
OK... that was off the top of my head and I got the function name wrong. Was it really that hard to try and look up what I really meant? :?

Switch it to DSGetLogEntry. Note that you'll need to include the use of DSGetNewestLogId as well from what I recall. Search for forums for examples of the syntax / usage.

Posted: Thu Jul 07, 2011 8:40 am
by pandeesh
Hi ,

I have used the below routine..

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
JobName = Arg1 

hJob = DSAttachJob(JobName, DSJ.ERRNONE) 

iLatestLogID = DSGetNewestLogId(hJob, DSJ.LOGANY) 

Ans = "" 
For iEventID = iLatestLogID To 1 Step -1 
   vEventDetail = DSGetLogEntry(hJob1, iEventID) 
   Ans<-1> = vEventDetail 
Next iEventID 

iIgnore = DSDetachJob(hJob)
But it's not working.Once the job aborts it says the routine did not finsh,reply=-1. But it's compiling fine.

Am i missing anything?

Thanks

Posted: Thu Jul 07, 2011 1:23 pm
by pandeesh
Hi Craig,

i have used the below code and i am receiving only the last line of the mail.

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
JobName = Arg1 

hJob = DSAttachJob(JobName, DSJ.ERRNONE) 

iLatestLogID = DSGetNewestLogId(hJob, DSJ.LOGANY) 

For iEventID = iLatestLogID To 1 Step -1
   
  vEventDetail = DSGetLogEntry(hJob, iLatestLogID) 

next iEventID

Mail = DSSendMail("From:DataStage-Development@xys.com\nTo:pandeesh@ccgi.com\nServer:wdims\nSubject:Jobs Failed !Please take care! \nBody:":vEventDetail ) 

Ans = Mail

iIgnore = DSDetachJob(hJob)
i am struggling to store all the log entries in a single variable(array variable) and concatenate that variable in the DSSendMail.

In the mail i am receiving:

Code: Select all

2011-07-07 08:49:25\adm\7\(Seqps) <- Acg: Job under control finished.
And one more thing is:
DSGetNewestLogId(hJob, DSJ.LOGANY) fetches all the entries in the log regardless of fatal,warning or information.
Is there any other option available to fetch the fatal alone?

Thanks

Posted: Thu Jul 07, 2011 3:13 pm
by ray.wurlod
You overwrite vEventDetail each iteration through the loop, but don't call DSSentMail() till you exit the loop. Why don't you specify in English what you want to achieve?

Posted: Thu Jul 07, 2011 3:32 pm
by chulett
pandeesh wrote: DSGetNewestLogId(hJob, DSJ.LOGANY) fetches all the entries in the log regardless of fatal,warning or information.
Is there any other option available to fetch the fatal alone?
Yes and a quick check of the documentation should clear that up for you. Hint: you told it you wanted DSJ.LOGANY - that's not the only option.

Posted: Thu Jul 07, 2011 9:14 pm
by pandeesh
ray.wurlod wrote:You overwrite vEventDetail each iteration through the loop,
In stead of overwriting, how to append the log information to that variable?

So that we can finally include that variable in the mail body?

Thanks

Posted: Thu Jul 07, 2011 10:12 pm
by chulett
Do you see how "Ans" was being treated as a dynamic arrary in the code you first posted and then you removed that bit of magic from the second iteration of the code? Now you want to treat your vEventDetail in that same fashion so it inserts a new array element each time through the loop rather than overwriting:

Code: Select all

For iEventID = iLatestLogID To 1 Step -1 
    
  vEventDetail<-1> = DSGetLogEntry(hJob, iLatestLogID) 

next iEventID
Then when you include vEventDetail in the body of the email it will have all occurances in it.

Posted: Fri Jul 08, 2011 12:59 am
by pandeesh
The below code works for me:

Code: Select all

vEventDetail<-1> = DSGetLogEntry(hJob,iEventID) 
But it mails log details for all runs ,since the loop is from iNewestLogID to 1

In stead of that, i need the log for only last run alone.
How to find the id for the initial line of last run?
is there any way to find that?

Thanks

Posted: Fri Jul 08, 2011 6:27 am
by chulett
How about this?
ray.wurlod wrote:Why don't you specify in English what you want to achieve?
Please do that so we don't waste any more time going 'round and 'round with inappropriate solutions. :?

Posted: Fri Jul 08, 2011 6:40 am
by pandeesh
i want to mail the log details of the last run alone.
This is my requirement.

Posted: Fri Jul 08, 2011 7:10 am
by chulett
Then why are you looking for ANY "newest" id (which will get you the most recent log entry) and then going backwards to the beginning of everything in the log? As noted, you tell the DSGetNewestLogId function what type of newest id you want so there are a couple of approaches that would be more appropriate.

You can also capture the newest "starting" id, that way you either know where to stop if you are farming everything backwards, or where to start if you want things in the "proper" order in your EventDetail array.

Posted: Fri Jul 08, 2011 7:14 am
by pandeesh
Yes Craig!! Exactly!!i want to capture the newest starting id.