writing a message from a transform into job log

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
chowdary
Participant
Posts: 38
Joined: Thu Jun 23, 2005 11:25 am

writing a message from a transform into job log

Post by chowdary »

Hi all,

Can any one help me out to write a message from the transform to the job log file...
I have an "if then else" clause on a particular field in the transformer stage so if the value of the input column is 0 then i need to write a message in the job log as a warning message.

So please help me out so fix this problem

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

Post by ray.wurlod »

Create a Routine that returns its input argument but logs a message if that value is zero.

Code: Select all

FUNCTION WarnIfZero(Arg1)
If Unassigned(Arg1) Or IsNull(Arg1)
Then
   Ans = @NULL
End
Else
   If Arg11 = 0
   Then
      Call DSLogWarn("Zero value encountered in transformation.", "WarnIfZero")
   End
   Ans = Arg1
End
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Hi,

Alternatively, you can 'UtilityWarningToLog' or 'UtilityMessageToLog' routines from transformer.

HTWH.

Regards
Saravanan
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
If you want to use the UtilityWarningToLog routine you must call it from a stage variable since it always returns 1 and the zero value of the column will be lost.
I think Ray, being the expert he is, has sugested a routine that will work as a derivation for as many columns as you need without the need to add a stage variable foreach column and will also preserve your zero value for that column.

So now that you know what are the implications of each option concider your requirements and choose the one most sutable to your particular case.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
rony_daniel
Participant
Posts: 36
Joined: Thu Sep 01, 2005 5:44 am
Location: Canada

what Unassigned will do

Post by rony_daniel »

Hi Ray,

In your example you have mentioned Unassigned(Arg1) . Can you please explain what Unassigned will do.

Thanks & Regards,
Rony.[/b]
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You could always try looking it up in the BASIC reference manual. :wink:

It does what you would think it does from its name - returns a boolean, true if the variable was never assigned a value and false if any value was assigned, including a null value.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In BASIC, where there are no data types, there is no need to declare variables. Variables come into existence when first used.

It follows from this that, where a variable name is used as an rvalue (for example on the right hand side of an assignment statement), it may be in an "unassigned" state - that is, a state where it has never had any value assigned to it.

This can cause fatal errors. The UnAssigned() function allows for that state to be tested. There is also an Assigned() function, the logical inverse.

Variables declared to be in COMMON are automatically initialized to zero and therefore can never be in an unassigned state.
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