Page 1 of 1

COMP-3 to Edited, Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 3:09 pm
by fornanthu
Hi,

Just need quick assistance as i have lost control in this stuff..

1. I want to move S9(15)V99 comp-3 to S9(15).99 , how can i do this in a better and efficient way.
2. I want to move S9(15)V99 comp-3 to S9(15)V99, on the direct move i am getting PACKED to NUMERIC NON-INTEGER is not permitted. i am just confused
3. I want to move S9(15)v99 comp-3 to X(18) with sign, how can i do this in better and efficient way.

Please someone assist me on this, looking for the response.

Re: COMP-3 to Edited Numeric, Numeric and Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 4:56 pm
by Robert Sample
1. Use MOVE. Unless you KNOW you have efficiency problems after a run-time analysis, do not -- EVER -- worry about performance. The current generation of mainframes performs tens of millions to hundreds of millions of lines of COBOL code for every second of CPU time. Unless you have something being done, literally, BILLIONS or TRILLIONS of times, then you are not likely to ever be able to see performance differences.

2. See the code below -- the Enterprise COBOL compiler does not generate an error for this, so it's something you are doing wrong in your program.

3. Your first problem is that 18 bytes is not enough to store a 17-digit number, a decimal point, and a sign. As for the rest of your question, see the code below.
       77  WS-PACKED-DECIMAL           PIC S9(15)V99 COMP-3.
       77  WS-ZONED-DECIMAL            PIC S9(15)V99.
       01  WS-VAR.
           05  WS-EDITED               PIC +9(15).99.
           05  WS-PICX                 REDEFINES WS-EDITED
                                       PIC X(19).
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           MOVE 123456789012345.67     TO  WS-PACKED-DECIMAL.
           MOVE WS-PACKED-DECIMAL      TO  WS-ZONED-DECIMAL
                                           WS-EDITED.
           DISPLAY 'SOURCE <' WS-PACKED-DECIMAL '>'.
           DISPLAY 'ZONED  <' WS-ZONED-DECIMAL '>'.
           DISPLAY 'PIC X  <' WS-PICX '>'.
produces output of
 SOURCE <12345678901234567>
 ZONED  <1234567890123456G>
 PIC X  <+123456789012345.67>

Re: COMP-3 to Edited Numeric, Numeric and Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 5:22 pm
by fornanthu
Hi,

Thanks for the reply.

Sometimes i am facing problem when i am adding S9(15)v99 + S9(15)V99.. i am getting SOC7 for this error. Please assist.

Re: COMP-3 to Edited Numeric, Numeric and Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 5:24 pm
by chandurokzz
Thanks Robert. That makes sense :)

Re: COMP-3 to Edited Numeric, Numeric and Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 5:29 pm
by chandurokzz
Hi Fornanthu

Sometimes i am facing problem when i am adding S9(15)v99 + S9(15)V99.. i am getting SOC7 for this error. Please assist.

if u can post the code, it would be helpful to help you :)

Re: COMP-3 to Edited Numeric, Numeric and Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 5:39 pm
by BillyBoyo
The abend means you have bad data in one of the fields. You'll need to show us more than that for further help.

Re: COMP-3 to Edited Numeric, Numeric and Alpha Numeric Move

PostPosted: Mon Jun 11, 2012 5:45 pm
by Robert Sample
A S0C7 abend is caused by invalid data and is one of the abends that is completely under the control of the COBOL programmer. If you use an IF <variable name> NUMERIC for each of the varaibles in your addition, and take appropriate action if the variable is not numeric, you will never get a S0C7 abend (at least, not for that addition). Pseudocode is:
IF  <variable-1> NUMERIC
AND <variable-2> NUMERIC
    ADD <variable-1> TO <variable-2> (or COMPUTE)
ELSE
   <handle invalid data>
END-IF