Focal Point
[Solved] Obtaining the Right 2 char of the value in a field

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

November 28, 2011, 04:45 PM
Geri
[Solved] Obtaining the Right 2 char of the value in a field
I need to capture the right 2 char of the value in a field. The length of the values in the field is not consistent. There are 136 pages on the forum with the word right and a succesful search is not possible.

For example,

abcde - 02
abc - 03
abcdefghij = 04
abcdefgh - 05

I want the right 2 char which happen to be numbers in the case. What would be used to capture these values?

Thank you

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




Prod: WebFOCUS 7.7.05 OS:Linux; Upgrading to: WebFOCUS 8.1.05 OS:Windows; Outputs: HTML, PDF, Excel; Adapters: SAP, MySQL, Oracle incl Report Caster
November 28, 2011, 04:55 PM
Prarie
Look at this Post
November 29, 2011, 04:41 AM
Ian Dalton
Hi Geri, You could try something like the following:-

This example uses a single blank space as a delimiter to break an address line into tokens and returns the last token, which is the zip code:

TABLE FILE EMPLOYEE
PRINT ADDRESS_LN3 AND COMPUTE
LAST_TOKEN/A10 = GETTOK(ADDRESS_LN3, 20, -1, ' ', 10, LAST_TOKEN) ;
AS 'LAST TOKEN,(ZIP CODE)'
WHERE TYPE EQ 'HSM'
END

The example produces the following report:

PAGE 1
LAST TOKEN
ADDRESS_LN3 (ZIP CODE)
----------- ----------
RUTHERFORD NJ 07073 07073
NEW YORK NY 10039 10039
FREEPORT NY 11520 11520
NEW YORK NY 10001 10001
FREEPORT NY 11520 11520
ROSELAND NJ 07068 07068
JERSEY CITY NJ 07300 07300
FLUSHING NY 11354 11354


_______________________
*** WebFOCUS 8.1.05M ***
November 29, 2011, 07:00 AM
GamP
TABLE FILE CAR
PRINT COUNTRY CAR MODEL
COMPUTE LAST2/A2 = SUBSTR(24, MODEL, ARGLEN(24,MODEL,'I2')-1, ARGLEN(24,MODEL,'I2'), 2, LAST2);
END
Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
November 29, 2011, 09:41 AM
Geri
The example from your post worked perfectly!

Thank you

>>>>>>>>>>>
Here's an example using the CAR file and the CAR field(A16).

-*
DEFINE FILE CAR
RJUST_CAR/A16 = RJUST(16, CAR, RJUST_CAR);
LAST2_CAR/A2 = EDIT(RJUST_CAR,'$$$$$$$$$$$$$$99');
END
-*
TABLE FILE CAR
PRINT
CAR
RJUST_CAR
LAST2_CAR
BY COUNTRY
END




Prod: WebFOCUS 7.7.05 OS:Linux; Upgrading to: WebFOCUS 8.1.05 OS:Windows; Outputs: HTML, PDF, Excel; Adapters: SAP, MySQL, Oracle incl Report Caster