Can we move packed decimal to numeric in Cobol?

This document describes how packed decimal values (Computational-3) can be converted to numeric values via File Master using COBOL copybooks. The only method to get this done is to use a File Master Reformat data set, aka. One copybook for the source data structure and one for the new data structure.

What is Z in Cobol?

As shown in the chart, the Z suppresses leading zeros by turning them to a space. The Z only suppresses leading zeros, embedded zeros such as the zero in the number 2005 are not suppressed. The decimal point means print an actual decimal point in this space.

What is PIC 9 Cobol?

The layout of each field in a COBOL record is precisely specified by a PICTURE (usually abbreviated PIC ) clause. The most common ones are: PIC 9 for numbers, optionally with S (sign) or V (implicit decimal point).

How is Comp-3 calculated?

To calculate the byte-length of a comp-3 field, start with the total number of digits and divide by 2 giving a result (discarding the remainder if any), then add 1 to the result. So, a field with “pic s9(6) comp-3” would take 4 bytes (6/2 +1).

Why do we use comp-3?

COMP-3 allows signed packed decimal item where the sign stores on least significant digit (rightmost lower nibble). The sign representation uses the same bit configuration as the 4-bit sign representation in zoned decimal fields.

How to move low values to a comp-3 variable?

CAN I MOVE LOWVALUES TO A COMP-3 VARIABLE. i think its not possible, u may get some soc error. u can move low values to comp-3. I Madhu, U CAN MOVE LOW-VALUE TO A COM-3 VARIABLE. BELOW I SEND U AN EXAMPLE. BYE BYE. WORKING-STORAGE SECTION. 01 NUMA PIC 9 (05) COMP-3 VALUE 3. PROCEDURE DIVISION. just move zero to the variable. it is low-value…

What happens when you move from display to comp-3?

Both are assumed USAGE DISPLAY. Now when you do a group level move from SUB-STRUCT-1 to a COMP-3 (Packed Decimal) you effectively tell the compiler not to convert from DISPLAY to COMP-3 format. And that is what you get. Try the following modifications to your code. Using REDEFINES creates a numeric elementary item for the move.

What happens when you move character data to comp-3?

Beware: Moving character data into a COMP-3 field may give you the dreaded SOC7 data exception abend when the receiving item is referenced. This is because not all bit patterns are valid COMP-3 numbers. You have 2 Issues. COBOL has several Numeric Data Structures.