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     [SOLVED] Searching for a better way...

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Searching for a better way...
 Login/Join
 
Master
posted
We have been messing with this all day, thinking there has to be a better way to strip zeros and trailing spaces from an Integer that's been converted to an alpha.

This is the best we could come up with.

We use PTOA so it doesn't create the preceding zeros. We use STRREP to strip off the preceding spaces, then have to use TRUNCATE to remove the trailing spaces. What a task.

SET ASNAMES=MIXED

-DEFAULTH &MULTIPLIER = 13713;
-DEFAULTH &MYCNT = _FOC_NULL;

TABLE FILE CAR
SUM
	COMPUTE MYCNT/A11V = STRREP(11, PTOA(CNT.DST.COUNTRY*&MULTIPLIER, '(P11)', 'A11V'), 1, ' ', 0, '', 11, MYCNT);
ON TABLE HOLD AS MYHOLD FORMAT INTERNAL
END

-RUN
-READFILE MYHOLD

-SET &MYCNT = TRUNCATE(&MYCNT);
-TYPE MYCNT = ->&MYCNT<-

END


Is it me or is the 100x harder than it should be based on any other language out there. We are unsure why IBI auto pads and creates preceding zeros.

This message has been edited. Last edited by: GavinL,



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
If you happen to know what the length of your integer will be it gets a lot simpler. In your example the length is 5 and as loing as the first COMPUTE has a length of 5 it doesn't appear to matter what you use as the length for the alpha field - although obviously you would want them the same.

I don't know if there is a way to figure out what the length of an integer is dynamically.

TABLE FILE CAR
SUM
    COMPUTE GP/I5 = CNT.DST.COUNTRY*&MULTIPLIER;
    COMPUTE GP2/A5=EDIT(GP);
END


Or (better) you can use a double precision number as the first COMPUTE and the FTOA in the second. Note the lower case c in the second parameter which removes the comma

TABLE FILE CAR
SUM
    COMPUTE GP/D10 = CNT.DST.COUNTRY*&MULTIPLIER;
    COMPUTE GP3/A10=FTOA(GP, '(D10c)', 'A10');
END


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Virtuoso
posted Hide Post
We use LJUST instead of STRREP for this particular purpose.
And sometimes we use FPRINT instead of PTOA, but that doesn't make a lot of difference:
-DEFAULTH &MULTIPLIER = 13713;

TABLE FILE CAR
SUM
	COMPUTE MYCNT/A11V = LJUST(11, FPRINT(CNT.DST.COUNTRY*&MULTIPLIER, 'P11', 'A11'), MYCNT);
END


Still not very convenient, but perhaps a small improvement.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Master
posted Hide Post
Look at TRIM and TRIMV function.




Scott

 
Posts: 865 | Registered: May 24, 2004Report This Post
Master
posted Hide Post
I'll play with it some more today with this tips.

Thanks for your input.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report 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     [SOLVED] Searching for a better way...

Copyright © 1996-2020 Information Builders