Help find DataStage function !!

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
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Help find DataStage function !!

Post 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
crouse
Charter Member
Charter Member
Posts: 204
Joined: Sun Oct 05, 2003 12:59 pm
Contact:

Post by crouse »

Sam,

Either the INDEX or COUNT functions should work for you.

The help screens give examples.

-Craig
Craig Rouse
Griffin Resouces, Inc
www.griffinresources.com
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Post 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!!
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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.
Last edited by pnchowdary on Thu Jul 07, 2005 2:29 pm, edited 3 times in total.
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Post by its_me48 »

Thanks Chowdary. I will give that a try and let the forum know probably tomorrow.

Regards !!
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Post 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!!
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post 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
its_me48
Participant
Posts: 33
Joined: Fri Apr 29, 2005 10:09 am

Post by its_me48 »

Craig & Naveen, Thanks a lot. The solution worked like a charm.

-Sam
Post Reply