Page 1 of 1

writing a message from a transform into job log

Posted: Wed Aug 31, 2005 9:55 pm
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

Posted: Wed Aug 31, 2005 10:00 pm
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)

Posted: Thu Sep 01, 2005 4:39 am
by elavenil
Hi,

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

HTWH.

Regards
Saravanan

Posted: Thu Sep 01, 2005 7:45 am
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,

what Unassigned will do

Posted: Thu Sep 08, 2005 3:03 am
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]

Posted: Thu Sep 08, 2005 6:39 am
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.

Posted: Thu Sep 08, 2005 4:27 pm
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.