Strip Chars at the end and not in middle

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
chaks
Premium Member
Premium Member
Posts: 39
Joined: Wed Nov 22, 2006 9:21 pm
Location: MA

Strip Chars at the end and not in middle

Post by chaks »

Hi
I have a Material Number like 123AB456DFG, and I have to strip the chars at the End, so output should be like 123AB456. Previously I wrote a basic Routine and now we want it in Parallel transformer.

Can you guide me in doing this...

Thanks
girija
Participant
Posts: 89
Joined: Fri Mar 24, 2006 1:51 pm
Location: Hartford

Post by girija »

Use LEFT fiunction if you want to strip last three (fixed) character from your input value.
girija
Participant
Posts: 89
Joined: Fri Mar 24, 2006 1:51 pm
Location: Hartford

Post by girija »

Use LEFT fiunction if you want to strip last three (fixed) character from your input value.
chaks
Premium Member
Premium Member
Posts: 39
Joined: Wed Nov 22, 2006 9:21 pm
Location: MA

Post by chaks »

girija wrote:Use LEFT fiunction if you want to stirp last three (fixed) character from your input value.
Thanks Girija, sorry for the incomplete information.

There may be any number of Chars at the end (1,2,3 or 0.)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why don't you post the Server routine code, then people could comment on how to do the equivalent in EE.
-craig

"You can never have too many knives" -- Logan Nine Fingers
uegodawa
Participant
Posts: 71
Joined: Thu Apr 27, 2006 12:46 pm

Post by uegodawa »

If you can output the material number into a flat file in unix box, you can execute sed command to remove those characters.

suppose you have create a flat file (mat.txt) which contains only one column (material num)

using following command you can eliminate comma (,) and alpha.

e.g sed 's/,$//g' mat.txt | sed 's/[A-Z]*$//g' > new_mat.txt

First it will remove comma subsequently remove all alphabetic characters.
Thanks,
Upul
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... or just do the same in an External Filter stage.

In an expression or routine, you need to have a rule that specifies how many characters to remove.

You did not state such a rule. I hesitate to assume anything, but it would appear that you want the trailing non-numeric characters removed.

As requested earlier, please post your server routine code so we can be sure of the requirement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

uegodawa wrote:First it will remove comma subsequently remove all alphabetic characters.
Reread the requirements - trailing alpha characters only. Apparently up to three max. As Ray noted, we really need a more complete specification.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chaks
Premium Member
Premium Member
Posts: 39
Joined: Wed Nov 22, 2006 9:21 pm
Location: MA

Post by chaks »

Thanks all for your help,This is the Server Routine

Code: Select all

PartNo = TrimB(Arg1)

MaxLen = Len(TrimB(PartNo))

AlphaCount = MaxLen
pos = 0

LOOP
WHILE pos < MaxLen
if Alpha(PartNo[(MaxLen-pos),1])=1
then
   pos = pos + 1 
   AlphaCount = AlphaCount - 1
end
else 
Goto EndofLoop
end

Repeat

EndofLoop:

Ans = PartNo[1,AlphaCount]
My solution to this in a Parallel Transformer(please ignore the syntax mistakes if any)

Code: Select all

Var1=Convert('1234567890','*', Matnr)
Var2 = Count('*',VAR1)
Var3 = Index(VAR1,'*',VAR2)
and finally in the Derivation
Matnr[1,VAR3] 
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Server routine idea.

Code: Select all

Ans = Arg1
Loop
While Ans Matches "0X1A"
   Ans = Left(Ans, Len(Ans)-1)
Repeat
Test could be Until Ans Matches "0X1N"
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