Page 1 of 1

Help find DataStage function !!

Posted: Thu Jul 07, 2005 1:51 pm
by its_me48
Hello All,

I want to find the word "Reversal" from one of the column in the transformer stage from the string.
Example Column A has 100 rows, first 5 are
Client Reversal,
REVERSAL Coding W/O
Contractual Allowanced
Diversified Payment Reversal &
Patient Payment

I want to add a logic in column B which is amount field (decimal datatype).
The logic is if I find the word "Reversal" or "reversal" or "REVERSAL" in column A, I want to change Column B to negative (-) amount else leave it as positive.
Is there a function that would help me find specific word in the string?

Please help.

Thank You,
-Sam

Posted: Thu Jul 07, 2005 2:00 pm
by crouse
Sam,

Either the INDEX or COUNT functions should work for you.

The help screens give examples.

-Craig

Posted: Thu Jul 07, 2005 2:13 pm
by its_me48
Craig,

Thanks for the reply. The index or count functions are different from what I am trying to do. I want to find the word "Reversal" (case insensitive) in the string? Any idea how I would make that search case insensitive?

Thanks!!

Posted: Thu Jul 07, 2005 2:13 pm
by pnchowdary
You can use the following logic in your transformer to get the desired result

If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB = INPUTLINK.COLB * -1) Else INPUTLINK.COLB

Try it and let me know if it works for ya.

Posted: Thu Jul 07, 2005 2:18 pm
by its_me48
Thanks Chowdary. I will give that a try and let the forum know probably tomorrow.

Regards !!

Posted: Thu Jul 07, 2005 2:32 pm
by pnchowdary
There was a small error in the logic i mentioned above, Please use the below logic in your transformer

Code: Select all

If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB

Posted: Thu Jul 07, 2005 6:06 pm
by its_me48
Chowdary,

Thanks for the input.
Could you please check the below syntax. Sorry for asking lame questions but I am new to DataStage. I want to check for NULL values.
So, I want to add the below logic only if COLA is NOT NULL. How do I do it? Below logic is erroring for me.

If IsNull(INPUTLINK.COLA) = 0 AND If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB

Thanks!!

Posted: Thu Jul 07, 2005 6:37 pm
by its_me48
Looks like I might have got it...Please confirm...
Also could you please tell me if its going to find all reversals in the string; REVERSAL, Reversal, & reversal in the UPCASE(count) function below...

Thanks !!

If (IsNull(INPUTLINK.COLA) = 0 AND Count(UPCASE(INPUTLINK.COLA),"REVERSAL") > 0) Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB

Posted: Thu Jul 07, 2005 11:18 pm
by chulett
Me48, a couple of points:

You don't need to check the results of an IsNull() call against 0 or 1, even though that will work. Being a boolean, it is easier to read if you just say

If IsNull(INPUTLINK.COLA) to see if COLA is a null -or-

If Not(IsNull(INPUTLINK.COLA)) to see if COLA is not null

You don't need the not null check in your expression, it doesn't really add any value as a null string won't trigger any false positives in your Count check. You should be fine with pnchowdary's original version... and yes, because you upcase the field and check against 'REVERSAL' it will work not matter what the case in the original string.

Posted: Fri Jul 08, 2005 10:13 am
by pnchowdary
Hi Me48,

I am sorry that I didnt check the website until now. I guess all your doubts have already been cleared by craig. If still you have any problems, let me know and I will be glad to help you out.

Thanks,
Naveen

Posted: Fri Jul 08, 2005 4:07 pm
by its_me48
Craig & Naveen, Thanks a lot. The solution worked like a charm.

-Sam