Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMP-3 Field write out too many bytes

Status
Not open for further replies.

rebeccabarker

Programmer
Jun 24, 2004
14
US
I have a Net Express COBOL program that produces a text file where all the amount fields are declared as s9(5)v99 comp-3. When you look at the output, the amount field is 7 bytes long rather than the expected 4 bytes. Am I missing something in my compile options or have I done something wrong?

Thanks for any help!
 
The definition for this field as a display is 7 bytes. Are you sure you are not misreading the source and looking at a comment line instead of part of the actual FD?
 
Search in your Micro Focus configuration. There are many options on "how to treat" packed and/or binary's.
I know for sure that MF can handle packed right.

But be ware: COMP-3 is a typical mainframe format, suited perfectly for the 390 instruction-set to execute 'native' calculations. Micro Focus programs run on unix/windows machines on other type hardware. Those processors cannot calculate with packed-decimal data, so the compiler has to convert all the time. That might be the reason why Micro Focus treats packed-decimal differently by default.
 
Comp-3 is not normally permitted in a text file. Normally you would convert it to display, which is seven bytes in your case. For portability it should be eight, with a separate sign byte.
 
Thanks for your responses. The output from my program is in EBCDIC and is transferred to our mainframe where another system picks it up and uses it. The output file has a .txt extension on it, even though it isn't a true text file.

I am sure it is outputing 7 bytes; the recieving system is expecting 4 bytes and so it picks up the incomplete number since it is too big.

I am re-writing this from an old system. In the old stsyem it reads the amounts directly from an SQL database into a comp-3 field and then outputs it. The new system reads the amount in from a file as an s9(6)v99 and tries to move it to a comp-3 field. Perhaphs I am missing something with this move?
 
Thank you for your help. I figured out the problem. In my file control section I had made the output file organization is line sequential. This was inserting tabs into the packed fields and adding the extra bytes. When I removed this piece, the output is now 4 bytes as expected. I had no idea organization is line sequential would do that.
 
It is well documented. There are a run-time switch and a call which will suppress this action. But your solution is better as it better defines the problem. BTW, those are not tabs, they are nulls. When reading, Net Express treats them as escape characters; they are skipped but the next character is treated as data even though it may look like a control character.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top