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

How to separate these records ?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Nov 22, 2012 3:01 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Nov 22, 2012 3:25 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Nov 22, 2012 4:48 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Nov 22, 2012 6:42 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Nov 22, 2012 6:47 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Nov 22, 2012 7:00 pm
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: 1788
Location: Bloomington, IL

PostPosted: Thu Nov 22, 2012 9:14 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Nov 22, 2012 9:19 pm
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: 1788
Location: Bloomington, IL

PostPosted: Thu Nov 22, 2012 9:48 pm
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: 2455
Location: Hampshire, UK

PostPosted: Thu Nov 22, 2012 11:28 pm
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
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

Moderator Emeritus


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

PostPosted: Sun Nov 25, 2012 6:06 am
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
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

Moderator Emeritus


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

PostPosted: Mon Nov 26, 2012 9:51 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top