February 14, 2019, 01:58 AM
MAK[SHARING] - Remove Trailing Spaces from text output (Unicode UTF-8)
Hi all,
Just thought I would again share a very simple solution that I'm sure most of you know but is not well documented. Hopefully this is not a piece of useless information.
The issue was that we have a requirement to output data to a text file and ensure that there are x number of spaces at the end of each row.
The row in the Oracle Database is set to A2000V however the maximum length in the row is 130 Characters with spaces after that.
The text file output required was that the end of the row had 8 trailing spaces.
If using a codepage like 1252 then you can set a define field to A138 and the output is fine.
However if using UNICODE the multiplication factor that accounts for the maximum of 3 Bytes will basically triple the space which in our case was adding 200+ spaces in the text file. (Even though it's not really space but bytes)
Anyway what we had to do was stipulate to WebFOCUS the number of bytes to display.
This was done by changing the define field from
DEFINE FILE REPORT_DATA
DF_MERGE_COLUMN/A138 = MERGE_COLUMN
to
DEFINE FILE REPORT_DATA
DF_MERGE_COLUMN/A138B = MERGE_COLUMN
Adding the B at the end of the field length in the define allowed us to have a text file with the correct number of spaces.
February 14, 2019, 08:15 AM
AddyCool,
Thanks for sharing
February 15, 2019, 05:52 PM
MathematicalRobI didn't know that, but wish I had; thank you!
February 15, 2019, 06:30 PM
MathematicalRobHowever, when I do get a multibyte character in one of my fields, if I use this approach, my field ends up being too narrow, and my next field starts early.
If anybody has a solution to
that, I'd love to hear it! One could convert all multibyte characters to ASCII characters at the outset, but that seems uneccessary in 2019. . .
February 16, 2019, 06:40 PM
MAKCan you give me an example of how your data is structured? Specifically where your Multibyte character is.
I haven’t tried this with a blend of ASCII and Multibyte but as we output Chinese Characters I can quite easily create a data source that does this.