View previous topic :: View next topic
|
Author |
Message |
shyansh_hercules Warnings : 2 New User
Joined: 12 Oct 2008 Posts: 4 Location: Pune
|
|
|
|
Please look at the example below.....
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. PGMSOC.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A.
02 BA PIC 9(18) COMP-3 VALUE 20.
01 B PIC 9(2).
PROCEDURE DIVISION.
MOVE 12 TO A.
DISPLAY "A:" A.
DISPLAY "BA:"BA.
MOVE A TO B.
DISPLAY 'B:' B.
* ADD BA TO B.
DISPLAY 'B= ',B.
STOP RUN. |
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.
A:12
BA:1 2404040404040404 // why BA contains garbage.
B:12
B= 12
If I do MOVE 12 TO BA...then it is absolutely fine and also in case of BA being USAGE IS DISPLAY ....no problem....
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
Code: |
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.....
TIA.
Rahul. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
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. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
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). |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Pay particular attention to the definition of "Group Moves". |
|
Back to top |
|
|
|