Page 1 of 1

Data exception error in COBOL

PostPosted: Tue Aug 19, 2008 9:12 pm
by vlobo
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

Re: Data exception error in COBOL

PostPosted: Wed Aug 20, 2008 2:04 am
by dick scherrer
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.