Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to compare inputs of same length but with unequal values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
BALAMURUGAN J

New User


Joined: 17 Apr 2012
Posts: 1
Location: INDIA

PostPosted: Tue May 15, 2012 4:43 pm    Post subject: How to compare inputs of same length but with unequal values
Reply with quote

Problem Description:
Compare the content of two files and write the contents in output file if they MATCHES.
I have two input files in sorted order.

First File Contents:
ASFLCMPR
CESD

Second File Contents:
ASFLCMPR
CESD
DESED

Expected Output:
ASFLCMPR
CESD

Actual Output:
ASFLCMPR

CODING:
PROCESS:
PERFORM READLIST TO READLISTX ------>READING FILE1
PERFORM READLISTA TO READLISTB------->READING FILE2
MAINLOOP:
IF NAM1 NE NAM2
PERFORM READLISTA TO READLISTB
GOTO MAINLOOP
ELSE
MOVE NAM2 TO OUT_NAME
WRITE OUTFILE1
GOTO PROCESS
ENDIF

PROBLEM:
It is displaying the first variable correctly. But the second variable s neglected since its having lesser lenght and comparison did not proceed after that.

Kindly help me with this.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Tue May 15, 2012 4:55 pm    Post subject: Reply to: How to compare inputs of same length but with uneq
Reply with quote

Looks to me like you don't read File 1 more than once, from what you have shown.

I don't understand at all what you mean by the subject or your comments about why you don't get a match.

Have you looked at the "Sticky" for a two-file match in the Cobol forum where you have posted? Compare the logic there to the logic you have and you should get to a resolution.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue May 15, 2012 5:17 pm    Post subject:
Reply with quote

Quote:
It is displaying the first variable correctly. But the second variable s neglected since its having lesser lenght and comparison did not proceed after that.
That's a statement constructed with non-IT words.

Did you mean the working-storage variables were of length 8 [PIC X(8)] to accomodate "ASFLCMPR" and when control reach to "CESD", the length of the input-content was less and it did not work, grumble... icon_eek.gif
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Tue May 15, 2012 6:12 pm    Post subject: Reply to: How to compare inputs of same length but with uneq
Reply with quote

It would be very easy for someone to correct your program if you show the actual code, not just "Is is.... since...".
By the way, who told you to use GO TO in a structured, new, 2012 COBOL program?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Tue May 15, 2012 7:04 pm    Post subject: Reply to: How to compare inputs of same length but with uneq
Reply with quote

Code:
CODING:
PROCESS:                               
   PERFORM READLIST TO READLISTX ------>READING FILE1         
   PERFORM READLISTA TO READLISTB------->READING FILE2   
MAINLOOP:                             
   IF NAM1 NE NAM2             
      PERFORM READLISTA TO READLISTB       
      GOTO MAINLOOP                   
   ELSE                             
      MOVE NAM2 TO OUT_NAME                 
      WRITE OUTFILE1                 
      GOTO PROCESS                   
   ENDIF


The pseudo-code you have shown, subject to no "end of file" processing, should actually "work" for your data.

Which means you have something wrong in the actual code we can't see.

You don't represent a full solution with your code, unless you know for certain that records on File 1 must always be present on File 2.

You don't mention whether you can have duplicates on either file.

I still can't make sense of your comments about the length. You using reference-modification? Any sort of "STRING"?
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: Tue May 15, 2012 7:13 pm    Post subject:
Reply with quote

Hello and welcome to the forum,

Your pseudo-code (as posted) will most lilely fail in a "real world" situation. Also, it is not compilable code, so we cannot be specific about your problem resolution.

When "matching" 2 files by a key, there must be tests for more than simply equal or not equal.

As suggested, look at the "2-file match/merge" sample code in the "Sticky" near the top of this COBOL part of the forum.

Post back here if you have any questions.
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 Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us