x12 substring manipulation
How do I manipulate a string in Ensemble DTL (X12 document) to extract a string starting from the right, or end, of the string?
I need to have 10 digit phone numbers, however some of the source data records include the "1" for the long distance dialing and I need to exclude this.
I have tried using Right(), SubStr(), and even SubString(string,*,-10) but it will not compile.
I find it hard to believe that Ensemble does not have the ability to read a string from the right.
Thank you for any assistance.
If you've specified the language as "basic", then I would expect the Right() function to be available. Otherwise, for "objectscript", you'll want to use something like $extract(string,*-10,*).
Edit: if there's some reason to prefer using the methods supplied by the wizard, you could also do something like this: ..SubString(string,..Length(string)-10)
I was able to get the 'Edit' suggestion (..SubString(string,..Length(string)-10)) to compile, but it did not remove the leading character as intended.
I was also able to get the $extract to compile, but still not getting it to remove the leading character. However, I feel this is the correct route for me to pursue. Thanks
Note that for your specific case, our examples have been off by one:
You actually want something like this:
If you're not sure whether the transformation is being applied at all, maybe do something more dramatic, like $reverse, as a sanity check?
Thanks! I did figure out that -9 was the value I needed and it is now working.