Page 1 of 1

Job Logs in Universe table ?

Posted: Wed Dec 20, 2006 3:00 pm
by mujeebur
Hi,

In which Universe table the Job log will be stored ? I want to write a routine to get the seq file with the job logs.

Yes, I can get the job logs via DSGetJobInfo and LinkRowCounts..etc. But I want to get it from Universe Tables.

Appreciated your help.

Posted: Wed Dec 20, 2006 3:13 pm
by chulett
You don't need 'Universe tables' for this, per se. Write your routines using the appropriate DSGetLog functions:

DSGetLogNewestId
DSGetLogEntry

The online help for the latter has an good example on how to do exactly that.

Posted: Wed Dec 20, 2006 3:29 pm
by mujeebur
The reason I am asking for this, I already wrote a routine which scans thru the job to get the OCI or PxOracle Stages ( given a ServerJob, Px Job) and find out all the links for that OCI/PxStage. And find the Link Counts for Input and Reject/OutPut links (i.e LinkTypes of 1 , 3 ). writes in to Seq File.

But what happens when run routine for Server Job gives the error as 'Unknown Stagename in the <jobname>'

Here is my routine::

* Atatched the Job

LinkRowCount = -1

JobHndle = DSAttachJob(DS_JOB_NAME, DSJ.ERRFATAL)
If NOT(JobHndle) Then
Call DSLogFatal("Job Attach Failed->":DS_JOB_NAME, "JobControl")
Ans = 1
Return ( Ans )
End

* To get the Stages of Type
Call DSGetStagesOfType(TempJobStageList, DS_JOB_NAME, "PxOracle" )

If Trim(TempJobStageList) = '' Then
Call DSGetStagesOfType(TempJobStageList2, DS_JOB_NAME, "ORAOCI9")
JobStageList = TempJobStageList2
End
Else
JobStageList = TempJobStageList
End

Call DSLogInfo("Stages OF Type ":JobStageList ,DS_JOB_NAME)

KnowLinkTypes = DSGetStageInfo (JobHndle,Trim(JobStageList) , DSJ.LINKTYPES)
Call DSLogInfo("******************LinkTypes ":KnowLinkTypes,DS_JOB_NAME)

* Get Stage Counts from the Job
JobStageCount= Count(JobStageList,',') + 1
Call DSLogInfo("SatgeCount":JobStageCount,DS_JOB_NAME)


* Loop thru all the Stages
For StageLoop =1 To JobStageCount Step 1

JobStageName = Field(JobStageList,",",StageLoop)
Call DSLogInfo("Got the StageName->":JobStageName,DS_JOB_NAME)

MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE)
Call DSLogInfo("Finding StageType before linkTypes->":MyStageType,DS_JOB_NAME)

KnowLinkTypes = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.LINKTYPES)

* Or KnowLinkTypes= or KnowLinkTypes = or KnowLinkTypes = or KnowLinkTypes =
If ( KnowLinkTypes = DSJE.BADHANDLE or KnowLinkTypes = DSJE.BADTYPE or KnowLinkTypes = DSJE.NOTINSTAGE or KnowLinkTypes = DSJE.BADSTAGE ) Then
Call DSLogInfo("Error in bad handle Finding StageName->":Trim(JobStageName),DS_JOB_NAME)
Goto MySubRoutineControl
End

JobLinkTypes = KnowLinkTypes
Call DSLogInfo("Know Link Types":KnowLinkTypes ,DS_JOB_NAME)


MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE)
Call DSLogInfo("*******StageType ->":MyStageType ,DS_JOB_NAME)

* Get Link Lists from the Job
JobLinkList = DSGetStageInfo (JobHndle,Trim(JobStageName),DSJ.LINKLIST )
If Not(JobLinkList) Then
Call DSLogInfo("returning...>":Trim(JobStageName) ,DS_JOB_NAME)
Ans = 1
Return ( Ans )
End

Call DSLogInfo("**JobLinkList->":JobLinkList,DS_JOB_NAME)


StageLinkCount= Count(JobLinkList,',') + 1
Call DSLogInfo("****StageLinkCount ->":StageLinkCount ,DS_JOB_NAME)

For LinkLoop = 1 To StageLinkCount Step 1
LinkType = Field(JobLinkTypes,",",LinkLoop)
Call DSLogInfo("**LinkType ->":Trim(LinkType) ,DS_JOB_NAME)

If ( LinkType = 1 OR LinkType = 3 ) Then
JobLinkNames = Field(JobLinkList,",", LinkLoop )
Call DSLogInfo("****JobLinkNames ->":JobLinkNames ,DS_JOB_NAME)

Call DSLogInfo("****JobLinkNames ->":JobLinkNames ,DS_JOB_NAME)
LinkRowCount = DSGetLinkInfo(JobHndle,Trim(JobStageName), JobLinkNames ,DSJ.LINKROWCOUNT )
Call DSLogInfo("****Link Count->":LinkRowCount,DS_JOB_NAME)

txt = Trim(JobStageName):'|':JobLinkNames:'|':LinkRowCount

WRITESEQ txt TO FILE else
Call DSLogFatal("Could not write the file: ":FileName, DS_JOB_NAME)
Ans = 1
Return (Ans)
End
End
Next LinkLoop


* End
Call DSLogInfo("Next Loop ....!!!!!":Trim(JobStageName) ,DS_JOB_NAME)

MySubRoutineControl:
Continue

Next StageLoop

WEOFSEQ FILE ** This is already opened earlier of the Routine , due to spalce constraint, I did not put it here the create criteria.

Ans = 0

Posted: Wed Dec 20, 2006 3:49 pm
by ray.wurlod
DataStage job logs are not stored in UniVerse tables.

They are stored in DataStage tables.

In any case, the job logs will not give you the stage names in a job.

Before we will even look at your code, please encase it in Code tags so that the indenting is preserved. You can edit the previous post; you do not need to post again.

Posted: Wed Dec 20, 2006 3:49 pm
by chulett
:? Ok, now I'm lost... how is the second post related to your original question? You first ask how to get log information from a job's log. Then you post a routine that interogates a job itself for stages and link row counts.

What are you trying to accomplish here? Fix the routine or write a new one that gets and processes information from the logs? If the former, then go back to your post and edit it to add

Code: Select all

 tags[/b] around the routine code to preserve the formating you have in there.

Posted: Wed Dec 20, 2006 4:04 pm
by mujeebur

Code: Select all


$IFNDEF JOBCONTROL.H 
$INCLUDE DSINCLUDE JOBCONTROL.H 
$ENDIF



* -------------------
* Open a  Sequentila File and write the Info 
 
Ans=0

  TempDir=TEMPDIR
  TempFile=LOAD_COUNTS_FILE

  HdrString='JobStages|JobStageLinkNames|RecCounts'

  ValidOpen = @FALSE
      FileName = TempDir:'/':TempFile
      If FileName Then
         OPENSEQ FileName TO FILE Then
            ValidOpen = @TRUE
         End Else
            CREATE FILE Then ValidOpen = @TRUE
         End
      End
      If NOT(ValidOpen) Then
         Call DSLogFatal("Could not create the file: ":FileName, FileName)
         Ans = 1
        Return ( Ans )

      End
      txt = HdrString
         WRITESEQ txt TO FILE else
            Call DSLogFatal("Could not write the file: ":FileName, FileName)
         End



* Atatched the Job

LinkRowCount = -1

JobHndle = DSAttachJob(DS_JOB_NAME, DSJ.ERRFATAL)
     	If NOT(JobHndle) Then
     	  Call DSLogFatal("Job Attach Failed->":DS_JOB_NAME, "JobControl")
     	  Ans = 1
        Return ( Ans )
    	End


* To get the Stages of Type
Call DSGetStagesOfType(TempJobStageList, DS_JOB_NAME, "PxOracle" )

If Trim(TempJobStageList) = ''  Then 
   Call DSGetStagesOfType(TempJobStageList2, DS_JOB_NAME, "ORAOCI9")
   JobStageList = TempJobStageList2
End
Else
    JobStageList = TempJobStageList
End

Call DSLogInfo("Stages OF Type ":JobStageList ,DS_JOB_NAME)

KnowLinkTypes = DSGetStageInfo (JobHndle,Trim(JobStageList) , DSJ.LINKTYPES)
Call DSLogInfo("******************LinkTypes ":KnowLinkTypes,DS_JOB_NAME)

* Get Stage Counts from the Job
JobStageCount= Count(JobStageList,',') + 1
Call DSLogInfo("SatgeCount":JobStageCount,DS_JOB_NAME)


* Loop thru all the Stages 
For StageLoop =1 To JobStageCount Step 1

  JobStageName = Field(JobStageList,",",StageLoop)
  Call DSLogInfo("Got the StageName->":JobStageName,DS_JOB_NAME)

  MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE)
  Call DSLogInfo("Finding StageType before linkTypes->":MyStageType,DS_JOB_NAME)

  KnowLinkTypes = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.LINKTYPES)

  JobLinkTypes = KnowLinkTypes 
  Call DSLogInfo("Know Link Types":KnowLinkTypes ,DS_JOB_NAME)


  MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE)
  Call DSLogInfo("*******StageType ->":MyStageType ,DS_JOB_NAME)

         * Get Link Lists from the Job
          JobLinkList     = DSGetStageInfo (JobHndle,Trim(JobStageName),DSJ.LINKLIST )
          If Not(JobLinkList) Then
            Call DSLogInfo("returning...>":Trim(JobStageName) ,DS_JOB_NAME)
            Ans = 1
            Return ( Ans )
          End

     
      Call DSLogInfo("**JobLinkList->":JobLinkList,DS_JOB_NAME)


      StageLinkCount= Count(JobLinkList,',') + 1
      Call DSLogInfo("****StageLinkCount ->":StageLinkCount ,DS_JOB_NAME)

            For LinkLoop = 1 To StageLinkCount Step 1
              LinkType = Field(JobLinkTypes,",",LinkLoop)
              Call DSLogInfo("**LinkType ->":Trim(LinkType) ,DS_JOB_NAME)

                  If ( LinkType = 1 OR LinkType = 3 ) Then 
                  JobLinkNames = Field(JobLinkList,",", LinkLoop )
                  Call DSLogInfo("****JobLinkNames ->":JobLinkNames ,DS_JOB_NAME)
                  
                     Call DSLogInfo("****JobLinkNames ->":JobLinkNames ,DS_JOB_NAME)
                     LinkRowCount = DSGetLinkInfo(JobHndle,Trim(JobStageName), JobLinkNames ,DSJ.LINKROWCOUNT )
                     Call DSLogInfo("****Link Count->":LinkRowCount,DS_JOB_NAME)
  
                     txt = Trim(JobStageName):'|':JobLinkNames:'|':LinkRowCount 

                      WRITESEQ txt TO FILE else
                      Call DSLogFatal("Could not write the file: ":FileName, DS_JOB_NAME)
                      Ans = 1
                      Return (Ans)
                      End
                  End
            Next LinkLoop 
    

   * End
   Call DSLogInfo("Next Loop ....!!!!!":Trim(JobStageName) ,DS_JOB_NAME)

Next StageLoop  

WEOFSEQ FILE

Ans = 0


The error happens at

Code: Select all

KnowLinkTypes = DSGetStageInfo (JobHndle,Trim(JobStageList) , DSJ.LINKTYPES)
Call DSLogInfo("******************LinkTypes ":KnowLinkTypes,DS_JOB_NAME)
whenever I execute for Server Job.

Posted: Wed Dec 20, 2006 5:18 pm
by ray.wurlod
DSGetStageInfo() does not take a list of stage names as its second argument. It needs a single stage name. So YOU need another loop. You probably also need a loop for the links within a stage.

Code: Select all

Message = "Link Row Counts"

StageList = Convert(",", @FM, DSGetJobInfo(hJob, DSJ.STAGELIST))
If Len(StageList) > 0 
Then

   Loop

      Remove StageName From StageList Setting MoreStages

      LinkList = Convert(",", @FM, DSGetStageInfo(hJob, StageName, DSJ.LINKLIST))
      Loop

         Remove LinkName From LinkList Setting MoreLinks
         RowCount = DSGetLinkInfo(hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
         Message<-1> = "   Stage " : Quote(StageName) : ", Link " : Quote(LinkName) : ": row count = " : RowCount

      While MoreLinks
      Repeat

   While MoreStages
   Repeat

   Call DSLogInfo(Message, "Run Statistics")

End

Posted: Thu Dec 21, 2006 9:00 am
by mujeebur
Thanks Ray, But the subroutine works for PX Job, fails only for Server Job.

The design of both jobs are same:


Server
----------
SeqStage----> Xfm------------------>ORAOCI9


Parallel
----------
SeqStage----> Xfm------------------>PxOracle

Posted: Thu Dec 21, 2006 9:04 am
by chulett
They both have three stages, sure, but other than that they're not "the same". Those are two totally different "Xfm" stages for one thing...

Posted: Thu Dec 21, 2006 9:45 am
by mujeebur
Yes, I know. DSGetStageInfo() does not take a list of stage names as its second argument.

I dont think that I am doing so. When look into the code, I have a for loop which gets the stage name from the StageList ,comma seperated output in JobStageList variable by Field satement.

Code: Select all


* Loop thru all the Stages 
For StageLoop =1 To JobStageCount Step 1 

  JobStageName = Field(JobStageList,",",StageLoop) 
  Call DSLogInfo("Got the StageName->":JobStageName,DS_JOB_NAME) 

  MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE) 
......

Posted: Fri Jan 05, 2007 1:38 pm
by karmadasai
Ok you use a loop in this case, but not below.
this routine works fine if you respect argument used by the DSGetStageInfo Function.

DSGetStageInfo (<JobHandle>, <JobStageName> ,DSJ.STAGETYPE)

Change the delimiter "," by @FM

Code: Select all


* Loop thru all the Stages 
JobStageCount = dcount(JobStageList, @FM)
For StageLoop =1 To JobStageCount Step 1 

  JobStageName = Field(JobStageList,@FM,StageLoop) 
  Call DSLogInfo("Got the StageName->":JobStageName,DS_JOB_NAME) 

  MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE) 
......


mujeebur wrote:Yes, I know. DSGetStageInfo() does not take a list of stage names as its second argument.

I dont think that I am doing so. When look into the code, I have a for loop which gets the stage name from the StageList ,comma seperated output in JobStageList variable by Field satement.

Code: Select all


* Loop thru all the Stages 
For StageLoop =1 To JobStageCount Step 1 

  JobStageName = Field(JobStageList,",",StageLoop) 
  Call DSLogInfo("Got the StageName->":JobStageName,DS_JOB_NAME) 

  MyStageType = DSGetStageInfo (JobHndle,Trim(JobStageName), DSJ.STAGETYPE) 
......

Posted: Fri Jan 05, 2007 1:55 pm
by I_Server_Whale
Welcome Aboard ! :)

Are you answering the post? If so, your sentences need not be in quotes. :?