Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Convert Integer to Alpha without leading zeros and without thousands separator

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Convert Integer to Alpha without leading zeros and without thousands separator
 Login/Join
 
Expert
posted
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Silver Member
posted Hide Post
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.
 
Posts: 40 | Registered: March 10, 2004Report This Post
Platinum Member
posted Hide Post
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
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Report This Post
Gold member
posted Hide Post
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
 
Posts: 77 | Location: Baltimore | Registered: May 31, 2006Report This Post
Expert
posted Hide Post
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Convert Integer to Alpha without leading zeros and without thousands separator

Copyright © 1996-2020 Information Builders