Focal Point
Double to integer
February 01, 2008, 09:16 AM
L_GDouble to integer
Hi all,
I have the following problem...
I have a filed that contains a double values (eg. 1234.55)
I want to print only 1234.
How I can convert/format the field?
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 09:36 AM
Alan BUse the INT function.
Alan.
WF 7.705/8.007
February 01, 2008, 09:43 AM
GinnyJakesYou can also just equate it to another field defined as integer or a double with no scale. It will truncate anything after the decimal point.
FLDINT/I4=DBLFLD;
Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 01, 2008, 09:44 AM
L_GThanks
...and how I can format it like this "1,234"
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 09:52 AM
LeahDo you want to convert it to integer or just print it with a comma and no decimals?
Ginny gave the integer coversion.
I know you are new to the game, but look up the formatting of output on reports.
You can try,
PRINT FIELD/D6
the /D6
gives only the whole and no decimals, assuming the field is defined in the master with decimals
Leah
February 01, 2008, 09:57 AM
L_GSorry,
here is my case:
I have a field with decimal values and I want to convert it into a alphabetic field that is formated with comma and no decimals...
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 09:57 AM
Alan BINT1/A8 = FTOA(decfld,'(D6)','A8');
Alan.
WF 7.705/8.007
February 01, 2008, 10:04 AM
L_GThank you very much Alan B
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 10:04 AM
GinnyJakesOK, that is clearer.
DEFINE FILE CAR
DBLFLD/D7.2=1234.55;
-* If FLD_NODEC is a D format, rounding will occur. With an I format, there is no rounding. Your choice.
FLD_NODEC/I4=DBLFLD;
FLD_ALPHA/A10=FTOA(FLD_NODEC,'(D4)', 'A10');
END
TABLE FILE CAR
PRINT DBLFLD FLD_NODEC FLD_ALPHA
BY COUNTRY
END
Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 01, 2008, 10:16 AM
L_Gand another question:
I used the example of the Alan B and it works perfect but the alignment of the field is left.
how I can set it to right?
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 10:26 AM
LeahI know this may sound like a broken record, but how are you using this field?
Leah
February 01, 2008, 10:30 AM
Alan BL_G
Alpha are left justified, numeric right. You asked for alpha.
If you want it alpha AND right justified use the style sheet.
As Leah says, how are you using this field?
Alan.
WF 7.705/8.007
February 01, 2008, 10:35 AM
L_GThe output of the report is a text file (it is requirement)
Here is the file otput:
*************************
I I I
I GEN I FEB I
I I I
=I==========I==========I=
I 2,153 I I
I 1,525 I I
I I I
I 13,653 I 14,218 I
I want to justified like this:
*************************
I I I
I GEN I FEB I
I I I
=I==========I==========I=
I 2,153 I I
I 1,525 I I
I I I
I 13,653 I 14,218 I
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 10:39 AM
FrankDutchif only the output is a text file you can just say
PRINT FIELD/D6
no conversion is needed.
maybe some basic training....!
|
Frank |
| prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7 |
February 01, 2008, 10:44 AM
L_Gyes but I create one alphanumeric field that is combination other field , for example:
DEFINE FILE somefile
MYFIELD/A100 = '*'|field1|'*';
END
field1 is FTOA(decfld,'(D6)','A8');
The file output is only MYFIELD
WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
February 01, 2008, 10:47 AM
GinnyJakesRun RJUST function on it after you do the concatenation.
You might want to peruse the functions manual.
Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 01, 2008, 11:19 AM
GlendaAfter you become familiar with the available functions, you might want to create some of your own functions.
Here's one I created right after I discovered that I could create my own. It's a little crude. But if it isn't broke, don't fix it.
DEFINE FUNCTION TRUNC(NUMBER/D12.2)
NUMBER_100/D12 = NUMBER*100;
NUMBER_100_FTOA/A18 = FTOA(NUMBER_100, '(D12)', 'A18');
NUMBER_100_FTOA_NOCOMMA/A18 = STRIP(18, NUMBER_100_FTOA, ',', 'A18');
NUMBER_100_FTOA_NOSPACE/A18 = STRIP(18, NUMBER_100_FTOA_NOCOMMA, ' ', 'A18');
NUMBER_100_FTOA_ARGLEN/I9 = ARGLEN(18, NUMBER_100_FTOA_NOSPACE, 'I9');
NUMBER_100_FTOA_SUBSTR/A18 = SUBSTR(18, NUMBER_100_FTOA_NOSPACE, 1,
NUMBER_100_FTOA_ARGLEN - 2, NUMBER_100_FTOA_ARGLEN - 2, 'A18');
TRUNC/D12 = EDIT(NUMBER_100_FTOA_SUBSTR);
END
I know there are easier ways to get to what you wanted in this instance, but the funttion above will work when you truly need to truncate a number. Simply save the function and use it like an include.
Good Luck
Glenda
In FOCUS Since 1990
Production 8.2 Windows