All,
I have recently written a simple routine. I would like to call this routine once the job finished. i.e I would like to call it under 'AFTER JOB -ROUTINE'. But when i click the 'AFTER JOB - ROUTINE' drop down box, it is not showing my routine. why ? how should i bring my routine under this combo box ?
Subroutine - visible !!! ???
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 729
- Joined: Tue Apr 28, 2009 10:49 pm
Subroutine - visible !!! ???
Karthik
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 729
- Joined: Tue Apr 28, 2009 10:49 pm
-
- Premium Member
- Posts: 729
- Joined: Tue Apr 28, 2009 10:49 pm
I hope i have to use 'AFTER/BEFORE ROUTINE'.karthi_gana wrote:"Transform Function"ray.wurlod wrote:What is the routine type (on its General tab)?
If i choose the above said one, i see two parameters by default.
1) InputArg
2)ErrCode
But earlier i designed the routine with single argument.
what should i pass for the second parameter? how should i handle it inside the routine? what should i return from the routine ?
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
i=0
Msg=''
handle=DSAttachJob (Arg1,DSJ.ERRFATAL)
jobName=DSGetJobInfo(handle,DSJ.JOBNAME)
jobStatus=DSGetJobInfo(handle,DSJ.JOBSTATUS)
stageList=DSGetJobInfo(handle,DSJ.STAGELIST)
stageCount = Count(stageList,',')
For i=1 To stageCount+1 step 1
stageName=Field(stageList,',',i)
linkName= DSGetStageInfo(handle,stageName,DSJ.LINKLIST)
linkType = DSGetStageInfo(handle,stageName,DSJ.LINKTYPES)
linkCount= Count(linkName,',')
for j=1 To linkCount+1 step 1
linkNm = Field(linkName,',',j)
linkTy = Field(linkType,',',j)
rowCnt= DSGetLinkInfo(handle,stageName,linkNm,DSJ.LINKROWCOUNT)
Begin Case
Case linkTy=1
Msg = Msg : "\n Number of rows read from link " : linkNm : " for Stage " : stageName : " : " : rowCnt :"\n"
Case linkTy = 2
Msg = Msg : "\n Number of rows referenced from link " : linkNm : " for Stage " : stageName : " : " : rowCnt:"\n"
Case linkTy = 3
Msg = Msg : "\n Number of rows write to output link " : linkNm : " for Stage " : stageName : " : " : rowCnt:"\n"
Case @TRUE
Msg = Msg : "\n Number of rows rejected to link " : linkNm : " for Stage " : stageName : " : " : rowCnt:"\n"
End Case
Next j
Next i
ToAddress=""
FromAddress="datastage"
Subject="Run stats for Job ": jobName
SMTPServer="host"
MessageBody=Msg
FullArg = ""
If ToAddress <> "" Then
FullArg<-1> = "To:":ToAddress
End
If FromAddress <> "" Then
FullArg<-1> = "From:":FromAddress
End
If Subject <> "" Then
FullArg<-1> = "Subject:":Subject
End
If SMTPServer <> "" Then
FullArg<-1> = "Server:":SMTPServer
End
If MessageBody <> "" Then
FullArg<-1> = "Body:":MessageBody
End
Code = DSSendMail(FullArg)
Ans = DSTranslateCode(Code)
Karthik
What we call "Routines" in DataStage server jobs are actually functions. A Job Before/After routine is a real routine and does not have a variable, user-defined, list of parameters. It has 2 parameters, the first being input to the routine and the secod is the return code. Any return code value other than 0 will cause the job to abort.
Instead of assigning any error code or text to "Ans" you need to set ErrorCode.
Instead of assigning any error code or text to "Ans" you need to set ErrorCode.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Mostly, however, you have to use the function type "Before/After Subroutine". Before you make the change, copy the code at least to your clipboad, because you may lose the code when making the change.
A before/after subroutine has precisely two arguments.
A before/after subroutine has precisely two arguments.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.