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
 

 

Logic required for files matching & calculate oldest dat

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

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Mon Nov 16, 2009 4:48 pm    Post subject: Logic required for files matching & calculate oldest dat
Reply with quote

I have two input files and i need to compare 1st input file a/c no& amount with 2nd input file a.c no and amount.If match found then i want to write the 2nd input file record in to output file.If more than one match found i want to write the 2nd input file record which is having the oldest date record based date field in 2nd input file?

A/c no is pic x(6),Amount is pic x(12)v99 comp-3.

Please let me know thelogic for this requiremnt?

File -1 Data :-
---------
Command ===> This PS file
****** **********************
a/c no | amount
01035900000000232.50
03466500000000232.50
03466500000000232.50
03466500000000232.50
03466500000000232.50
03466700000000232.50
03466800000000232.50
03466900000000222.50
****** **********************
File-2 Data:- This VSAM file
--------------
Date action branch a/c num amount
20091027 1 999 010359 232.50
20091028 1 999 034665 232.50
20091029 1 999 034665 232.50
20091030 1 999 034665 232.50
20091030 1 999 034665 232.50
20091101 1 999 034667 232.50
20091102 1 999 034668 232.50
20091102 1 999 034669 222.50

Please let me know thelogic for this requiremnt?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 16, 2009 5:14 pm    Post subject:
Reply with quote

well other than looking at the 'suggested logic' contained in the PROGRAMS button at the top of the page,

From the above input files, what is your desired output - as records, not your rules.
Back to top
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Mon Nov 16, 2009 5:18 pm    Post subject:
Reply with quote

Desired out put for this requirement is

Date action branch a/c num amount
20091027 1 999 010359 232.50
20091028 1 999 034665 232.50
20091101 1 999 034667 232.50
20091102 1 999 034668 232.50
20091102 1 999 034669 222.50
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 16, 2009 6:20 pm    Post subject:
Reply with quote

what is the key for the vsam file?
Back to top
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Tue Nov 17, 2009 9:43 am    Post subject:
Reply with quote

VSAM file Key is a/c num&amount .
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Nov 17, 2009 10:47 am    Post subject:
Reply with quote

Hi Babu,

My suggestion would be to SORT the file based on the a/c num, amount the DATE field before starting the actual processing.

In your code, after doing a read for each record in the second file, you could check the previous key value. If its the same, skip the record with no processing.

Code:
1.      SORT second file with a/c num, amount and date
2.      Read each record in second file until EOF
2.1       If <key of current record> = <key of previous record>
2.1.1       Continue to next read ( Step 2 )
2.2       Find the key in the first file, If not found
2.2.1       Continue to next read ( Step 2 )
2.3       Write the record to the o/p
2.4       Update the <key of previous record> with <key of current record>
3.      Exit


Do let me know in case of any clarifications / mistakes... icon_razz.gif
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2009 11:14 am    Post subject:
Reply with quote

babu_hi wrote:
VSAM file Key is a/c num&amount .
Are you sure the key is a/c num and amt? From the Language Reference manual concerning indexed organization:
Quote:
... the value in each prime key data item must be unique...
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 Nov 17, 2009 11:22 am    Post subject:
Reply with quote

Hello,

Most places do not allow amounts to be part of the primary key. . . Many places to not allow amounts and/or quantities to be a key/index at all. . .

This sounds like a situation that might run for a long while until some customer repeats a purchase and winds up with the same account and $ and then the process will fail. And everyone will remark - "we haven't changed anything".
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Nov 17, 2009 12:09 pm    Post subject:
Reply with quote

Terry Heinze wrote:
babu_hi wrote:
VSAM file Key is a/c num&amount .
Are you sure the key is a/c num and amt? From the Language Reference manual concerning indexed organization:
Quote:
... the value in each prime key data item must be unique...

icon_redface.gif ... completely overlooked this point...
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2009 12:35 pm    Post subject:
Reply with quote

Your solution may work, Binop; I was just pointing out a VSAM rule. It's too late at night for me to think. icon_smile.gif
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Nov 17, 2009 12:44 pm    Post subject:
Reply with quote

Thanks Terry..

Terry Heinze wrote:
I was just pointing out a VSAM rule. It's too late at night for me to think. icon_smile.gif

Exactly my point... Not happy at myself because its morning for me.. and my thinking process should be at its peak... icon_razz.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Nov 17, 2009 1:11 pm    Post subject:
Reply with quote

Beside that, a prime key starts at position 1. And thats not the case here looking at the record lay-out of the output file.
But then it could be an alternate index, allowing duplicates.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Nov 18, 2009 11:17 am    Post subject:
Reply with quote

Hi Peter,

You said,
Quote:
Beside that, a prime key starts at position 1. And thats not the case here looking at the record lay-out of the output file.


A snapshot from the following link
Quote:
VSAM indexed file organization
(Also referred to as VSAM KSDS (key-sequenced data set) organization.) In a VSAM indexed file (KSDS), the records are ordered according to the collating sequence of an embedded prime key field, which you define. The prime key consists of one or more consecutive characters in the records. The prime key uniquely identifies the record and determines the sequence in which it is accessed with respect to other records. A prime key for a record might be, for example, an employee number or an invoice number.


Am I missing something... icon_redface.gif .. I couldn't find any reference telling the prime key should start at 1st byte... My understanding was that the VSAM key could start from any position and not necessarily the first byte in the record.. Please do correct me if I am wrong...
Back to top
View user's profile Send private message
belchoff

New User


Joined: 21 Oct 2009
Posts: 4
Location: UK

PostPosted: Wed Nov 18, 2009 11:25 am    Post subject:
Reply with quote

why dont you load one file into an array after sorting it, then read the other file, run a search in the table of the loaded file.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Nov 18, 2009 12:49 pm    Post subject:
Reply with quote

Binop,

my bad. Had another database organization in mind.
The default for vsam is a key of 64 bytes starting at pos 1
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Nov 18, 2009 2:21 pm    Post subject:
Reply with quote

Thanks Peter, for the clarification and info... icon_smile.gif
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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Matching with Key at different postions. rajatbagga DFSORT/ICETOOL 12 Wed Nov 09, 2016 10:58 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
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
No new posts Adding records from two files into on... shiitiizz SYNCSORT 4 Mon Sep 19, 2016 8:41 pm


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