help with routine needed

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

help with routine needed

Post by efxuser »

I am writing this routine to write job log to a file.The routine was working when tryin to display on screen.when i changed ot rite to a file it is giving me compilation error.Any pointers appreciated.

0027 On Error

^
End of Line unexpected, Was expecting: '!', '=', "AND", "OR", "LT", "LE",
"GT", "GE", "NE", "EQ", "MATCH", "GOSUB", "GOTO"
0037 Call DSLogFatal("Cannot open file ":Filename, "MyRoutine")

^
WARNING: Text found after final END statement






Code: Select all

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

Ans = 0

FileName =" /home/cvid/joblog.txt"

 hJob = DSAttachJob(JobName, DSJ.ERRNONE)
RealJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If RealJobName Matches "'-'1N0N"
Then
   Ans = -1  ;  
End
Else
	OpenSeq FileName To FileVar Then
	   Result = DSGetLogSummary(hJob, DSJ.LOGINFO,  StartTimeStamp, EndTimeStamp, 0)
	   WriteSeq Result to FileName Else
	   On Error
  		Call DSLogWarn("Cannot open file ":FileName, "MyRoutine")
  	   End
  	   End 
	   Call DSLogInfo(Result, "Testingkkkkkkk")
	End Else
	   Call DSLogFatal("Cannot open file ":FileName, "MyRoutine")
	   GoTo ErrorExit
	End

End
 
ErrCode = DSDetachJob(hJob)

RETURN(Ans)
EFX
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Is that your complete routine? I do not see subfunction ErrorExit?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post by efxuser »

<modified>
EFX
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post by efxuser »

my subroutine just assigns return code and logs.
I guess I am messing up the gile closing and end else...i cannot figure it out.
any help is appreciated.
EFX
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post by efxuser »

heres my another try

Code: Select all

DEFFUN OpenSequentialFile(filename, openmode, writemode, logevents) CALLING "DSU.OpenSequentialFile"

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

 Ans = 0

 hJob = DSAttachJob(JobName, DSJ.ERRNONE)
RealJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If RealJobName Matches "'-'1N0N"
Then
   Ans = -1  ; * no such job
End
Else
   Result = DSGetLogSummary(hJob, DSJ.LOGINFO, StartTimeStamp, EndTimeStamp, 0)

    Call DSLogInfo(Result, "Testingkkkkkkk")
   TargetFilePath = "/home/cvid/LL.txt"
   fvTargetFile = OpenSequentialFile(TargetFilePath, "W", "O", "Y")
   WriteSeq Result To fvTargetFile 
    Else
       Call DSLogInfo("Can not write to output file." ) 
     
      End 
End

* Detach job, ignoring errors.
ErrCode = DSDetachJob(hJob)

RETURN(Ans)
but no avail.no compiling errors but the file is not getting written to.any clues?
EFX
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You should have had compile error. DSLogInfo() within the WriteSeq statement requires two arguments. You supply only one. Also, you do not check (using FileInfo()) that the call to OpenSequentialFile() succeeds.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

First of all, in your original post your are opening the file to the pointer 'FileVar' but when you write your result you are not writing it to that pointer.
Second, your result will be a dynamic array and if you just write it out to a file, it will be all jumbled together, you need to parse the info out. Read about DSGetLogSummary() in help.

What are you trying to accomplish here? Maybe we can direct you to an easier solution.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post by efxuser »

I am trying to create a routine which will take arguments as job name, start timestamp,end timestamp and will write the log to a file whose name will be jobname_starttimestamp_endtimestamp.
Thanks for your time and guidance.
EFX
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ok, lets take a step back, you are writing a basic routine in a parallel job. Are you writing a before/after job subroutine, yes?
Input your parameters with a delimiter say pipe(|).
Inside the routine, use the field() function to split the argument.
Then create the file using the arguments. Read about the different functiaonlities of DSGetLogInfo(). Identify the correct one you want to use.
Then first get the file creating and log production part working. Then we can work onto the last piece to populate the file with the log, 'properly' portion.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
efxuser
Premium Member
Premium Member
Posts: 50
Joined: Tue Jun 24, 2008 9:00 am

Post by efxuser »

No, Iam looking to create a routine which I will be calling in the end of a sequence. So in that case the server routine can take multiple parameters correct?
EFX
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Sounds reasonable. Before you actually sit down to code, go through the basic guide and read about
1)How to create a file
2) How to write to a file
3)Different DSGetLogInfo() functions.
This will help you cut down your development time.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply