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.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     getting rid of leading zeros in an integer field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
getting rid of leading zeros in an integer field
 Login/Join
 
Gold member
posted
I have integer field (/I05)that may look like 00465 or 00010 or 01000 etc. I want to show this integer field as 465 or 10 or 1000. FTOA function changes it to alpha field and strip takes out the zeros but can someone show me how to use these 2 functions correctly so that only leading zeros will be taken out, please.
Thanks in advance,
KK


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
 
Posts: 71 | Registered: May 23, 2004Report This Post
Virtuoso
posted Hide Post
quote:
I want to show this integer field as 465 or 10


If just wanting output to surpess zeroes on the report, add an 'S', that is,
PRINT
FEILDI/I05S
...

Or is it that you want to convert it to an alpha field for some other reason, that is what FTOA is used for. Such as for concatenation to build a print line. I do that in a report here is an excerpt

CAQHRS/A7 = FTOA(CDQHRS,'(D6.2)',CAQHRS);
CAQPNTS/A7 = FTOA(CDQPNTS,'(D6.2)',CAQPNTS);
CAGPA/A7 = FTOA(CDGPA,'(D6.3)',CAGPA);
MATOTAL/A5 = FTOA(MDTOTAL,'(D4)',MATOTAL);
GAATAWA/A5 = FTOA(GDATAWA,'(D4)',GAATAWA);

I then build one print line for this special report concatenating some fields with spaces in between.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
Something like this:

TABLE FILE CAR
PRINT
SALES
COMPUTE SALESD/D6 = SALES; NOPRINT
COMPUTE SALESB/A9 = FTOA(SALES, '(D6)', 'A9');
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
END


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
Gold member
posted Hide Post
thanks, but I was using FTOA exactly like in Francis's post was giving leading zeros.
This is how mine looks like:
I have 2 fields that are scores and codes and both are alpha fields. I converted the scores field into I05 first like this.

DEFINE FILE TEST
scores/i05 = edit (scores);
codea /a04 = if codea eq 'A' then scores else 0;
codeb /a04 = if codea eq 'B' then scores else 0;
END

TABLE FILE TEST
SUM CODEA CODEB
BY PID
ON TABLE HOLD AS HOLD1
END

so that I get codea and codeb in one line for each ID.

DEFINE FILE HOLD1
CODEA /A05 = FTOA (CODEA, '(I05)', CODEA);
CODEB /A05 = FTOA (CODEB, '(I05)', CODEB);
END

TABLE FILE HOLD1
PRINT CODEA CODEB
BY PID
ON TABLE PCHOLD FORMAT HTML
END

if codea is holding 00200 and codeb is 00030, I want these codea and codeb to just be showing 200 and 30. So I tried using strip? or something else?
KK


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
 
Posts: 71 | Registered: May 23, 2004Report This Post
Virtuoso
posted Hide Post
quote:
DEFINE FILE HOLD1
CODEA /A05 = FTOA (CODEA, '(I05)', CODEA);
CODEB /A05 = FTOA (CODEB, '(I05)', CODEB);
END

TABLE FILE HOLD1
PRINT CODEA CODEB
BY PID
ON TABLE PCHOLD FORMAT HTML
END

if codea is holding 00200 and codeb is 00030, I want these codea and codeb to just be showing 200 and 30. So I tried using strip? or something else?


If you are just displaying then why bother to convert back to alpha, just use

PRINT CODEA/I05S CODEB/I05S
BY PID ....


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Gold member
posted Hide Post
Thanks Leah, but I need to convert it back to alpha because I want these scores to be a part of a string, like this:

STRING1 = NAME | CODEA | ',' | CODEB;

so that it will show

KK 220 10
etc.

so when converting it back to alpha from integer using FTOA gives me leading zeros and I need to stip off the leading zeros so that it will show like the above line and not like
KK 00220 00010 etc.


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
 
Posts: 71 | Registered: May 23, 2004Report This Post
Virtuoso
posted Hide Post
Kind of reminds me of the mess I have to convert names properly when using LCWORD. You might be able to use something like this, of course, you'd have to watch for the fact that it was only leading characters you wanted to change.

FULXNAMA/A32 = LCWORD(32,FUL_NAME,FULXNAMA);
I_IDX/I2 = IF FULXNAMA CONTAINS ' Mc' THEN
POSIT(FULXNAMA,32,' Mc',3,I_IDX) ELSE 0;
I_IDX2/I2 = I_IDX + 3;
I_IDX3/I2 = I_IDX + 4;
GETCHAR/A1 = IF I_IDX EQ 0 THEN ' ' ELSE
SUBSTR (32,FULXNAMA,I_IDX2,I_IDX3,1,GETCHAR);
NEWCHAR/A1 = UPCASE(1,GETCHAR,NEWCHAR);
FULXNAMT/A32 = IF GETCHAR EQ ' ' THEN FULXNAMA ELSE
OVRLAY(FULXNAMA,32,NEWCHAR,1,I_IDX2,FULXNAMT);
I_IDXA/I2 = IF FULXNAMT CONTAINS ' Mac' THEN
POSIT(FULXNAMT,32,' Mac',4,I_IDX) ELSE 0;
I_IDXB/I2 = I_IDXA + 4;
I_IDXC/I2 = I_IDXA + 5;
GETCHARA/A1 = IF I_IDXA EQ 0 THEN ' ' ELSE
SUBSTR (32,FULXNAMT,I_IDXB,I_IDXC,1,GETCHARA);
NEWCHARA/A1 = UPCASE(1,GETCHARA,NEWCHARA);
FULXNAMZ/A32 = IF GETCHARA EQ ' ' THEN FULXNAMT ELSE
OVRLAY(FULXNAMT,32,NEWCHARA,1,I_IDXB,FULXNAMZ);
I_IDX4/I2 = IF FULXNAMZ CONTAINS ' Iii' THEN
POSIT(FULXNAMZ,32,' Iii',4,I_IDX4) ELSE 0;
I_IDX5/I2 = I_IDX4 + 1;
GETCHAR6/A3 = IF I_IDX4 EQ 0 THEN ' ' ELSE 'III';
FULXNAMW/A32 = IF GETCHAR6 EQ ' ' THEN FULXNAMZ ELSE
OVRLAY(FULXNAMZ,32,GETCHAR6,3,I_IDX5,FULXNAMW);
I_IDX6/I2 = IF FULXNAMW CONTAINS ' Ii' THEN
POSIT(FULXNAMW,32,' Ii',3,I_IDX6) ELSE 0;
I_IDX7/I2 = I_IDX6 + 1;
GETCHAR7/A3 = IF I_IDX6 EQ 0 THEN ' ' ELSE 'II';
FULXNAME/A32 = IF GETCHAR7 EQ ' ' THEN FULXNAMW ELSE
OVRLAY(FULXNAMW,32,GETCHAR7,2,I_IDX7,FULXNAME);


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
To my surprise, FTOA does not correctly convert from I to A (I had old code lying around that suggested it did).

My example first converts from I to D and then uses FTOA on the D field, which has suppressed leading zeros.


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
Virtuoso
posted Hide Post
If you have an I05, an EDIT can move this to alpha, then follow with the TRIM function and remove leading occurences of zero.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Gold member
posted Hide Post
Thanks very much, Both!


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
 
Posts: 71 | Registered: May 23, 2004Report 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     getting rid of leading zeros in an integer field

Copyright © 1996-2020 Information Builders