Focal Point
EDIT Question - extracting characters

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

August 07, 2007, 05:06 PM
<M_RIOS75>
EDIT Question - extracting characters
I would use the following code to extract the last 2 characters for the field I need which in this case FIELD1=A10

FIELD2/A2 = EDIT(FIELD1,'$$$$$$$$99');

But the field value I'm working with can be anywhere from A10 to A28 (field is A28), how can I make this dynamic; pulling off the last 2 characters on that field?
August 07, 2007, 05:27 PM
JimRice
Hi Marvin,

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
-*

Jim


WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2
August 07, 2007, 05:34 PM
Alan
Using Functions Pg. 5-54 :

DEFINE FILE ...
-*** First trim the trailing blanks...
FLD1_TRIM/A28V = TRIMV('T', ORIGINAL_FLD, 28, ' ', 1, FLD1);
-*** Then find the true length of the data...
FLD1_LGTH/I2 = LENV(FLD1_TRIM, FLD1_LGTH);
-*** Calculate the Starting Position...
FLD1_START/I2 = FLD1_LGTH - 2 ;
-*** Substring to get the result...
FLD1_LAST2/A2 = SUBSTV(28, ORIGINAL_FLD, FLD1_START, FLD1_LGTH, FLD1_LAST2);
END


WF 7.6.6, FOCUS 7.6.4, IBM MVS/TSO, Windows 2003 Server, DB2, MSSQL
August 08, 2007, 10:17 AM
<M_RIOS75>
Thanks for the replies! I found the first response easier to follow although they were both helpful. Thanks again.