Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Whether my MOVE CORRESPONDING will work or not

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Whether my MOVE CORRESPONDING will work or not
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

Moderator Team Head


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

PostPosted: Wed May 16, 2007 10:39 pm    Post subject: Re: MOVE CORRESPONDING
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: 3158
Location: Tucson AZ

PostPosted: Wed May 16, 2007 10:53 pm    Post subject:
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    Post subject:
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: 149
Location: Ottawa Canada

PostPosted: Thu May 17, 2007 12:46 am    Post subject:
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

Site Director


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

PostPosted: Thu May 17, 2007 12:57 am    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu May 17, 2007 2:12 am    Post subject:
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: 149
Location: Ottawa Canada

PostPosted: Wed May 23, 2007 7:47 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Wed May 23, 2007 8:16 pm    Post subject:
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    Post subject:
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: 149
Location: Ottawa Canada

PostPosted: Thu May 24, 2007 6:18 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu May 24, 2007 8:52 pm    Post subject:
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

Active Member


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

PostPosted: Fri May 25, 2007 6:01 pm    Post subject:
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: 149
Location: Ottawa Canada

PostPosted: Fri May 25, 2007 7:29 pm    Post subject:
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

Active User


Joined: 12 Jul 2006
Posts: 154
Location: USA

PostPosted: Fri Feb 01, 2008 5:24 pm    Post subject: Move corresponding it NOT a bad practice!
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).

http://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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Fileaid 2 commands instream work. In ... descann Compuware & Other Tools 2 Tue May 16, 2017 3:31 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us