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 separate these records ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Thu Nov 22, 2012 12:11 pm    Post subject: How to separate these records ?
Reply with quote

Hi every one.
I am trying to write a PL/I program which compares two files and writes the equal records into a file and writes the records which are different into another file.. The data is numeric and sorted in the files.

Code:
READ FILE(INFILE1) INTO (INREC1);             
READ FILE(INFILE2) INTO (INREC2);             
DO WHILE(E_O_INFILE1 ¬= 1 || E_O_INFILE2 ¬= 1);
      IF DATA_I = DATA_O THEN DO;             
         WRITE FILE(OUTFILE1) FROM (INREC1);   
         READ FILE(INFILE1) INTO (INREC1);     
         READ FILE(INFILE2) INTO (INREC2);     
      END;                                     
      ELSE                                     
      IF DATA_I < DATA_O THEN DO;             
         WRITE FILE(OUTFILE2) FROM (INREC1);   
         READ FILE(INFILE1) INTO (INREC1);     
      END;                                     
      ELSE                                     
      IF DATA_I > DATA_O THEN DO;             
         WRITE FILE(OUTFILE2) FROM (INREC2);   
         READ FILE(INFILE2) INTO (INREC2);     
      END;                                     
END;                                             


This is the logic I am workling on.
But I am not getting the output.
It compiling fine.
But in the RUN JCL,
The return code is 00, EXCP is "71".
Correct me where am I actually going wrong here.

Code'd
Back to top
View user's profile Send private message

prino

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Thu Nov 22, 2012 3:01 pm    Post subject:
Reply with quote

Next time use
Code:
[code][/code]
tags around your code and supply all declarations. We haven't got a clue about what the E_O_INFILEx's have been declared as, or initialized to.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Nov 22, 2012 3:25 pm    Post subject: Reply to: How to separate these records ?
Reply with quote

In addition, what happens to your keys for end-of-file on either file? What happens if one file is empty?
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Nov 22, 2012 4:48 pm    Post subject:
Reply with quote

Quote:
Code:
DO WHILE(E_O_INFILE1 ¬= 1 || E_O_INFILE2 ¬= 1);


....exactly what is it you hope to achieve by concatenating E_O_INFILE1 with E_O_INFILE2 ??? icon_rolleyes.gif

Garry.
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Thu Nov 22, 2012 6:26 pm    Post subject:
Reply with quote

@Bill Woodger
I have declared them above in my program.

This will execute only if either of the file is not empty.
The error is that the output file-1 is writing the correct data, which satisfies the condition but the output file-2 which should write the non-similar records, is going into the infinite loop.
The non similar records are being written in a large numbers.

@Garry Carroll
I corrected the concatenation symbol.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Nov 22, 2012 6:42 pm    Post subject: Reply to: How to separate these records ?
Reply with quote

Code:
1 1
2
3
4


Left column is file 1, right column is file 2.

Show how the comparison of your keys operates for this.

Hint: when one file reaches end-of-file you set the comparison key (for me, not in the record area) "high". I don't know, but suspect not, if PL/I has any "magic" doing this for you.

There is a "two file match" sticky in the Cobol forum here. Look at the logic there.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Nov 22, 2012 6:47 pm    Post subject:
Reply with quote

tamminenisidhartha wrote:
@Bill Woodger
I have declared them above in my program.

This will execute only if either of the file is not empty.
The error is that the output file-1 is writing the correct data, which satisfies the condition but the output file-2 which should write the non-similar records, is going into the infinite loop.
The non similar records are being written in a large numbers.

@Garry Carroll
I corrected the concatenation symbol.


First, what have you declared E_O_INFILE1 and E_O_INFILE2 as ? BIN FIXED or DEC FIXED ?

You seem to have changed from getting cond code zero to going into an infnite loop?

Garry.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Thu Nov 22, 2012 7:00 pm    Post subject: Re: Reply to: How to separate these records ?
Reply with quote

Bill Woodger wrote:
Hint: when one file reaches end-of-file you set the comparison key (for me, not in the record area) "high". I don't know, but suspect not, if PL/I has any "magic" doing this for you.

In PL/I you would usually do this in the ON ENDFILE unit, and the loop would be controlled not by EOF's, but by key1/2 ^= 'high'.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Nov 22, 2012 9:14 pm    Post subject: Re: Reply to: How to separate these records ?
Reply with quote

prino wrote:
Bill Woodger wrote:
Hint: when one file reaches end-of-file you set the comparison key (for me, not in the record area) "high". I don't know, but suspect not, if PL/I has any "magic" doing this for you.

In PL/I you would usually do this in the ON ENDFILE unit, and the loop would be controlled not by EOF's, but by key1/2 ^= 'high'.

Which suggests to me the possibility that E_O_INFILEn are actually declared BIT, and that the DO statement ought to be
Code:
DO WHILE (E_O_INFILE1 ¬= '1'B | E_O_INFILE2 ¬= '1'B);
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Nov 22, 2012 9:19 pm    Post subject: Re: Reply to: How to separate these records ?
Reply with quote

Akatsukami wrote:
prino wrote:
Bill Woodger wrote:
Hint: when one file reaches end-of-file you set the comparison key (for me, not in the record area) "high". I don't know, but suspect not, if PL/I has any "magic" doing this for you.

In PL/I you would usually do this in the ON ENDFILE unit, and the loop would be controlled not by EOF's, but by key1/2 ^= 'high'.

Which suggests to me the possibility that E_O_INFILEn are actually declared BIT, and that the DO statement ought to be
Code:
DO WHILE (E_O_INFILE1 ¬= '1'B | E_O_INFILE2 ¬= '1'B);


... which is what I was hinting at when I asked if the declares were for BIN or DEC.....

Garry.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Nov 22, 2012 9:48 pm    Post subject: Re: Reply to: How to separate these records ?
Reply with quote

Garry Carroll wrote:
Akatsukami wrote:
prino wrote:
Bill Woodger wrote:
Hint: when one file reaches end-of-file you set the comparison key (for me, not in the record area) "high". I don't know, but suspect not, if PL/I has any "magic" doing this for you.

In PL/I you would usually do this in the ON ENDFILE unit, and the loop would be controlled not by EOF's, but by key1/2 ^= 'high'.

Which suggests to me the possibility that E_O_INFILEn are actually declared BIT , and that the DO statement ought to be
Code:
DO WHILE (E_O_INFILE1 ¬= '1'B | E_O_INFILE2 ¬= '1'B);


... which is what I was hinting at when I asked if the declares were for BIN or DEC.....

It's Thanksgiving Day in the U.S.; I only got up about an hour ago, and I'm still working on my first cup of coffee and cigar. I'm entitled to be obtuse, dammit! icon_wink.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Thu Nov 22, 2012 11:28 pm    Post subject:
Reply with quote

I would actually go for:
Code:
Do While (¬E_O_INFILE1 | ¬E_O_INFILE2);

Actually, my sample program has...
Code:
DO WHILE (more_master_records | more_update_records);
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Fri Nov 23, 2012 11:24 am    Post subject:
Reply with quote

Hi all.

The program is running fine now.
I thank you all for your valuable suggestions.
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: Sun Nov 25, 2012 6:06 am    Post subject: Reply to: How to separate these records ?
Reply with quote

Good to hear it is working - what did you change to make it work correctly?

d
Back to top
View user's profile Send private message
tamminenisidhartha
Currently Banned

New User


Joined: 31 Oct 2012
Posts: 43
Location: INDIA

PostPosted: Mon Nov 26, 2012 12:01 pm    Post subject:
Reply with quote

@Dick scherrer.

I included the following condition in the "DO WHILE" loop.

Code:
DO WHILE (E_O_INFILE1='Y' & E_O_INFILE2='N');
       PUT SKIP LIST('WRITING REMAIN OF FILE2');
       READ FILE(INFILE2) INTO(INREC2);
       WRITE FILE(OUTFILE2) FROM (INREC2);
       READ FILE(INFILE2) INTO(INREC2);
       END;
       DO WHILE (E_O_INFILE1='N' & E_O_INFILE2='Y');
       PUT SKIP LIST('WRITING REMAIN OF FILE1');
       READ FILE(INFILE1) INTO(INREC1);
       WRITE FILE(OUTFILE2) FROM (INREC1);
       READ FILE(INFILE1) INTO(INREC1);
       END;


Its working fine now.
NOTE:- I changed the end of file variables to "Y" and "N".
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: Mon Nov 26, 2012 9:51 pm    Post subject: Reply to: How to separate these records ?
Reply with quote

Thank you for posting your solution - it may help another one day icon_smile.gif

d
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 -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am


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