Discussion Locked

BITs problem in COBOL - (Mainframe appli

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have done the coding of PL/I to COBOl conversion and having a problem of dealing with the BIT data type of PL/I.

I managed to convert the byte into a bit-stream after reading the data into the COBOl variables. This particular byte in PL/I represents a number which doesn't look like a number actually. But in PL/I this is easily solved by a simple assignment statement i.e., move the BITs value to a variable of data type DECIMAL. I think this assignment internally converts this bit-stream into a valid decimal value. This type of conversion is not supported in COBOl.

Please help me in cracking this problem.

-Chandra

5 replies

by john.mallonee

I'm not sure what your data looks like, but it sounds like you're trying to convert data that is hexadecimal into a numeric format in the COBOL program. If the data is binary numeric, you could have a character field (PIC X) which is redefined as binary (USAGE COMP field). You could then use the COMP field or move it to a field with any valid numeric format (e.g. PIC 9). Any more details on the hex representation of your data stream?

by rjeff

It 's been a long time since PL/I for me. Is the BIT datatype used to address the individual bit states within a byte, allowing multiple switches "packed" into one byte? If so, you need to test for conditional processing not as a numeric value for calculations. This could be accomplished by defining the byte as hexadecimal, assuming your compiler agrees, then testing for the hex equivalent to relvant bit patterns.
If you have to go to a numeric value be careful to confirm compiler sign assumptions for the various numeric types and not let any slip in to drive you crazy.

This discussion is closed to new replies.