I was a fairly good student in COBOL and my instructor asked me to work in the Lab at night to help the evening instructor. We had just set up the AS400 the year before, and I kind of learned how to use it from the beginning.
The most common error I noticed other than typing errors was a DECIMAL DATA ERROR. This is a difficult problem, because the program may compile and then it will crash when it sees the bad data. The compiler won't always find all of the programmers mistakes.
This is AS400 for "You can not do mathematics with non-numeric items."
If you have a field with the picture clause "PIC Z9" or "$$9.99", it has characters in it that are not numbers. You have to add a number to a number!
I recommend that you make a test COBOL program and try to do what the questions are asking. This will give you some of the answers you want to know.
One other main problem is that the programmer uses a numeric item before data is moved to it. There is always something in a memory location. When you make a variable you get whatever is there to begin with. Some compilers may be initializing numeric variables to 0 and alpanumeric variables to spaces, but you can not extect this to occur. It is always safe to know what is in a variable by giving it an initial value or moving a value to it to initialize it.
You can move a non-numeric value to a numeric field.
Try this Idea
01 TOTAL-FIELDS.
05 FINAL-TOTAL-9 pic 999.
05 FINAL-TOTAL-X pic 999.
FINAL-TOTAL-ROUTINE.
MOVE 976 TO FINAL-TOTAL-9.
MOVE ABC TO TOTAL-FIELDS. (CONSIDERED A GROUP MOVE)
ADD 1 TO FINAL-TOTAL-9.
Will it compile?
Will it Run?
FINAL-TOTAL-ROUTINE.
MOVE 783 TO FINAL-TOTAL-X.
MOVE ABC TO TOTAL-FIELDS. (CONSIDERED A GROUP MOVE)
IF FINAL-TOTAL-9 IS NUMERIC
ADD 1 TO FINAL-TOTAL-9.
Will it compile?
Will it Run?
Why?
Why not?
The best way to learn is to program the questions and make the compiler give you the results.
My JAVA instructor always asked all kinds of wild questions, and we always compiled everything as a test. Java is a lot more complicated than COBOL.
If you do not like my post feel free to point out your opinion or my errors.