numberic data being truncated



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

Re: numberic data being truncated

Postby littlechicken » Thu Nov 04, 2010 11:56 am

I would display the input and the result field then you will see the exact field where it all goes missing and also add a record count and display that also at the same display.

this would make debugging easier for using iebeyeball the worlds best debugging tool easier to use rather than the really unpopular utility iebguess.
littlechicken
 
Posts: 25
Joined: Thu Oct 28, 2010 10:15 am
Has thanked: 0 time
Been thanked: 0 time

Re: numberic data being truncated

Postby nicole » Thu Nov 04, 2010 9:47 pm

Hi again,

OK, it seems the records are getting truncated. When I try to change the WS-DOLLARS PIC 9(3) to PIC S9(7)V99 I get a ABEND SOC7. I think it has to do with maybe how the records are unstringed.

01 WS-DOLLARS PIC S9(7)V99.
01 WS-TEMP-CENTS PIC 99.
01 WS-CENTS REDEFINES WS-TEMP-CENTS
PIC V99.

01 WS-TEMP-AMOUNT PIC 9(3)V99.

When I use a display this is what is given: 06385 when it's suppose to be 106385

I think the problem lies here:
UNSTRING COIN-IN-REC
DELIMITED BY
ALL '.'
INTO WS-DOLLARS
WITH POINTER
CTR-1
UNSTRING COIN-IN-REC
DELIMITED BY
ALL '"'
INTO WS-TEMP-CENTS
WITH POINTER
CTR-1
ADD WS-CENTS WS-DOLLARS
GIVING WS-TEMP-AMOUNT

Still not sure why I'm not allowed to change that temp amount to a value that can handle the field. Let me know if you have any ideas. Thanks in advance.
nicole
 
Posts: 23
Joined: Thu Jul 22, 2010 10:02 pm
Has thanked: 0 time
Been thanked: 0 time

Re: numberic data being truncated

Postby Robert Sample » Thu Nov 04, 2010 9:57 pm

Changing WS-DOLLARS is a start -- but your code
ADD WS-CENTS WS-DOLLARS
GIVING WS-TEMP-AMOUNT
means anything over 1000 in WS-DOLLARS will be truncated based on
01 WS-TEMP-AMOUNT PIC 9(3)V99.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: numberic data being truncated

Postby nicole » Thu Nov 04, 2010 10:05 pm

Yes I understand that, but everytime I change it I get that ABEND SOC7: The system detected a data exception.
I still can't understand it, why can't I change the pic to a larger amount to accomodate the incoming data. Maybe your right Robert, I shouldn't be a programmer.
nicole
 
Posts: 23
Joined: Thu Jul 22, 2010 10:02 pm
Has thanked: 0 time
Been thanked: 0 time

Re: numberic data being truncated

Postby Robert Sample » Thu Nov 04, 2010 10:16 pm

I could see a S0C7 if you changed WS-DOLLARS, but not if you change WS-TEMP-AMOUNT (which is what I suggested you change). The UNSTRING command doesn't really make sense the way you've used it -- it is rare for input files not to be defined with fixed formats, so UNSTRING would not be needed to manipulate the data. Based on what you've got, I would try
01  WS-DOLLARS      PIC S9(07).
01  WS-DOLLARS-CHAR PIC X(07).
.
.
.
UNSTRING COIN-IN-REC
DELIMITED BY
ALL '.'
INTO WS-DOLLARS-CHAR
WITH POINTER
CTR-1 
MOVE FUNCTION NUMVAL (WS-DOLLARS-CHAR) TO WS-DOLLARS.
and leave the rest of the code as is.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: numberic data being truncated

Postby nicole » Thu Nov 25, 2010 1:17 am

Hi there,

Sorry for the long wait for a reply from me, but I finally figured it out. It's so simple it makes me look stupid, but live and learn. I have to change the WS-DOLLARS PIC s9(3) to PIC s9(4) and the WS-TEMP-AMOUNT PIC 9(3)v99 to PIC 9(7) v99. I realized I was trying to change to many things at once. So I left program alone for a few days and when I went back to it, I could see clearly what needed to be done. Thanks for everyone's help.
nicole
 
Posts: 23
Joined: Thu Jul 22, 2010 10:02 pm
Has thanked: 0 time
Been thanked: 0 time

Re: numberic data being truncated

Postby dick scherrer » Thu Nov 25, 2010 3:10 am

Good to hear it is working - thank you for letting us know :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: numberic data being truncated

Postby littlechicken » Thu Nov 25, 2010 10:33 am

welldone

display command is your friend :) in batch.
littlechicken
 
Posts: 25
Joined: Thu Oct 28, 2010 10:15 am
Has thanked: 0 time
Been thanked: 0 time

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post