Page 1 of 1

Passing Parameters to Notification Stage

Posted: Mon Dec 29, 2003 2:50 am
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

Posted: Mon Dec 29, 2003 4:07 am
by ray.wurlod
This has been answered in the past.
When you search specify "parameters" and "notification" and select "search for all".

Posted: Tue Dec 30, 2003 1:18 pm
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.

Posted: Tue Nov 23, 2004 4:09 pm
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

Posted: Tue Nov 23, 2004 8:34 pm
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.