View previous topic :: View next topic |
Author |
Message |
bade_miya Beginner
Joined: 10 Dec 2003 Posts: 110 Topics: 38
|
Posted: Sat Aug 21, 2004 4:50 am Post subject: MOVE CORROSPONDING IN COBOL |
|
|
Hi all,
I was trying to do a move corrosponging in cobol. According to the books i reffered, its said that both the source and destination sub fields should have the same name. But its giving me a compilation error "variable not uniquely defined." I am attaching the code i used for my program. I have two questions.
1) Is there anything wrong with this code?
2) Will it allow me to perform the below operation successfully? (what i need is to display the comp3 variables correctly in the sysout.)
****************************************************
Code: |
01 WS-OUTREC.
05 WS-OUTREC-TABLE OCCURS 10 TIMES.
10 WS-ONE-FULL-REC.
15 WS-A PIC X(04).
15 WS-B PIC 9(02).
15 WS-C PIC S9(9)V99 COMP-3.
15 WS-D PIC S9(7)V99 COMP-3.
15 WS-E PIC S9(9)V99 COMP-3.
15 WS-F PIC X(02).
15 WS-G PIC S9(12)V99 COMP-3.
15 WS-H PIC S9(10)V99 COMP-3.
15 WS-I PIC S9(12)V99 COMP-3.
15 FILLER PIC X(32).
01 WS-EDITTED.
10 WS-ONE-FULL-REC-1.
15 WS-A PIC X(04).
15 WS-B PIC 9(02).
15 WS-C PIC -Z(9).99.
15 WS-D PIC -Z(7).99.
15 WS-E PIC -Z(9).99.
15 WS-F PIC X(02).
15 WS-G PIC -Z(12).99.
15 WS-H PIC -Z(10).99.
15 WS-I PIC -Z(12).99.
15 FILLER PIC X(32).
PROCEDURE DIVISION.
MOVE '1132' TO WS-A(1) OF WS-ONE-FULL-REC(1).
MOVE 1 TO WS-B(1) OF WS-ONE-FULL-REC(1).
MOVE 1000.00 TO WS-C(1) OF WS-ONE-FULL-REC(1).
MOVE 500.00 TO WS-D(1) OF WS-ONE-FULL-REC(1).
MOVE 500.00 TO WS-E(1) OF WS-ONE-FULL-REC(1).
MOVE '1+' TO WS-F(1) OF WS-ONE-FULL-REC(1).
MOVE 2000 TO WS-G(1) OF WS-ONE-FULL-REC(1).
MOVE 500 TO WS-H(1) OF WS-ONE-FULL-REC(1).
MOVE 1500 TO WS-I(1) OF WS-ONE-FULL-REC(1).
MOVE CORR WS-ONE-FULL-REC(1) TO
WS-ONE-FULL-REC-1.
DISPLAY 'WS-ONE-FULL-REC-1 ' WS-ONE-FULL-REC-1.
****************************************************
|
Please tell me wether there is something wrong with my approch.
Thanks
bade_miya. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sat Aug 21, 2004 10:21 am Post subject: |
|
|
Bade_miya,
In your code WS-OUTREC-TABLE that occurs 40 times. So when you move you don't need to specify the subscript for the items defined at 15 level. You can move directly
to the variable like this
Code: |
MOVE '1132' TO WS-A OF WS-ONE-FULL-REC(1).
|
Notice that I did not use the subscript for WS-A variable
Once you move the variables like this you will not have any problem.
The WS-EDITED field does not exactly match the WS-ONE-FULL-REC, as the former does not have fillers. So you may get an warning message that
Code: |
"CORRESPONDING" was specified, but subordinate item "FILLER" within "WS-ONE-FULL-REC" did not qualify according to the rules for the "CORRESPONDING" phrase. Subordinate item "FILLER" was ignored.
|
Your display of WS-ONE-FULL-REC-1 will display all the comp-3 fields clearly in sysout
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
bade_miya Beginner
Joined: 10 Dec 2003 Posts: 110 Topics: 38
|
Posted: Mon Aug 23, 2004 1:52 am Post subject: |
|
|
Hi Kolusu,
You identified the problem correctly. Actually it was a silly mistake. . . Thanks for the reply Kolusu. I am attaching the modified code and output sysout so that it can be useful to someone.
*************************************************************
01 WS-OUTREC.
05 WS-OUTREC-TABLE OCCURS 10 TIMES.
10 WS-ONE-FULL-REC.
15 WS-A PIC X(04).
15 FILLER PIC X(02).
15 WS-B PIC 9(02).
15 WS-C PIC S9(9)V99 COMP-3.
15 WS-D PIC S9(7)V99 COMP-3.
15 WS-E PIC S9(9)V99 COMP-3.
15 FILLER PIC X(02).
15 WS-F PIC X(02).
15 WS-G PIC S9(12)V99 COMP-3.
15 WS-H PIC S9(10)V99 COMP-3.
15 WS-I PIC S9(12)V99 COMP-3.
15 FILLER PIC X(30).
01 WS-EDITTED.
10 WS-ONE-FULL-REC-1.
15 WS-A PIC X(04).
15 FILLER PIC X(02).
15 WS-B PIC 9(02).
15 WS-C PIC -Z(9).99.
15 WS-D PIC -Z(7).99.
15 WS-E PIC -Z(9).99.
15 FILLER PIC X(02).
15 WS-F PIC X(02).
15 WS-G PIC -Z(12).99.
15 WS-H PIC -Z(10).99.
15 WS-I PIC -Z(12).99.
15 FILLER PIC X(30).
PROCEDURE DIVISION.
MOVE '1132' TO WS-A OF WS-ONE-FULL-REC(1)
MOVE 1 TO WS-B OF WS-ONE-FULL-REC(1)
MOVE 1000.00 TO WS-C OF WS-ONE-FULL-REC(1)
MOVE 500.00 TO WS-D OF WS-ONE-FULL-REC(1)
MOVE 500.00 TO WS-E OF WS-ONE-FULL-REC(1)
MOVE '1+' TO WS-F OF WS-ONE-FULL-REC(1)
MOVE 2000 TO WS-G OF WS-ONE-FULL-REC(1)
MOVE 500 TO WS-H OF WS-ONE-FULL-REC(1)
MOVE 1500 TO WS-I OF WS-ONE-FULL-REC(1)
MOVE CORR WS-ONE-FULL-REC(1) TO
WS-ONE-FULL-REC-1.
DISPLAY 'WS-ONE-FULL-REC(1)' WS-ONE-FULL-REC(1).
DISPLAY 'WS-ONE-FULL-REC-1 ' WS-ONE-FULL-REC-1.
*************************************************************
OUTPUT SYSOUT
*************************************************************
WS-ONE-FULL-REC(1)1132 01 & & 1+ & &
WS-ONE-FULL-REC-1 1132 01 1000.00 500.00 500.00 1+ 2000
*************************************************************
Thanks .
bade_miya |
|
Back to top |
|
|
bade_miya Beginner
Joined: 10 Dec 2003 Posts: 110 Topics: 38
|
Posted: Mon Aug 23, 2004 1:55 am Post subject: |
|
|
Hi Kolusu,
You identified the problem correctly. Actually it was a silly mistake. . . Thanks for the reply Kolusu. I am attaching the modified code and output sysout so that it can be useful to someone.
*************************************************************
01 WS-OUTREC.
05 WS-OUTREC-TABLE OCCURS 10 TIMES.
10 WS-ONE-FULL-REC.
15 WS-A PIC X(04).
15 FILLER PIC X(02).
15 WS-B PIC 9(02).
15 WS-C PIC S9(9)V99 COMP-3.
15 WS-D PIC S9(7)V99 COMP-3.
15 WS-E PIC S9(9)V99 COMP-3.
15 FILLER PIC X(02).
15 WS-F PIC X(02).
15 WS-G PIC S9(12)V99 COMP-3.
15 WS-H PIC S9(10)V99 COMP-3.
15 WS-I PIC S9(12)V99 COMP-3.
15 FILLER PIC X(30).
01 WS-EDITTED.
10 WS-ONE-FULL-REC-1.
15 WS-A PIC X(04).
15 FILLER PIC X(02).
15 WS-B PIC 9(02).
15 WS-C PIC -Z(9).99.
15 WS-D PIC -Z(7).99.
15 WS-E PIC -Z(9).99.
15 FILLER PIC X(02).
15 WS-F PIC X(02).
15 WS-G PIC -Z(12).99.
15 WS-H PIC -Z(10).99.
15 WS-I PIC -Z(12).99.
15 FILLER PIC X(30).
PROCEDURE DIVISION.
MOVE '1132' TO WS-A OF WS-ONE-FULL-REC(1)
MOVE 1 TO WS-B OF WS-ONE-FULL-REC(1)
MOVE 1000.00 TO WS-C OF WS-ONE-FULL-REC(1)
MOVE 500.00 TO WS-D OF WS-ONE-FULL-REC(1)
MOVE 500.00 TO WS-E OF WS-ONE-FULL-REC(1)
MOVE '1+' TO WS-F OF WS-ONE-FULL-REC(1)
MOVE 2000 TO WS-G OF WS-ONE-FULL-REC(1)
MOVE 500 TO WS-H OF WS-ONE-FULL-REC(1)
MOVE 1500 TO WS-I OF WS-ONE-FULL-REC(1)
MOVE CORR WS-ONE-FULL-REC(1) TO
WS-ONE-FULL-REC-1.
DISPLAY 'WS-ONE-FULL-REC(1)' WS-ONE-FULL-REC(1).
DISPLAY 'WS-ONE-FULL-REC-1 ' WS-ONE-FULL-REC-1.
*************************************************************
OUTPUT SYSOUT
*************************************************************
WS-ONE-FULL-REC(1)1132 01 & & 1+ & &
WS-ONE-FULL-REC-1 1132 01 1000.00 500.00 500.00 1+ 2000
*************************************************************
Thanks .
bade_miya |
|
Back to top |
|
|
bade_miya Beginner
Joined: 10 Dec 2003 Posts: 110 Topics: 38
|
Posted: Mon Aug 23, 2004 2:06 am Post subject: |
|
|
Hi Kolusu,
You identified the problem correctly. Actually it was a silly mistake. . . Thanks for the reply Kolusu. I am attaching the modified code and output sysout so that it can be useful to someone.
*************************************************************
01 WS-OUTREC.
05 WS-OUTREC-TABLE OCCURS 10 TIMES.
10 WS-ONE-FULL-REC.
15 WS-A PIC X(04).
15 FILLER PIC X(02).
15 WS-B PIC 9(02).
15 WS-C PIC S9(9)V99 COMP-3.
15 WS-D PIC S9(7)V99 COMP-3.
15 WS-E PIC S9(9)V99 COMP-3.
15 FILLER PIC X(02).
15 WS-F PIC X(02).
15 WS-G PIC S9(12)V99 COMP-3.
15 WS-H PIC S9(10)V99 COMP-3.
15 WS-I PIC S9(12)V99 COMP-3.
15 FILLER PIC X(30).
01 WS-EDITTED.
10 WS-ONE-FULL-REC-1.
15 WS-A PIC X(04).
15 FILLER PIC X(02).
15 WS-B PIC 9(02).
15 WS-C PIC -Z(9).99.
15 WS-D PIC -Z(7).99.
15 WS-E PIC -Z(9).99.
15 FILLER PIC X(02).
15 WS-F PIC X(02).
15 WS-G PIC -Z(12).99.
15 WS-H PIC -Z(10).99.
15 WS-I PIC -Z(12).99.
15 FILLER PIC X(30).
PROCEDURE DIVISION.
MOVE '1132' TO WS-A OF WS-ONE-FULL-REC(1)
MOVE 1 TO WS-B OF WS-ONE-FULL-REC(1)
MOVE 1000.00 TO WS-C OF WS-ONE-FULL-REC(1)
MOVE 500.00 TO WS-D OF WS-ONE-FULL-REC(1)
MOVE 500.00 TO WS-E OF WS-ONE-FULL-REC(1)
MOVE '1+' TO WS-F OF WS-ONE-FULL-REC(1)
MOVE 2000 TO WS-G OF WS-ONE-FULL-REC(1)
MOVE 500 TO WS-H OF WS-ONE-FULL-REC(1)
MOVE 1500 TO WS-I OF WS-ONE-FULL-REC(1)
MOVE CORR WS-ONE-FULL-REC(1) TO
WS-ONE-FULL-REC-1.
DISPLAY 'WS-ONE-FULL-REC(1)' WS-ONE-FULL-REC(1).
DISPLAY 'WS-ONE-FULL-REC-1 ' WS-ONE-FULL-REC-1.
*************************************************************
OUTPUT SYSOUT
*************************************************************
WS-ONE-FULL-REC(1)1132 01 & & 1+ & &
WS-ONE-FULL-REC-1 1132 01 1000.00 500.00 500.00 1+ 2000
*************************************************************
Thanks .
bade_miya |
|
Back to top |
|
|
|
|