Focal Point
[SOLVED] TRIM Function adds Symbols

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6107017306

May 12, 2011, 02:39 PM
GaryB
[SOLVED] TRIM Function adds Symbols
I am converting an integer to alpha format, and removing the leading zeros, but the TRIM function adds symbols to the results.

  
-SET &PAGES = 100;
FILEDEF TEMPPAGES DISK (APPEND
-RUN
-REPEAT PAGE_LOOP FOR &PCOUNTER FROM 1 TO &PAGES;
-WRITE TEMPPAGES NOCLOSE &PCOUNTER.EVAL
-PAGE_LOOP
-CLOSE TEMPPAGES
FILEDEF PMAS DISK TEMPPAGES.MAS
-RUN
-WRITE PMAS FILENAME=TEMPPAGES, SUFFIX=FIX    , $
-WRITE PMAS FIELDNAME=PAGES,ALIAS=, USAGE=I3, ACTUAL=A3 ,$
-CLOSE PMAS
-RUN
DEFINE FILE TEMPPAGES
PAGESALPHA/A6 = TRIM('L',EDIT(PAGES),6,'0',1,'A6');
END
TABLE FILE TEMPPAGES
PRINT
PAGES PAGESALPHA

WHERE PAGES GE 33;
END
-RUN



Starting at 33 the Euro symbols displays on some of the conversion. Other symbols also appear in the sample below:

PAGES PAGESALPHA
33 33 €
34 34
35 35 €
36 36
65 65 @
66 66 €
67 67 À


Any ideas what is going on?

Gary

This message has been edited. Last edited by: GaryB,
May 12, 2011, 04:15 PM
Francis Mariani
Change your DEFINE column to this:
PAGESALPHA/A6 = TRIM('L',EDIT(PAGES),3,'0',1,'A6');
The column is defined as I3 in the Master, so the TRIM should be using 3 characters as well.


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
May 12, 2011, 04:18 PM
Tom Flynn
1.Then don't do the DEFINE and TRIM; there aren't any Leading Zeroes anyway...
2. If you must have an alpha column, your TRIM code is incorrect, S/B A3 not A6:
DEFINE FILE TEMPPAGES
PAGESALPHA/A3 = TRIM('L',EDIT(PAGES),3,'0',1,'A3');
END


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 12, 2011, 04:19 PM
Tom Flynn
Francis, change your A6 to A3, and, you beat me again...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 12, 2011, 04:26 PM
Francis Mariani
If he needs an A6 field he can have one, but with a three character TRIM function...


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
May 12, 2011, 04:33 PM
Tom Flynn
Actually, he just needs to change the Master, if the need is for an A6 column:

-WRITE PMAS FIELDNAME=PAGES,ALIAS=, USAGE=I6, ACTUAL=A6 ,$


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 12, 2011, 06:15 PM
Waz
Gary, You could also use FTOA to convert the I3, combined with LJUST you could also left justify the text.

FILEDEF TEMPPAGES DISK (APPEND
-RUN
-REPEAT PAGE_LOOP FOR &PCOUNTER FROM 1 TO &PAGES ;
-WRITE TEMPPAGES NOCLOSE &PCOUNTER.EVAL
-PAGE_LOOP
-CLOSE TEMPPAGES
FILEDEF PMAS DISK TEMPPAGES.MAS
-RUN
-WRITE PMAS FILENAME=TEMPPAGES, SUFFIX=FIX    , $
-WRITE PMAS FIELDNAME=PAGES,ALIAS=, USAGE=I3, ACTUAL=A3 ,$
-CLOSE PMAS
-RUN
DEFINE FILE TEMPPAGES
PAGESALPHA/A6 = FTOA(PAGES,'(F3)','A6');
END
TABLE FILE TEMPPAGES
PRINT
PAGES PAGESALPHA

WHERE PAGES GE 33;
END
-RUN



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

May 13, 2011, 07:12 AM
<FreSte>
Or use the FPRINT function.


COMPUTE AA/A3 = FPRINT(PAGES, 'I3', 'A3');

...

FPRINT: Converting Fields to Alphanumeric Format

Usage Notes for the FPRINT Function
The FPRINT function converts any type of field except for a text field to its alphanumeric
equivalent for display. The alphanumeric representation will include any display options that
are specified in the format of the original field.
Available Languages: reporting

FPRINT(infield, 'usageformat', outfield)
where:
infield     : Is the field to be converted.
usageformat : Is the usage format of the field to be converted, including display options. The format must be enclosed 
              in single quotation marks.
outfield    : Is the name of the output field or its format enclosed in single quotation marks. The
output field must be long enough to hold the converted number itself, with a sign and
decimal point, plus any additional characters generated by display options, such as
commas, a currency symbol, or a percent sign.

For example, D12.2 format is converted to A14 because it outputs two decimal digits,
a decimal point, a possible minus sign, up to eight integer digits, and two commas. If
the output format is not large enough, excess right-hand characters are truncated.

Usage Notes for the FPRINT Function
The output of FPRINT for numeric values is right-justified within the area required for the
maximum number of characters corresponding to the supplied format. This ensures that
all possible values are aligned vertically along the decimal point or units digit.
By default, the column title is left justified for alphanumeric fields. To right justify the
column title, use the /R reformatting option for the field.

May 16, 2011, 09:25 AM
GaryB
Thanks everyone.

Fixing the field lengths worked fine, but I have to say I liked FPRINT because it can be used in other conversions.

Gary
May 16, 2011, 10:00 AM
Francis Mariani
FPRINT - very interesting function. Can't find any documentation online, search at IBI Documentation results in "There were no results for fprint. Here are the results for print."

No documentation about it in the DevStudio 7.6.8 Help either.

Ah... it looks like a new feature in v7.7.

Nice.


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
May 16, 2011, 03:38 PM
<FreSte>
Francis,

I know this was around in 7.6.9 (not sure about the other 7.6.x releases), but it was not documented.
For 7.7 it is documented, see here

-Fred-
May 16, 2011, 03:48 PM
Francis Mariani
Merci!


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
May 16, 2011, 11:22 PM
Waz
I just checked 7.6.6 and it had FPRINT.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

May 17, 2011, 09:23 AM
Francis Mariani
I just checked 7.6.8 and it's available, but not documented.


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
May 17, 2011, 05:05 PM
Waz
I should have added, that I checked 7.6.9 and 7.6.11, and all had it.

Francis, your signature says you have 7.6.5, does it work on that version ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!