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     How do I add a leading zero?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
How do I add a leading zero?
 Login/Join
 
Gold member
posted
I have an A2 field that is determined by using the GETTOK command. I need the first character to be zero if the result is only one character. Any ideas?


WF 766
Win2K
 
Posts: 50 | Location: North Carolina | Registered: May 16, 2006Report This Post
Guru
posted Hide Post
FIELD2/A02 = IF EDIT(FIELD1,'9') EQ ' '
THEN '0' | EDIT(FIELD1, '$9')
ELSE FIELD1;

Try this.
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
<Special-K>
posted
You could turn it into a number and add 100 and edit the last 2 characters, something like

DEFINE FILE CAR
FLD1/A2=;
FLD2/I2=EDIT(FLD1);
FLD3/I3=100+FLD2;
FLD4/A3=EDIT(FLD3);
FLD5/A3=EDIT(FLD4,'$99');
END

TABLE FILE CAR
PRINT FLD1 FLD5
END
 
Report This Post
Expert
posted Hide Post
The simplest way is to use edit to conver the A2 to I2 and then back to A2:

TABLE FILE CAR
PRINT
CAR
COMPUTE TEST1/A2 = ' 3';
COMPUTE TEST2/I2 = EDIT(TEST1);
COMPUTE TEST3/A2 = EDIT(TEST2);
WHERE RECORDLIMIT EQ 1
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
Didn't work... result is still only one character

FIELD2/A02 = IF EDIT(FIELD1,'9') EQ ' '
THEN '0' | EDIT(FIELD1, '$9')
ELSE FIELD1;


WF 766
Win2K
 
Posts: 50 | Location: North Carolina | Registered: May 16, 2006Report This Post
Gold member
posted Hide Post
Converting the A2 to I2 and then back to A2 did the trick... Thanks!


WF 766
Win2K
 
Posts: 50 | Location: North Carolina | Registered: May 16, 2006Report This Post
Expert
posted Hide Post
there's always
newfield/A4='00' || oldfield ;
newfield/A4=RJUST(4,newfield,newfield);
newerfield/A2=SUBSTRING(4,newfield,3,4,2,'A2');




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
Platinum Member
posted Hide Post
Hi Suzanne,

There's a formatting option of an 'L' that can be used with numeric fields which will retain leading zeroes. I use this most when I create extract files that need leading zeroes to be retained (ON TABLE HOLD AS MYFILE FORMAT ALPHA).

Here's an example using the CAR table:

DEFINE FILE CAR
CNT/I2 WITH MODEL = CNT + 1;
A_CNT/A2 WITH MODEL = IF CNT EQ 1 THEN '1' ELSE '2';
I_CNT/I2L WITH MODEL = EDIT(A_CNT);
-*
END
TABLE FILE CAR
PRINT
CAR
MODEL
CNT
A_CNT
I_CNT
WHERE RECORDLIMIT EQ 2
END

Jim


WF DevStu 5.2.6/WF Srv 5.2.4/Win NT 5.2
 
Posts: 118 | Location: Lincoln Nebraska | Registered: May 04, 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     How do I add a leading zero?

Copyright © 1996-2020 Information Builders