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     EDIT Function and commas

Read-Only Read-Only Topic
Go
Search
Notify
Tools
EDIT Function and commas
 Login/Join
 
<kws999>
posted
I am new to WebFocus:
I am using the EDIT function in a DEFINE ADD prior to the report to convert data from alphanumeric (zzz,zzz.99) to numeric (999,999.99) but the edit function is not converting any data that has commas in the input field. The only fields converted are ones where the amount is less than 1000. Any suggestions?
Thank you,
Wayne
 
Report This Post
Platinum Member
posted Hide Post
You need to first remove the commas. This is easy, but for one little possibility. Let's take the easy approach first. Take a look at the following code.

DEFINE FILE CAR
ALPHAFIELD/A12 = '1,234,567.89';
NOCOMMAS/A10 = EDIT(ALPHAFIELD,'9$999$999999');
NUMFIELD/D12.2 = EDIT(NOCOMMAS);
END

TABLE FILE CAR
PRINT
ALPHAFIELD
NOCOMMAS
NUMFIELD
BY MODEL
WHERE RECORDLIMIT EQ 1
END

Your output will look something like this

MODEL ALPHAFIELD NOCOMMAS NUMFIELD
------ ----------- ---------- ------------
Jaguar 1,234,567.89 1234567.89 1,234,567.89

In case you did not already know, there are two EDIT functions. The first one above was used to strip out the commas. The second was used to convert from alpha to numeric. Hopefully, you have access to documentation in which you can look up the first function.

There is a problem with this solution, though.It assumes the commas are always in the second and sixth positions, which will not be true if the value in the alpha field is less than a million - say, 1,234.56. Alpha fields are, by default, left justified. So in this case, the sixth character is your decimal point, and the routine above would stip it out.

You can solve this problem by first right justifying the data. Do something like this:

DEFINE FILE CAR
ALPHAFIELD/A12 = '1,234.56';
RIGHTDATA/A12 = RJUST(12,ALPHAFIELD,RIGHTDATA):
NOCOMMAS/A10 = EDIT(RIGHTDATA,'9$999$999999');
NUMFIELD/D12.2 = EDIT(NOCOMMAS);
END

TABLE FILE CAR
PRINT
ALPHAFIELD
RIGHTDATA
NOCOMMAS
NUMFIELD
BY MODEL
WHERE RECORDLIMIT EQ 1
END

Now your output will look something like this:

MODEL ALPHAFIELD RIGHTDATA NOCOMMAS NUMFIELD
------ ------------ ----------- ---------- ------------
Jaguar 1,234.56 1,234.56 1234567.89 1,234.56

I hope I lined that up right. That's not easy to do here.
 
Posts: 135 | Location: Portland, OR | Registered: March 23, 2005Report This Post
<kws999>
posted
This is what I finally figured out. I did this by having a STRIP function then an EDIT function and then finally combining the two functions together as in QMF! Whew...that was tough!

EDIT( (STRIP(15, FIELDA, ',', 'A15')))

This strips out the commas and edits it for decimal all at the same time...Thank you for your help. I appreciate it.
Wayne
 
Report This Post
<JG>
posted
There is a function, ATODBL designed specifically to convert Alpha numeric to numeric format but again it requires the removal of comma's

look at the example below

DEFINE FILE CAR
XX/A12 WITH COUNTRY='1,222,333.99';
YY/D10.2=ATODBL((STRIP(12, XX, ',', 'A10')),'12', YY);
END
TABLE FILE CAR
PRINT XX YY
BY COUNTRY
END
-RUN
 
Report This Post
<DocServices>
posted
For more information on the ATODBL and/or the EDIT function, please see Chapter 9: Format Conversion Functions in the WebFOCUS Using Functions 5.3 manual (DN4500583.0904).

Hope this helps.

-Jennifer
 
Report 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     EDIT Function and commas

Copyright © 1996-2020 Information Builders