Passing Parameters to Notification Stage

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Vishvas
Participant
Posts: 34
Joined: Sat Jun 21, 2003 3:52 am

Passing Parameters to Notification Stage

Post by Vishvas »

Hi,

Can we pass parameters to a Notification Stage of a sequencer? I tried it out, but it was not working. If we can't use #param#, then what is the way to pass Reciepients Address to a Notification Stage?

Arun
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This has been answered in the past.
When you search specify "parameters" and "notification" and select "search for all".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sdevashis
Participant
Posts: 54
Joined: Thu Oct 09, 2003 4:00 am
Location: India

Post by sdevashis »

Well something which I faced recently and and may be this can be of some help to you....

It seems that you are trying to send the reciepients address. In such cases use a ROUTINE to get the job done and not a Notification....

I used a function and a routine which helped me a lot in long run.

I have a config file storing the mail server and recipients

========================================
C:\CONF\ETLCONF.conf
=======================================
#MAIL_SERVER
BANGALOREPC

#USER_ACCOUNT
sdevashis@yahoo.com ; devashis@hotmail.com

#SERVICE_ACCOUNT
etl_mailing_service@yourcompany.com


=======================================
Function to read the parameters from config file
========================================
Function ReadParam(Arg1)

EV = 0
OpenSeq "C:\CONF\ETLCONF.conf" To FileVar Else
Ans = "ERROR"
End

LOOP

ReadSeq FileLine From FileVar

On Error
Ans = "ERROR"
End

Then
If EV=1 Then
Ans = FileLine
CloseSeq FileVar
Exit
END

If FileLine = "#":Arg1 Then
EV = 1
End

End

REPEAT

CloseSeq FileVar

====================================



=====================================
Routine "SendMail" [BEFORE/AFTER routine]
======================================

$INCLUDE DSINCLUDE JOBCONTROL.H
DEFFUN ReadParam(Arg1) Calling "DSU.ReadParam"

V_MAIL_SERVER = ReadParam("MAIL_SERVER")
V_USER_ACCOUNT = ReadParam("USER_ACCOUNT")
V_SERVICE_ACCOUNT= ReadParam("SERVICE_ACCOUNT")

ErrorCode = 0

JobHandle = DSAttachJob(InputArg,DSJ.ERRNONE)
Report=DSMakeJobReport(JobHandle, 1, "CRLF" )

Reply = DSSendMail("server:":V_MAIL_SERVER:"\nFrom:":V_SERVICE_ACCOUNT:"\nTo:":V_USER_ACCOUNT:"\nSubject:":InputArg:"\nBody:":Report)

Begin Case
Case Reply = DSJE.NOERROR
ErrorCode = 0
Case @True
ErrorCode = 1
End Case

==============================================


So you are through.....you can use the routine in the sequences and give the job name as a parameter to the Routine and it will mail the details to all the reciepients defined on the config file and through the mail server described in the config file.

These two things will help you a lot when you have to change the reciepients number of time or you are migrating the project from one place to another when the mail server name changes.

Hope this helps.
Last edited by sdevashis on Tue Dec 30, 2003 2:05 pm, edited 2 times in total.
/*Devashis*/
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

Post by olgc »

Hi,

Where do you guys code the following function: Datastage Designer or Datastage Manager? The error is:

0002 Function ReadParam(Arg1)
^
"FUNCTION" unexpected, Was expecting: Array Name, Variable name,

When you compile it with Datastage Designer.

Thanks,

=======================================
Function to read the parameters from config file
========================================

Function ReadParam(Arg1)

EV = 0
OpenSeq "C:\CONF\ETLCONF.conf" To FileVar Else
Ans = "ERROR"
End

LOOP

ReadSeq FileLine From FileVar

On Error
Ans = "ERROR"
End

Then
If EV=1 Then
Ans = FileLine
CloseSeq FileVar
Exit
END

If FileLine = "#":Arg1 Then
EV = 1
End

End

REPEAT

CloseSeq FileVar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You create routines in the Routines branch of the Repository. You can do this from Designer or Manager; either opens the same edit window.

You do not include the FUNCTION declaration; this is automatically created for you by the edit window. Similarly you do not include the RETURN function, which is also automatically generated. However you do have to ensure that the return value is assigned to the return variable, whose name is (non-negotiably) Ans.

You compile and test it within the Routines edit window.
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