Page 1 of 1

Strip Chars at the end and not in middle

Posted: Wed Feb 25, 2009 9:51 am
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

Posted: Wed Feb 25, 2009 9:58 am
by girija
Use LEFT fiunction if you want to strip last three (fixed) character from your input value.

Posted: Wed Feb 25, 2009 10:04 am
by girija
Use LEFT fiunction if you want to strip last three (fixed) character from your input value.

Posted: Wed Feb 25, 2009 11:00 am
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.)

Posted: Wed Feb 25, 2009 11:18 am
by chulett
Why don't you post the Server routine code, then people could comment on how to do the equivalent in EE.

Posted: Wed Feb 25, 2009 3:10 pm
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.

Posted: Wed Feb 25, 2009 3:49 pm
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.

Posted: Wed Feb 25, 2009 3:54 pm
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.

Posted: Wed Feb 25, 2009 5:30 pm
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] 

Posted: Wed Feb 25, 2009 6:04 pm
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"