Address Parsing Help Parallel Transformer

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
nekeda7
Participant
Posts: 5
Joined: Wed Jul 30, 2014 7:26 am

Address Parsing Help Parallel Transformer

Post by nekeda7 »

Source Data (sample data provided below)


AddrLn1, AddrLn2, AddrLn3
123 main st, null, null
C/O James, 456 Corporate Rd, null
C/O Greene, HR Dept, 487 Field St


Mapping Rules
If AddrLn1 has 'c/o' or 'Attn', use AddrLn2 Else AddrLn1. this is mapped to target field EmplAddrLn1

If AddrLn2 was used for ADDRESS_LINE_1, look at AddrLn3. Skip address line with 'c/o' or 'Attn'. this is mapped to target field EmplAddrLn2


I need help with function to be used in parallel transformer and proper syntax for it.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Start by looking at UpCase() so you don't have to worry about "Attn" versus "ATTN" (etc) and then Index() to determine if those substrings are present. Any answer other than zero = yes.
-craig

"You can never have too many knives" -- Logan Nine Fingers
nekeda7
Participant
Posts: 5
Joined: Wed Jul 30, 2014 7:26 am

Post by nekeda7 »

Does this look right to put in transformer for target field EmplAddrLn1

Code: Select all

If Index(UpCase(Lnk_HardCodeValues_in.ADDRESS_LINE1), "C/O" or "ATTN")<> 0 Then Lnk_HardCodeValues_in.ADDRESS_LINE2 Else Lnk_HardCodeValues_in.ADDRESS_LINE1
nekeda7
Participant
Posts: 5
Joined: Wed Jul 30, 2014 7:26 am

Post by nekeda7 »

Anyone else have any other ideas to implement this requirement????
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I deleted the duplicate 'urgent' topic you opened with this exact same question in it. Let's play here.

The code you posted is fine in spirit but the syntax is wrong. You cannot use an "or" there, you need to repeat the test for each thing tested for. And with zero being equal to FALSE and non-zero equating to TRUE you can simply things.

Code: Select all

If Index(UpCase(Lnk_HardCodeValues_in.ADDRESS_LINE1), "C/O") or Index(UpCase(Lnk_HardCodeValues_in.ADDRESS_LINE1), "ATTN") Then Lnk_HardCodeValues_in.ADDRESS_LINE2 Else Lnk_HardCodeValues_in.ADDRESS_LINE1
See if that works for you.

ps. Stage variables to hold things like the UpCase'd ADDRESS_LINE would make this more efficient.
-craig

"You can never have too many knives" -- Logan Nine Fingers
nekeda7
Participant
Posts: 5
Joined: Wed Jul 30, 2014 7:26 am

Post by nekeda7 »

Thanks chulett.

Transformer stage is not accepting that code in the derivation.Throws that red error bar


This one works though after i add comma 1 to each one. What is the 1 indicate after the address in this syntax?

If Index(UpCase(Lnk_HardCodeValues_in.ADDRESS_LINE1),"C/O", 1) OR Index(UpCase(Lnk_HardCodeValues_in.ADDRESS_LINE1),"ATTN", 1) Then Lnk_HardCodeValues_in.ADDRESS_LINE2 Else Lnk_HardCodeValues_in.ADDRESS_LINE1
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

These functions are documented and that would be explained there. It signifies the "occurrence" of the substring, here meaning the first.
-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 »

I'd be using a Standardize stage (QualityStage component) with an appropriate address rule set (e.g. USADDR).
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