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 2 fields of 2 PS files in a PLI program

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

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Mon Jan 13, 2014 4:34 pm    Post subject: How to compare 2 fields of 2 PS files in a PLI program
Reply with quote

Dear Team,

I have a requirement wherein I need to compare 2 fields of 2 different PS files (inputs) of different structures. And, if the 2 fields are same, then the records from the 2nd input file need to be written to the output file.

The field names that need to be compared are IPAIPRO and CONTMES. These are present in both the files.

first file :

IPAIPRO starts at 1st position and its length is 7
CONTMES starts at 194 position and its length is 4.

Second file :

IPAIPRO starts at 1st position and its length is 7
CONTMES starts at 218 position and its length is 4.

Could anyone tell me the syntax to compare the 2 fields of 2 different PS files??

Thanks a lot in advance.
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


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

PostPosted: Mon Jan 13, 2014 5:54 pm    Post subject:
Reply with quote

How are the fields declared?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Mon Jan 13, 2014 6:57 pm    Post subject: Reply to: How to compare 2 fields of 2 PS files in a PLI pro
Reply with quote

Are you really wanting a PL/1 or assembler routine or have you just been careless and posted here rather than in the appropriate sort forum? Sort can easily do what want using JOINKEYS.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


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

PostPosted: Mon Jan 13, 2014 8:26 pm    Post subject:
Reply with quote

I don't understand why anyone who has done any programming at all in a given language would ask a question like this on a forum.
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 Jan 13, 2014 11:11 pm    Post subject:
Reply with quote

Hi Phil,

Possibly because they have not yet been tasked with writing a 2-file match/merge.

There is a cobol sample as a "sticky" (that is easily re-coded in some other language).

These days, he sort products have JOINKEYS which should be considered if the whole process does nothing but the match/merge and write some output.

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

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Tue Jan 14, 2014 12:27 am    Post subject: Reply to: How to compare 2 fields of 2 PS files in a PLI pro
Reply with quote

Dear team,

It would be great if it can be written as a piece of code in PLI.

However, I am not really sure how this is accomplished using SORT as well.


@Akatsukami,

IPAIPRO is CHAR(7) and CONTMES is PIC'(4)9'.
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 Jan 14, 2014 12:53 am    Post subject:
Reply with quote

Hello,

Look at the sticky mentioned earlier and re-code in pl/i.

If you use cobol or pl/i the sort(s) would be done before the match/merge cpode was run. There would be no sorting in the code.

If you use JOINKEYS, you can probably get it all done in one step.
Back to top
View user's profile Send private message
Kunal Surpurkar

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Tue Jan 14, 2014 5:03 pm    Post subject: Reply to: How to compare 2 fields of 2 PS files in a PLI pro
Reply with quote

Hi Dick,

Thanks for the reply.

If I have to use JOINKEYS in sort, May I know the syntax of it and how it can be used in my requirement.

Two files are of length 300 VB...And, IPAIPRO in first file starts at position 7 and CONTMES starts at 194 position.

And in second file, IPAIPRO starts at position 7 and CONTMES starts at 218 position.

Kindly let me know incase you need more information.

Thanks a lot.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Tue Jan 14, 2014 5:29 pm    Post subject:
Reply with quote

In PL/I, a variable in a structure may have its name qualified so as to be unique (the same is generally true of other languages, although the syntax may vary).

Assuming for the sake of discussion that the two structures holding the records are named rec1 and rec2, these tasks can be carried out by:
Code:
if (rec1.ipaipro=rec2.ipaipro) then...

and, of course
Code:
if (rec1.contmes=rec2.contmes) then...
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Tue Jan 14, 2014 7:02 pm    Post subject: Reply to: How to compare 2 fields of 2 PS files in a PLI pro
Reply with quote

This is your basic 2 file match outline. Memorize it.
Code:
read a record from each file
do while both files have more data
   select
      when keys match
      do
         do matching stuff
         read a new record from each file
      end
      when key of file 1 > key of file 2
      do
         do key 1 > key 2 stuff
         read a new record from file 2
      end
      when key 1 < key 2
      do
         do key 1 < key 2 stuff
         read a new record from file 1
      end
   end select
end main loop
if more records in file 1
then do file 1 stuff
if more records in file 2
then do file 2 stuff
end program
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 Jan 14, 2014 7:39 pm    Post subject:
Reply with quote

Hello,

Quote:
If I have to use JOINKEYS in sort, May I know the syntax of it and how it can be used in my requirement.
I would not think of this as "have to". Not so long ago, sport products did NOT hasve the JOINKEYS funtionality.

If you look here in the forum, there are Many examples. There are examples in the product documentation.

If you get stuck, post what you tried and explain what happened. Post the JCL and any informational and/or diagnostic information generated.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Wed Jan 15, 2014 8:10 am    Post subject: Re: Reply to: How to compare 2 fields of 2 PS files in a PLI
Reply with quote

Nic Clouston wrote:
This is your basic 2 file match outline. Memorize it.
Code:
read a record from each file
do while both files have more data
   select
      when keys match
      do
         do matching stuff
         read a new record from each file
      end
      when key of file 1 > key of file 2
      do
         do key 1 > key 2 stuff
         read a new record from file 2
      end
      when key 1 < key 2
      do
         do key 1 < key 2 stuff
         read a new record from file 1
      end
   end select
end main loop
if more records in file 1
then do file 1 stuff
if more records in file 2
then do file 2 stuff
end program


If you are going to use this logic, then both files should be sorted based on the Key (Ascending) before this.
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: Wed Jan 15, 2014 8:21 am    Post subject:
Reply with quote

Hello,

If any program is to be used, the files need to be presorted . . .
Back to top
View user's profile Send private message
Kunal Surpurkar

New User


Joined: 15 Nov 2012
Posts: 47
Location: India

PostPosted: Mon Jan 27, 2014 10:29 pm    Post subject:
Reply with quote

Dear Team,

Thanks a lot for your suggestions.

I had tried using the logic in PLI program...but, its taking a lot of time for the program to complete as the files have millions of records.

So, I used JOINKEY concept to find the matching records in the 2 files and it worked.

Thanks a lot once again icon_smile.gif
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 Jan 27, 2014 10:35 pm    Post subject:
Reply with quote

Good to hear it is working - thank you for letting us know 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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm


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