COMP-3 to Edited, Alpha Numeric Move



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COMP-3 to Edited, Alpha Numeric Move

Postby fornanthu » Mon Jun 11, 2012 3:09 pm

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.
Regards,
Nanthu.Y
fornanthu
 
Posts: 6
Joined: Sun Jan 31, 2010 6:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COMP-3 to Edited, Alpha Numeric Move

 

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

Postby Robert Sample » Mon Jun 11, 2012 4:56 pm

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>
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

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

Postby fornanthu » Mon Jun 11, 2012 5:22 pm

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.
Regards,
Nanthu.Y
fornanthu
 
Posts: 6
Joined: Sun Jan 31, 2010 6:25 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby chandurokzz » Mon Jun 11, 2012 5:24 pm

Thanks Robert. That makes sense :)
chandurokzz
 
Posts: 10
Joined: Wed Apr 11, 2012 12:49 pm
Has thanked: 1 time
Been thanked: 0 time

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

Postby chandurokzz » Mon Jun 11, 2012 5:29 pm

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 :)
chandurokzz
 
Posts: 10
Joined: Wed Apr 11, 2012 12:49 pm
Has thanked: 1 time
Been thanked: 0 time

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

Postby BillyBoyo » Mon Jun 11, 2012 5:39 pm

The abend means you have bad data in one of the fields. You'll need to show us more than that for further help.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

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

Postby Robert Sample » Mon Jun 11, 2012 5:45 pm

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
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post