Joined: 06 Jun 2008 Posts: 8237 Location: Dubuque, Iowa, USA
when we are converting Comp-3 field (like PIC S9(9)V99 COMP-3. ) to numeric field what field length do the conveted value occupy?
This depends on what you want to convert it to. PIC S9(09)V99 USAGE DISPLAY will take 11 bytes. If you want the explicit decimal point in your output field, add a byte for it. If you want a separate sign add a byte for it. So the output field will be 11 to 13 bytes depending on your needs; if you go with DB/CR or other formatting options you could again need to add bytes.
lohithegde: please, please, please learn the difference between a bit and a byte. Your answer is completely wrong because of this difference Referenced post deleted before seeing this clarification. d
i tried this conversion, the byte length comes out to be 15 bytes. is it some standard ?????
You tried what conversion? What did you code exactly? There are defaults for the output form and length of various conversions, but you can override them.
The real question is what do you want the converted value to look like and what length do you want it to have? Once you decide that, you can use the appropriate statement to do the conversion you want.
If you need help figuring out how to do the conversion you want, show an example of the input values and what you want for output.
I had two Comp-3 variable in the input file.
PIC S9(9)V99 COMP-3. and PIC S9(11)V99 COMP-3.
I converted these field using the following OUTREC
72,6,PD,M4 and 119,7,PD,M4(first field starting from position 72 and second from 119)
In output file, the the converted value occupy 15 and 18 bytes respectively.
How this length bytes are calculated by the system internally?
You used an edit mask of M4 which has a pattern of:
A 6-byte PD value has a sign and 11 digits (e.g. X'12345678901C'). The 11 digits are substituted for the I and T characters in the M4 pattern from right to left and the sign (+ or -) is substituted for S resulting in:
which is 15 characters.
A 7-byte PD value has a sign and 13 digits (e.g. X'1234567890123C'). The 13 digits are substituted for the I and T characters in the M4 pattern from right to left and the sign (+ or -) is substituted for S resulting in: