Data exception error in COBOL



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

Data exception error in COBOL

Postby vlobo » Tue Aug 19, 2008 9:12 pm

Hi ther,

I am experience a very strange problem in COBOL.

I have an variable defined as COMP-3 and all I want to do is ADD 1 to it. However, when I do this via the ADD statement I get a data exception error. I have tried a number of ways changing the 1 to +1, +001 etc, the Add to Compute etc. with no success.

The strange thing is that I have a similar variable defined in this same way on which I can perform the ADD with no issues at all.

Help would be greatly appreciated.

Thanks

Vanessa
vlobo
 
Posts: 1
Joined: Tue Aug 19, 2008 9:09 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Data exception error in COBOL

Postby dick scherrer » Wed Aug 20, 2008 2:04 am

Hello Vanessa and welcome to the forums,

You need to initialize your variable to zero before executing an add/compute to that variable. The literal being used is not the problem, the variable is the problem.

All variables (especially numeric variables) should be initialized.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post