MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MOVE CORROSPONDING IN COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Sat Aug 21, 2004 4:50 am    Post subject: MOVE CORROSPONDING IN COBOL Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Sat Aug 21, 2004 10:21 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Mon Aug 23, 2004 1:52 am    Post subject: Reply with quote

Hi Kolusu,
You identified the problem correctly. Actually it was a silly mistake. Embarassed . Smile . 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
View user's profile Send private message
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Mon Aug 23, 2004 1:55 am    Post subject: Reply with quote

Hi Kolusu,
You identified the problem correctly. Actually it was a silly mistake. Embarassed . Smile . 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
View user's profile Send private message
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Mon Aug 23, 2004 2:06 am    Post subject: Reply with quote

Hi Kolusu,
You identified the problem correctly. Actually it was a silly mistake. Embarassed . Smile . 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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group