Page 2 of 2
Posted: Fri Aug 18, 2006 2:34 am
by rkdatastage
Hi ameyvaidya
Thanks for your response
The Routine works fine but it is not Full filling my requirement
ex1:
My String : ANSY, 3/4" SQ. DR., P/N 251-A626A,
Routine Output : P/N 251
My Desired Output has to be : P/N 251-A626A
Ex 2:
My String : BE PON AY, P/N 436A90-A602, FOR
Routine Output : P/N 436
My Desired Output has to be : P/N 436A90-A602
Can you guide me what are the necessary changes i had to do with the Code .
Thanks in Advance
RK
Posted: Fri Aug 18, 2006 3:36 am
by ameyvaidya
This line is the Key:
Code: Select all
IF NUM(InString[PnEndTester,1]) AND InString[PnEndTester,1]<>" " THEN
What i am doing here is checking for a pure numeric part number.
If the Part number can also have "-" then add
Add more conditions to this line to test for more cases. Everything else signifies the end of the part number.
Thats all
Posted: Fri Aug 18, 2006 5:54 am
by dprasanth
rkdatastage wrote:Hi ameyvaidya
Thanks for your response
The Routine works fine but it is not Full filling my requirement
ex1:
My String : ANSY, 3/4" SQ. DR., P/N 251-A626A,
Routine Output : P/N 251
My Desired Output has to be : P/N 251-A626A
Ex 2:
My String : BE PON AY, P/N 436A90-A602, FOR
Routine Output : P/N 436
My Desired Output has to be : P/N 436A90-A602
Can you guide me what are the necessary changes i had to do with the Code .
Thanks in Advance
RK
Hi,
Try adding this to ameyvaidya code . This one will just extract the P/N bit
Total_length=Len(InString)
PnStart=INDEX(InString,"P/N",1)
Start=(Length1-PnStart)+1
Pnbefore=Field(Right(InString, Start),",",1)
Ans=Pnbefore
Posted: Fri Aug 18, 2006 9:42 am
by ray.wurlod
Anyone try the MatchField() function suggestion?
Posted: Fri Aug 18, 2006 9:53 am
by chulett
Apparently, the preference is for a more brute force method.
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Fri Aug 18, 2006 10:02 am
by DSguru2B
Actually if you look at my routine, its fairly simple. Its not working because its not complete. You need an 'Ans' line. I left that upto you so that you can decide what delimiter should come between 'Part' and 'RestOfData'.
Code: Select all
Desc=TRIM(Arg1)
RestOfData=''
Part=''
EndForLoop=LEN(Desc)
FOR n = 1 TO EndForLoop
IF Desc[n,4] = 'P/N '
THEN
Part=Field(Desc[n,EndForLoop-n+1],1,2)
RestOfData=Desc[1,n-1]:Desc[n+Len(Part),EndForLoop-Len(Part)]
END
NEXT n
Ans=Part:"|":RestOfData
I delimited the two parts with a pipe.
In the transformer you can use a Field() function to get 'Part' which is before the Pipe and 'RestOfData' which is after the Pipe.
Posted: Fri Aug 18, 2006 10:06 am
by chulett
'Brute Force' does not imply complexity, per se... just relates more to the fact that the routine is iterating through the string a character at a time.
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Fri Aug 18, 2006 10:16 am
by DSguru2B
Mine is 4 characters at a time
![Wink :wink:](./images/smilies/icon_wink.gif)
Posted: Fri Aug 18, 2006 11:05 am
by chulett
Um... no, you slide over one character at a time checking for four each time.
![Razz :P](./images/smilies/icon_razz.gif)
Posted: Fri Aug 18, 2006 1:48 pm
by DSguru2B
Darn, i thought id sly by without you noticing it. But you got me
![Surprised :o](./images/smilies/icon_surprised.gif)
The OP should really come back and let us know if it worked or not. I dont have access to DS at the moment and thus cannot test out my routine
![Sad :(](./images/smilies/icon_sad.gif)