02 BA PIC 9(18) COMP-3 VALUE 20.
01 B PIC 9(2).
MOVE 12 TO A.
DISPLAY "A:" A.
MOVE A TO B.
DISPLAY 'B:' B.
* ADD BA TO B.
DISPLAY 'B= ',B.
I am getting a 0C7 abend because of the add operation.....and also found the reason because the variable BA contains garbage value after MOVE 12 TO A operation.
Joined: 06 Jun 2008 Posts: 8235 Location: Dubuque, Iowa, USA
My question is....
1.after MOVE 12 TO A .... A contains 12 but BA contains garbage why??
2.Please somebody tell me the memory layout when we declare a 01 level variable with its sublevels......as i know whenever we give a name to any variable compiler gives memory to it...if we see
01 A. BLW=00000+000 0CL10
02 BA PIC 9(18) COMP-3 VALUE 20. BLW=00000+000,0000000 10P
What does the above sentence mean...which one of them acquire the actual
bytes ....or A is just given the base address of all its following sublevels.....
My question is ... Have you ever had any exposure to the internal representation of COBOL values? If so, you should know the answers already; if not, go to the manuals link at the top of the page, click on it, find the COBOL Language Reference, and read section 5.3 on the various formats of COBOL variables. Once you've done that, if you still have questions then post them.
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
In addition to reading the appropriate material in the cobol documentation, there is something you have just discovered that you should pay special attention to. . .
Just because the compiler processes some statements with no error, that is no guarantee that the compiled code will run successfully - the results may not be the desired results or the process may abend (as is the case with your 0c7).