Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stripping out data

Status
Not open for further replies.

mart10

MIS
Nov 2, 2007
394
GB
I am using CR XI
I have data in following possible output format

xxxxxxxxx
xxxxxxxxx-yyy
xxxxxxxxx-yyy-abcdefg
xxxxxxxxx-abcdefghij

The xxxxxxxxx is ALLWAYS 9 characters long and is present on every occasion
The yyy is ALLWAYS 3 characters long

I need to extract the other piece of data which may be there eg abcdef - This although at end is variable length
 
You could get rid of the first part using
Code:
Mid({your.field}, 10, 10)
If 'yyy' has varying values, use SPLIT on the dash and UBIND to find the number of fragments, then LENGHT to find how long it is, to get rid of the 3-character bit.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Look up those commands on HELP

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Mmmmm I understand you sending me there but this is why i came on here for some on line help to show me how to do it and then explaining the method
 
How do you distinguish "yyy" from "abcdefg" in your actual data as in the following? Is the yyy always three in length? Always the same character? AND the abcdefghij ALWAYS more then three in length? And NOT the same characters?

xxxxxxxxx-yyy
xxxxxxxxx-abcdefghij

Since the desired component can be in the same position as the yyy we need to know how you can differentiate them.

-LB
 
yyy is allways three in length but can be difeerent characters (currency code) Sometimes abcdef CAN be 3 or even 2 charaters in length it is varriable as this is company code BUT it will never be the same characters as yyy
 
That is insufficient as a method to distinguish them. It is easy to return the last element in the string, but right now that could include any of:

xxxxxxxxx
yyy
abcdefghij

So again, how do YOU know when you are seeing a company code versus a currency code in the second position?

-LB

 
xxxxxxxxx
xxxxxxxxx-yyy
xxxxxxxxx-yyy-abcdefg
xxxxxxxxx-abcdefghij

The abcde... will allways follow a - but there again this would not rule out yyy would it.

At the moment I have put in:

if ubound(split({gltnrpt.coa_code},"-")) = 3 then
split({gltnrpt.coa_code},"-")[3]
else
if ubound(split({gltnrpt.coa_code},"-")) = 2 then
split({gltnrpt.coa_code},"-")[2]

However sometimes this can bring back just the yyy and I recognise this as a currency code manually. I suppose what I could do is take the results of this and then compare with a list of currencies we have and exclude if the result is the same
 
Try using LENGTH to identify such cases, avoid it if it is three.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
mmm cant do that, as mentioned above sometimes the abcdef is abc! although I dont think abc will ever be same coding as yyy (ISO currency code)
 
I guess the best solution would be to compare the ubound value to the currency code.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top