my requirement is to generate a fixed width flat file with around 200 columns. But my source do not give me all that I require for my target, hence I am required to set a default value (space for character and 0 for numeric). This I can deal with.
My other requirement is that I need to pad non null numeric value with zeros (prefix the value with adequate no. of zeros).
eg for a numeric column of size (7,2) if my value from source is 10.1 my target should have 00010.10
For this i tried using the "Null String" and "Padding" option of the column definition of a sequential file. but instead of getting a value prefixed by zeros i get it prefixed by spaces.
So i ended up using routines to manually do that.
Please help. Thanks
fixed with file as targets
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 122
- Joined: Mon Jul 05, 2004 1:33 pm
- Location: MA
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Use the Fmt() function for padding. Look it up in on-line help or in the BASIC manual. Its first argument is the value to be formatted, its second argument is a specification about how to format that value, and includes
[ width ] [ background ] justification [ conversion ] [ mask ]
In your example, you're looking for a background character of "0" and two decimal places.(The width must include character positions for decimal place, thousands delimiters, currency symbols, sign, and so on, if used.
[ width ] [ background ] justification [ conversion ] [ mask ]
In your example, you're looking for a background character of "0" and two decimal places.
Code: Select all
Fmt(TheValue, "8'0'R2")
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 122
- Joined: Mon Jul 05, 2004 1:33 pm
- Location: MA