Focal Point
Convert Integer to Alpha without leading zeros and without thousands separator

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

November 02, 2006, 03:36 PM
Francis Mariani
Convert Integer to Alpha without leading zeros and without thousands separator
I have an integer field that I'd like to convert to alpha.

Using EDIT(number) I get leading zeros.

Using FTOA(number, '(format)', outfield) I get thousand separators.

I'd like a string that has neither. I want to create a comma or tab delimited file where my numeric data is enclosed in double quotation marks (i.e. "5737299219238872") so that Excel does not assume the column is numeric.

Thank you.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 02, 2006, 03:48 PM
Francis Mariani
Could it be as simple as using a F11 field instead of a D11 field in the FTOA function?

Then I prepend and append a " to the alpha value.

 COMPUTE XAPPL_DIM_KEY/F11 = APPL_DIM_KEY; NOPRINT
 COMPUTE YAPPL_DIM_KEY/A14 = FTOA(XAPPL_DIM_KEY, '(F11)', 'A14'); NOPRINT
 COMPUTE ZAPPL_DIM_KEY/A16 = '"' || YAPPL_DIM_KEY || '"';

Except that there are leading blanks in ZAPPL_DIM_KEY, e.g.
"     596642"



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 02, 2006, 03:54 PM
TerryW
Unfortunately you cannot trick Excel into thinking a field is text simply by putting quotes around a number. This has been a know defect in Excel for years, and unless they have corrected it in the very latest version, numbers are always treated as numbers, even if there are quotes around them.

The only way to change that behavior is to put a non-numeric character in the string. I have used leading underscores successfully, although your end-users might be a little confused by it unless you explain it or add a note in the trailer.
November 02, 2006, 03:58 PM
smiths
Francis,

To remove the thousands separators, use the lowercase 'c' in the format:

-SET &NUMBER = 00123456789;
-SET &ALPHA = FTOA(&NUMBER ,'(D9c)','A9');
-TYPE ALPHA: (&ALPHA)

Regards,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
November 02, 2006, 04:03 PM
Jim_at_LM
Francis:

Here is some code we use with FTOA. "c" drops the thousands operator.

-* some stuff we do for reporting with FTOA
VERBOBJ/D13.2 =
IF COUNTER EQ 1 THEN &FLD1 ELSE



CFMT/A13 = IF COUNTER EQ 8 OR 14 …
OR 21 OR 29 THEN '(D13.2c)' ELSE '(D13c)';
NOBX/A13 = FTOA(VERBOBJ1,CFMT,NOBX);


-* and, with Dialogue Manager:

-*******************************************************************
-* DEFINE NEW FLD WITH FORMAT FROM VARIABLE RETRIEVED *
-*******************************************************************
-SET &FORMAT=&HOLD_FMT ;
-*
-SET &CFMT =IF &HOLD_FMT CONTAINS 'I' THEN '(D13c)' ELSE '(D13.2c)';
-*
DEFINE FILE YTD_MO
FLD1 / &FORMAT = &FLD ;
CFMT /A13 = '&CFMT.EVAL';
FLD /A13 = FTOA(FLD1,CFMT,FLD);


WebFOCUS 7.6.11, WINDOWS, HTML, PDF, EXCEL
November 02, 2006, 04:08 PM
Francis Mariani
I decided to not bother with any numeric column conversion.

If the file is saved as tab delimited and suffixed with .tab, and then opened in Excel, Excel prompts you with its' Text Import Wizard, where you specify that the data is delimited by tabs and where for each column you can set the data format - I chose Text and the file was opened with no problems at all.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server