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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
the trim function
 Login/Join
 
Platinum Member
posted
Hello,

I have some percentage fields that I need to display on a report in a certain format.

my code is as follows:
FPPCT/A10 =FTOA(pct,'(D7.2)','A10');
-*timtest
TPPCT/A10 =TRIM('T',FPPCT,10,'0',1,'A10');
DPPCT/A10 =TRIM('T',TPPCT,10,'.',1,'A10');
-* PPCT/A100 =''|FPPCT|'';
PPCT/A100 =''|DPPCT|'';


input what my code produces what I need
------ --------------------- -----------
0.01 .01 0.01
0.10 .10 0.1
1.01 1.01 1.01
1.00 1.00 1
100.00 100.00 100




Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

 
Posts: 133 | Registered: December 29, 2006Report This Post
Virtuoso
posted Hide Post
Just curious. If the calculation is giving you the decimal, why not just multiply it by 100 or use the percent display option?


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Platinum Member
posted Hide Post
any other suggestions ?




Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

 
Posts: 133 | Registered: December 29, 2006Report This Post
Virtuoso
posted Hide Post
As to suggestions, as you are only showing the percent part of your code, are you calculating the value and if I read your message correctly, if it is .01, then you want 1.00. Is there a particular reason you are creating an alpha field? As in you need it that way to concatinate with other alpha fields?

Oh and as Tony and Francis always say, please update your signature on the forum to show what platform and version you are on.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
The solution is what is called "Dynamically Formatted Virtual Fields". Look for "Applying Dynamically Formatted Virtual Fields to Report Columns" in the documentation.

Turing CENT-ZERO on will give you a zero before the decimal when an amount is less than 1. (This, of course has nothing to do with dynamically formatted fields - I always set CENT-ZERO to ON.)

Here's an example using the data you specified:

SET CENT-ZERO=ON
-RUN

DEFINE FILE CAR
PCT/D7.2 = 
IF COUNTRY EQ 'ENGLAND'   THEN 0.01 ELSE
IF COUNTRY EQ 'FRANCE'    THEN 0.10 ELSE
IF COUNTRY EQ 'ITALY'     THEN 1.01 ELSE
IF COUNTRY EQ 'W GERMANY' THEN 1.00 ELSE 100.00;

FPPCT/A8 =FTOA(PCT,'(D7.2)','A8');

PCT_FMT/A8 = 
IF EDIT(FPPCT,'$$$$$$99') EQ '00' THEN 'D7' ELSE IF EDIT(FPPCT,'$$$$$$$9') EQ '0' THEN 'D7.1' ELSE
'D7.2';
END
TABLE FILE CAR
SUM
PCT 
PCT/PCT_FMT
BY COUNTRY
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
Platinum Member
posted Hide Post
I am not calculating the value. The value comes in as a (D7.2). I am converting it to show up on the report correctly?

if the field comed in as 0.01 I need to display 0.01 on the report.

If the field codes in as .10 I need to display 0.1 on the report

If the field comes in as 1.00 I need to display 1 on the report.

One thing that seems strange is that (for example) the database shows the pct field as 0.01 however when my program see's it it is .01...with no filtering done on the field at all. Does Web Focus automatically eliminate the preceeding zero prior to the decimal?




Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

 
Posts: 133 | Registered: December 29, 2006Report This Post
Expert
posted Hide Post
By default, the zero preceding the decimal place is not displayed, turning CENT-ZERO ON displays it.

Please try the dynamically formatted field and let me know if this works for you - it should give exactly what you want.

Cheers,


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
With what you say you want, I agree with Francis, the virtual format calculation is for you. Note you will have to keep your FTOA to create the field you need for the virtual calculation. Have fun in FOCUS.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Platinum Member
posted Hide Post
The code I implemented is as follows:
FPPCT/A10 =FTOA(pct,'(D7.2)','A10');
PCT_FMT/A10 =
IF EDIT(FPPCT,'$$$$$$$$99' EQ '00' THEN 'D7' ELSE IF EDIT(FPPCT,'$$$$$$$$$9') EQ '0' THEN 'D7.1' ELSE
'D7.2'
PPCT/A100 =''|FPPCT|''

input what I getting
----- --------------
0.01 0.01 - good
0.10 0.10 - expecting - 0.1
1.00 1.0 - expecting - 1
100.10 100.10 - expecting 100.1




Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

 
Posts: 133 | Registered: December 29, 2006Report This Post
Expert
posted Hide Post
SET CENT-ZERO=ON
-RUN

DEFINE FILE CAR
PCT/D7.2 = 
IF COUNTRY EQ 'ENGLAND'   THEN 0.01 ELSE
IF COUNTRY EQ 'FRANCE'    THEN 0.10 ELSE
IF COUNTRY EQ 'ITALY'     THEN 1.01 ELSE
IF COUNTRY EQ 'W GERMANY' THEN 1.00 ELSE 100.00;

FPPCT/A8 =FTOA(PCT,'(D7.2)','A8');

PCT_FMT/A8 = 
IF EDIT(FPPCT,'$$$$$$99') EQ '00' THEN 'D7' ELSE IF EDIT(FPPCT,'$$$$$$$9') EQ '0' THEN 'D7.1' ELSE
'D7.2';
END
TABLE FILE CAR
SUM
PCT 
PCT/PCT_FMT
BY COUNTRY
END

PCT_FMT is the format of the numeric field you want to display. I think it has to be A8. It is then referenced as a field reformat here: PCT/PCT_FMT

Did you know that you can copy the code I provided here, paste it into a fex and run it on your server? The CAR file is distributed with all version of WebFOCUS, so it should be available on your WebFOCUS installation. Give it a try to see how it works.


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
quote:
PPCT/A100 =''|FPPCT|''


You don't need that.

Just display the PCT as originally calculated, but reformat it with PCT_FMT.


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
Platinum Member
posted Hide Post
Good Morning,

I want to thank you for you assistance in helping me resolve this matter. I have included the code which worked for me. My problem turned out to be that my field had spaces at the end of it and when I tried to "TRIM" the training zeroes it did not work because their was no trailiing zero's. Again, thanks alot.

NPPCT/P7.2C =pct;
-* IPPCT/D4C =NPPCT;
FPPCT/A10 = PTOA(NPPCT,'(P7.2C)',FPPCT);
TPPCT/A10 = RJUST(10,FPPCT,TPPCT);
GPPCT/A10 = TRIM('T',TPPCT,10,'0',1,'A10');
MPPCT/A10 = RJUST(10,GPPCT,MPPCT);
DPPCT/A10 = TRIM('T',MPPCT,10,'.',1,'A10');
PPCT/A100 = ''|DPPCT|'';




Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

 
Posts: 133 | Registered: December 29, 2006Report This Post
Platinum Member
posted Hide Post
Good Morning Leah,

I want to thank you for your assistance with my "TRIM" code. I have posted the solution to the problem. Just wanted to say thanks. Have a great day.




Prod: WebFOCUS 7.6.10 MRE
Oracle/Sybase
Test: DevStudio 7.6.6
WF Server 7.6.6
Report Caster 7.6.6
Web Server - Tomcat
MS Windows XP SP2
Output: HTML, Excel 2000 , PDF, CSV, DOC

 
Posts: 133 | Registered: December 29, 2006Report This Post
Virtuoso
posted Hide Post
quote:
Good Morning Leah,

I want to thank you for your assistance with my "TRIM" code. I have posted the solution to the problem. Just wanted to say thanks. Have a great day


You're most welcome. You will find this forum is a great place for help and learning. I know I get much out of what I see.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
So, you did not try the Dynamically Formatted Virtual Fields method? Two DEFINE fields instead of seven.


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
Francis, thanks for reminding about the SET CENT-ZERO=ON.
very useful now that i'm dealing with costs measured in mils.
i just put it in my edasprof.
right before the set behaviour=abnormal.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Expert
posted Hide Post
Hey, you must have the Canadian version of WF Smiler


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


Copyright © 1996-2020 Information Builders