IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Whether my MOVE CORRESPONDING will work or not


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
daves

New User


Joined: 30 Mar 2007
Posts: 7
Location: Bangalore

PostPosted: Wed May 16, 2007 10:37 pm
Reply with quote

Hi ,

I just want to know whether my MOVE CORRESPONDING will work or not?If NO then why???


Code:

01 WS-DATE-I.
     05 WS-CENTURY          PIC X(2).
     05 WS-YEAR                PIC X(2).
     05 FILLER                    PIC X.   
     05 WS-MONTH             PIC X(2).
     05 FILLER                    PIC X.
     05 WS-DAY                 PIC X(2).

01 WS-DATE-O.
     05 WS-CENTURY          PIC 99.
     05 WS-DATE-6.     
         10 WS-YYMM.
             15 WS-YEAR        PIC 99.
             15 WS-MONTH     PIC 99.
         10 WS-DAY             PIC 99.

MOVE CORRESPONDING    WS-DATE-I   TO   WS-DATE-O.

Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed May 16, 2007 10:39 pm
Reply with quote

What happened when you tested your code?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed May 16, 2007 10:53 pm
Reply with quote

Off hand I'd say no......
Though a little redefinition could get it to work.


"The two subordinate items have the same name and the same qualifiers up to but not including identifier-1 and identifier-2."
Back to top
View user's profile Send private message
daves

New User


Joined: 30 Mar 2007
Posts: 7
Location: Bangalore

PostPosted: Wed May 16, 2007 11:02 pm
Reply with quote

Hi,

I haven't tested this yet though i doubt it will work
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu May 17, 2007 12:46 am
Reply with quote

daves,

These are the types of things that you should try yourself. Write a small program that does it. If you get into that habit of doing this you will never forget.

By the way, MOVE CORRESPONDING is considered a bad practice. We have many millions of lines of COBOL here and I have yet to see it used.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu May 17, 2007 12:57 am
Reply with quote

Hello,

As has already been posted, a very good practice is to have a "little bit of test code" that is used for this kind of testing. Not an application program, but something you can experiment with. If you run your test and then try variations, you can learn much.

As far as this
Quote:
though i doubt it will work
what do you doubt?

I haven't put it on the system here, but i believe it may work as is.

As was also posted, not only is it considered bad practice many places, but it is not permitted to be promoted to production.
Back to top
View user's profile Send private message
daves

New User


Joined: 30 Mar 2007
Posts: 7
Location: Bangalore

PostPosted: Thu May 17, 2007 1:20 am
Reply with quote

Hi.

i got it tested with minor redefinition and it's now working.

Thanks all for your advices
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu May 17, 2007 2:12 am
Reply with quote

daves wrote:
i got it tested with minor redefinition and it's now working.
Feel free to post your "minor redefinition".....All of us, and generations of followers, would like to know your answer....
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Wed May 23, 2007 7:47 pm
Reply with quote

Daves,

Several of us have cautioned you that MOVE CORRESPONDING is considered bad practice. We could explain to you why this is so but I notice you didn't ask.

Does your shop conduct code walkthroughs? If not, then no need to worry about any of this.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed May 23, 2007 8:16 pm
Reply with quote

TG Murphy wrote:
Several of us have cautioned you that MOVE CORRESPONDING is considered bad practice. We could explain to you why this is so but I notice you didn't ask.
Several of us?
Yes, please explain why it is considered a bad practice.
Back to top
View user's profile Send private message
shane

New User


Joined: 17 May 2007
Posts: 11
Location: Phoenix,Arizona

PostPosted: Wed May 23, 2007 8:22 pm
Reply with quote

Hi,

I also want to know why using MOVE CORRESPONDING is considered a bad practice.
Can you plzz explain it for us???
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Thu May 24, 2007 6:18 pm
Reply with quote

1. Readability.

2. Impact Analysis.

Example: Find out which programs use the variable PENSION-AMT. To do this you search your source code. You can imagine how the use of MOVE CORRESPONDING will cause you to miss references to PENSION-AMT.

3. Error Diagnosis

Your MOVE CORRESPONDING statement abends on a data exception. Which MOVE caused the abend? Might be hard to say.

Bottom Line: MOVE CORRESPONDING = small convenience at big cost
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu May 24, 2007 8:52 pm
Reply with quote

TG Murphy wrote:
1. Readability.
A single line is fairly readable.
Quote:
2. Impact Analysis.
Example: Find out which programs use the variable PENSION-AMT. To do this you search your source code. You can imagine how the use of MOVE CORRESPONDING will cause you to miss references to PENSION-AMT.
So group moves should not be allowed?
Quote:
3. Error Diagnosis
Your MOVE CORRESPONDING statement abends on a data exception. Which MOVE caused the abend? Might be hard to say.
Possibly, but I have yet to figure out how to use AbendAid.....I usually just look at the dump.
Quote:
Bottom Line: MOVE CORRESPONDING = small convenience at big cost
Personally, I don't think I have ever used it, but, IMO, when appropriate, it seems like it would be just fine to do so.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Fri May 25, 2007 6:01 pm
Reply with quote

I used MOVE CORRESPONDING very nicely (in a one-time program) to convert records with lots of packed-dec fields to display. By duplicating the record layouts and changing the target PIC's, MOVE CORRESPONDING was a good solution.

BUT - it does not handle tables, so I still had to code loops for the OCCUR's in the record.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Fri May 25, 2007 7:29 pm
Reply with quote

William,

1. Yes - a single line might be "easy" to read but what does it mean? It is the meaning behind the line that is hard to read.

2. Group moves. Good point. Impossible to avoid using group moves. I guess we could add REDEFINED fields to this list as well. However, this does not change the fact that MOVE CORRESPONDING is NOT good for impact analysis. It's bad bad bad...

3. I have no "real life" experience debugging MOVE CORRESPONDING so I can't really say how much weight to give this risk. I don't think it is a big deal.

Do a google search on "cobol programming standards" and you will see a clear consensus against using MOVE CORRESPONDING. I'm not making this stuff up guys. I understand that you may be comfortable using it but eventually most of the code you write will be passed on to others.

The existence of MOVE CORRESPONDING in your program will trigger closer scrutiny during code walkthroughs. For example, whenever we see commented code (without comments explaining why it was commented) in brand new programs, the alarm bells go off.

Once the alarm bells go off we scrutinize these program to death. MOVE CORRESPONDING is another one of the those things that triggers the alarm bells.

Anyways guys - my intention isn't to get into a pissing match but rather encourage daves to be more curious about what he does.
Back to top
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Fri Feb 01, 2008 5:24 pm
Reply with quote

Move corresponding has gotten a bad wrap like go to. Go to exit is desirable as is move corresponding at the 01 level. As for impact analysis goes, your impact analysis tool should use the field name to get the 01 level and then go from there. If you're missing impacts due to move corresponding, it's because you're impact analysis methodology needs work IMO.

I can't count the bugs I've seen caused from banning move corresponding. This is especially common in cases with long record descriptions of several hundreds of fields. The issue it's too easy to miss a field in this cases.

Here is a link that talks a bit about some of the 'standards' in use in some shops that don't make sense anymore(if they ever did).

www.idinews.com/cobolStds.html

I would limit the use however to 01 levels. Using it with reckless abandon is ill advised.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts How to move DB2 Installation HLQ DB2 4
No new posts How to move values from single dimens... COBOL Programming 1
Search our Forums:

Back to Top