Focal Point
[SOLVED] Retrieve last three digits in an account number

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5567058986

April 05, 2018, 06:15 PM
LarissaB
[SOLVED] Retrieve last three digits in an account number
Hi there,
I am trying to extract the last three digits from our account numbers and then concatenate those last three with other identifying fields in order to make one identifying field.

I can do everything except for extract the last (right) three digits of the account number.

Here is my issue. The field has an A16V format since our credit cards have 16 digits in them, but we also have other accounts with 8 or 9 or even 10 digits in them, based on their product type.

I have tried the EDIT, TRIM and SUBSTR functions without any luck to get the last three from all different account types.

Has anyone else tried this? Any suggestions?

Thanks,
Larissa


Sample:
Account #: Output:
5000789482 482
1042648927156478 478
1000371628731 731

This message has been edited. Last edited by: LarissaB,


Version: 8.2.03M, OS/Platform: Windows 7 & 10, Output: Excel, pdf, html
April 05, 2018, 06:28 PM
Waz
You could try using RJUST and SUBSTR

{untested}
FIELD/A3 = SUBSTR(16, RJUST(16, ACCT, 'A16'),14,16,3,'A3') ;


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

April 05, 2018, 06:53 PM
LarissaB
I owe you Waz, this worked beautifully!
Next time I wont waste two hours trying to figure it out on my own and I'm coming directly to you.

Thanks again!
-Larissa


Version: 8.2.03M, OS/Platform: Windows 7 & 10, Output: Excel, pdf, html
April 07, 2018, 10:46 AM
Tony A
Alternatively check out This link

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 09, 2018, 05:45 PM
Waz
Like the idea of a DEFINE FUNCTION for reusability.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!