COBOL MOVE CORRESPONDING DOUBT

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

perumalnk
Member
Posts: 24
Joined: Thu Feb 28, 2008 3:30 am
Location: Denver,USA

COBOL MOVE CORRESPONDING DOUBT

Post by perumalnk » Thu Aug 12, 2010 8:26 am

Hi,

Wishes !

I have a tiny doubt in COBOL "MOVE CORRESPONDING" working. Please find below my scenario,

Layout#1:

01 WS-LAYOUT-1
05 WS-MOVE-1
10 WS-FIELD-1 PIC X(02).
10 WS-FIELD-2 PIC S9(09) COMP-3.

Layout#2:

01 WS-LAYOUT-2
05 WS-MOVE-2
10 WS-FIELD-1 PIC X(02).
10 WS-FIELD-2 PIC 9(07).

With this layouts,when I execute the below statement,

MOVE CORRESPONDING WS-MOVE-1 TO WS-MOVE-2

Whether WS-FIELD-2 from input layout will get moved to output layout or not?

Thanks in advance !

Thanks,
Perumal.N.K.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Aug 12, 2010 2:41 pm

Why not just try this out?

PS. you need period (.) after 01 and 05 levels.
Regards,
Anuj

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Aug 12, 2010 3:04 pm

perumalnk wrote:I have a tiny doubt...
funny, nearly all your posts sound the same.
you are just to lazy to read the manual.

explanation which will remove all doubts
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Thu Aug 12, 2010 4:00 pm

My guess is it should move the values from input WS-FIELD-2 to output WS-FIELD-2.
Natarajan
Chennai

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Aug 12, 2010 4:14 pm

Natarajan wrote:My guess is it should move the values from input WS-FIELD-2 to output WS-FIELD-2.
yes, it will be a conversion move.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

perumalnk
Member
Posts: 24
Joined: Thu Feb 28, 2008 3:30 am
Location: Denver,USA

Post by perumalnk » Fri Aug 13, 2010 2:43 pm

Hi All,

Thanks for the reply.

I did try that out. It got moved , but initially I thought it will not get moved as the declarations differ. So just to confirm my understanding, I asked this doubt. Sorry that it bothered much.
The WS-FIELD-2 of input layout comes from an IMS DB.Now when I changed the output layout WS-FIELD-2 declaration to S9(9) comp-3, I faced S0C7 abend at the move. For the same segment values when I declare my output WS-FIELD-2 as 9(8),job goes through fine !

Thanks,
Perumal.N.K.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Aug 13, 2010 2:58 pm

I faced S0C7 abend at the move
**sigh** the SOC7 indicates that you have non-numerics in a numeric field.

all you have managed to do is just propogate the garbage thru your program,
instead of taking an exception routine,
denoting the problem - and the values,
substituting appropriate default values or
doing something to tell someone that their is garbage in the system.

do you work for the government?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

perumalnk
Member
Posts: 24
Joined: Thu Feb 28, 2008 3:30 am
Location: Denver,USA

Post by perumalnk » Fri Aug 13, 2010 3:51 pm

Hi Dick Brenholtz,

Those are new fields added in a segment and they might be hoding low values for the existing entries in the DB. I understand that is the reason for S0C7. I just wonder why is the data exception abend is not occuring when I use 9(8)? I expect the S0C7 abend when use the same data with the declaration of 9(8). Hope my doubt is clear to you now.

I dont work for govt.

Thanks,
Perumal.N.K.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Aug 13, 2010 4:12 pm

PIC 9n display/PIC S9n display is for all-intents-and-purposes - alphanumeric,
which allows you to stuff any garbage into the field
with the added feature that you can perform arithmetic with the field.

IMUO:
move corr should not be used and most site standards don't allow it.
it only saves in the coding, as the generated code is still single moves.

i believe that you should always maintain numeric values in pure numeric fields (comp, comp-3)
which helps remove garbage from the data flow.
you could have tested for low-values and moved zero to a comp-3 field.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Aug 13, 2010 4:57 pm

Not sure if I've missed something but just a COBOL MOVE will not cause a S0C7 unless you use the "target (non-numeric)" field in Arithmetic-calculations. Just after MOVE DISPLAY both the variables and you should be having a hint of what's happeing.
Regards,
Anuj

perumalnk
Member
Posts: 24
Joined: Thu Feb 28, 2008 3:30 am
Location: Denver,USA

Post by perumalnk » Mon Aug 16, 2010 2:15 pm

Hi Dick Brenholtz,

Thanks for clarifying the reason behind the S0C7 when the variable is declared as PD. I was wondering the reason behind it.

Yeah, as MOVE CORRESPONDING was used already at that place, we did not get the drive to make an explicit check for low values.

Thanks again.

Thanks,
Perumal.N.K.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Mon Aug 16, 2010 4:02 pm

COMP-3, yeah - it'll casue S0C7. Thanks Dick.

Please disregard my previous post :oops:.
Regards,
Anuj

academyindia4

Topic deleted by Admin

Post by academyindia4 » Wed Jan 27, 2016 8:30 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 10:18 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 10:23 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others