Search code examples
functionundefinedbasicdatastageibm-infosphere

Datastage Basic - How to Supress "previously undefined" Warning Message in Transform Function


I have a datastage routine transform function, that does something a bit more complicated than the following(Takes in Arg1 which can be null):

Ans = Len(Arg1)

In certain situations I am calling this transform function in a transform stage and for certain rows where I'm passing in a null-able Timestamp column and I believe several null values are getting passed through to my function, when I run my job through datastage director, I see "Finished (See Log)" for my transform stage and a number of warning messages are shown, they basically say this(repeated a bunch of times):

Program "ABC": Line 2, Variable "Arg1" previously undefined. Empty string used.

I've attempted to catch this condition by using the "ISNULL" function to detect it, but unfortunately my efforts have been unsuccessful, I tried the following:

If ISNULL(Arg1) THEN
   Ans = 0
END
ELSE IF Arg1 = $Null THEN
   Ans = 0
END
ELSE
   Ans = Len(Arg1)
END

Same issue, just a different line number on the warning message.

I don't understand why this is occurring, the "ISNULL" function seems to be straight forward, and I believe the error message is referring to the fact that Arg1 is null. I found some posts related to that but I don't have the direct link, is that accurate, does undefined = null in datastage basic, or can I catch this condition some other way?

I've searched extensively, most of what is written on this application is archaic and ancient and doesn't really provide any relevant information on the warning message itself. Is there a better resource for looking up relevant information on datastage warning messages, I feel as though I'm not understanding a core tenant of datastage. How do I catch this condition inside of the function and suppress the warning message using only datastage basic code(Without changing my input or column type)?


Solution

  • @RayWurlod was close, it's actually the "Assigned" function that accomplished this, so my final solution looks like:

    If NOT(ASSIGNED(Arg1)) THEN
       Ans = 0
    END
    ELSE
       Ans = Len(Arg1)
    END