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
 

 

Take first file and check an indicator if it is Y

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

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Tue Jun 01, 2010 10:06 pm    Post subject: Take first file and check an indicator if it is Y
Reply with quote

Hi,

I have three input file which has key in 1 to 7 and 36 to 39 in sorted order.

I need to take first file and check an indicator if it is Y then i need to check the key of the first with second if it matches then need to write to file and same to next file.

for example,

A000072 A000068 A000068
A000078 A000072 A000069
A000079 A000073 A000072

I need to take first record and find the second file exact and write some output file with some variables from first record.

how to do this,

Thanks,
Venkatraman B
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 Jun 01, 2010 10:09 pm    Post subject:
Reply with quote

Hello,

You need to post sample data from both input files and the output you want from that sample input data. If either file can contain duplicates, show this also.

Clearly explain the "rules" for your process.
Back to top
View user's profile Send private message
venkatatcts

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Tue Jun 01, 2010 10:16 pm    Post subject: Reply to: cobol program
Reply with quote

Hi,

Code:
File 1                          file 2                      file 3

A000072........................ A000068.................... A000068......................
A000078........................ A000072.................... A000069.....................
A000079........................ A000073.................... A000072 .....................

A000072 matches with second record of seond file take that and write some information from A000072 to output file.

A000072 some inforamtion - first output file.
A000078 is not matched and should be written to error file.
A000068 No need to do anything with A000068 in first file
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 Jun 02, 2010 2:08 am    Post subject:
Reply with quote

Hello,

How many records will there be in each of the files?

What you are looking for is a 3-file match/merge - not so common. . . 2-file match/merge is very common and there is a working example of the code in the "Sticky" near the top of the COBOL part of the forum.

If one of the files is always very small, it might be read into an array and used from there. If 2 of the files could be combined, the sample code from the "Sticky" could be used.

If you start from scratch, it may take a bit of work to create the 3-file match/merge code. Due to more and more direct accrss to data, i've not needed a 3-file match/merge for over 30 years so i don't have an example. . .
Back to top
View user's profile Send private message
venkatatcts

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Thu Jun 03, 2010 7:58 pm    Post subject: Cobol Hold
Reply with quote

Hi,

I am reading three sequential file on which one key is same which is 10 bit field and all the three fields are in sorted order.

I need to read the first file and match the second file and third file by key and update the records if there is no match from second file and third file to first file.

If there is no match need to write it to error record.

I am reading all the three files first record.

Code:
     IF FIRST FILE INDICATOR1 = Y AND FIRST FILE INDICATOR2 = Y
     PERFORM P1300-xxx-READ THRU P1300-EXIT   
         UNTIL FIRST-FILE-KEY <= SECOND-FILE-KEY OR UNTIL FIRST FILE EOF
            IF FIRST-KEY   = SECOND FILE KEY AND SECOND FILE AND second Not EOF
               COMPARE THE SOME FILEDS AND IF MATCHES
               PERFORM UPDATE
              ELSE
              PERFORM ERROR
               PERFORM SECOND FILE READ
    ELSE (indicator is N and N in first file)
       then same logic is perfomed against the 1 and third file.


The above logic works and i got the output. But for the scenario,

first file 10 record with the same key and second and third file as only one file for that key.

File 1 (IND) FILE 2 FILE 3

XXXXXX1 Y Y XXXXXX1 XXXXXX1
XXXXXX1 Y Y
XXXXXX1 N N
XXXXXX1 N N

First file will check with second file but there are two records in that which will not be compared as my code will read the next record one it matches. So i need to check the both the records with file2 and same for file3

Please help me out in this
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jun 03, 2010 8:15 pm    Post subject:
Reply with quote

Quote:
all the three fields are in sorted order.


think you mean that all three files are sorted based on same field.

Quote:
and update the records if there is no match from second file and third file to first file.


Quote:
COMPARE THE SOME FILEDS AND IF MATCHES
PERFORM UPDATE


not really sure of the rules of your game.

1. can there be duplicates in any of the files?
  • does file1 have dups
  • does file2 have dups
  • does file3 have dups


2. can a key exist in file2 or 3 that does not exist in file1?

3. when is an output record generated? I assume that is what you mean by update?

since the solution is predicated on the answer to the above questions,
provide an answer.
Back to top
View user's profile Send private message
venkatatcts

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Thu Jun 03, 2010 10:31 pm    Post subject: Reply to: Take first file and check an indicator if it is Y
Reply with quote

hi,

1. file 1 has duplicates
2. file 1 has all the key which is in 2 and 3
3. when key matches and some comparison after that

Thanks.
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: Thu Jun 03, 2010 11:04 pm    Post subject:
Reply with quote

Hello,

Quote:
The above logic works and i got the output. But . . .
As i mentioned in your duplicate topic - you need to test with a more complete set of sample data. I believe you will find the posted code will not even come close.

Suggest you find a way to combine files 2 & 3 before your process (using a record ndicator in addition to the keys/data) or (if one of them will always be small) load this into an array so that you are back to a 2-file match process.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jun 03, 2010 11:07 pm    Post subject:
Reply with quote

ok,
what output is generated when:
  • key1 = key2 & key1 = key3
  • key1 = key2 & Key1<> key3
  • key1 <> key2 & key1 = key3
  • key1 <> key2 & Key1 <> key3


<> key means there is no match.

when file1 has duplicates, that means the above holds true for second file1 (the dup).
what output is generated?

and the other comparisons that you mention, what are they?
those also have to do with the logic.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Jun 04, 2010 3:45 am    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
  • key1 = key2 & key1 = key3
  • key1 = key2 & Key1<> key3
  • key1 <> key2 & key1 = key3
  • key1 <> key2 & Key1 <> key3
OK, so that is what the "List" tag does, neet... icon_surprised.gif
Back to top
View user's profile Send private message
venkatatcts

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Fri Jun 04, 2010 7:56 am    Post subject: Reply to: Take first file and check an indicator if it is Y
Reply with quote

Hi,

Input file :

Ln code is the comparison after the code

Key1 Ln Bi pd key2 Ln Bi PD key 3 Ln Bi Pd
10001 40 01 00 10001 40 01 00 10002 50 10 10
10001 40 01 00 10002 50 10 10
10001 50 10 10
10001 50 10 10

Before that a claim indicator is checked if it is Y then file1 is compared with file2 else file1 is compared with file3.
If key 1 = key 2
then
compare the bi of first file with second file FIRST-FILE-KEY <= SECOND-FILE-KEY OR UNTIL FIRST FILE EOF
if it matches write record
else write it to error file
compare the pd of first file with second file FIRST-FILE-KEY <= SECOND-FILE-KEY OR UNTIL FIRST FILE EOF
if it matches write record
else write it to error file
ELSE
Same logic for 1 file vs 3 file.

If the file1 key matched with file 2 it should write to output. since there are two records with the same key in first file i need to write both the record to output. But my code will not do that.

Actually i need to have a hold variable to to hold the second file key and then check the next first file comparison (LN and PD) if it matches then again i need to write.

For example the output should be like this,
output file :
Key1 Ln Bi pd updated value from key1 or key 3
10001 40 01 00 XXX
10001 40 01 00 YYYYYYY
10001 50 10 10 dddfdd
10001 50 10 10 dsfdssd

Please suggest on this,

Thanks,
venkat
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Jun 04, 2010 8:14 am    Post subject: Re: Reply to: Take first file and check an indicator if it i
Reply with quote

What did you want?
This:
venkatatcts wrote:
Key1 Ln Bi pd key2 Ln Bi PD key 3 Ln Bi Pd
10001 40 01 00 10001 40 01 00 10002 50 10 10
10001 40 01 00 10002 50 10 10
10001 50 10 10
10001 50 10 10
.
.
.
Key1 Ln Bi pd updated value from key1 or key 3
10001 40 01 00 XXX
10001 40 01 00 YYYYYYY
10001 50 10 10 dddfdd
10001 50 10 10 dsfdssd
Or this:
Code:
 Key1    Ln    Bi  pd        key2        Ln     Bi PD              key 3   Ln  Bi   Pd
 10001   40   01  00          10001   40    01  00             10002   50 10   10
 10001   40   01  00          10002   50    10  10
 10001   50   10  10         
 10001   50   10  10
.
.
.
 Key1    Ln    Bi  pd       updated value from key1 or key 3
 10001   40   01  00       XXX   
 10001   40   01  00       YYYYYYY   
 10001   50   10  10       dddfdd   
 10001   50   10  10       dsfdssd
Please refer to [code]Suggestion Whenever indentation representation needed
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: Fri Jun 04, 2010 8:53 am    Post subject:
Reply with quote

Hello,

You seem to be determined to continue with the same approach you started with. I believe if you continue and do get something running this way, it will not work for all situations than could be encountered in real data.

The main problem i see with this approach is that your "driver" has no way to stay in sync between the 3 files. . .

If your system has Easytrieve, you might get what you want more quickly using the MATCH function of Easytrieve.

Or look for a way to make the main process work with only 2 files by combining 2 of them before this main step or storing one in an internal array (depending on size).
Back to top
View user's profile Send private message
venkatatcts

New User


Joined: 16 Mar 2009
Posts: 55
Location: India

PostPosted: Fri Jun 04, 2010 9:39 am    Post subject: Reply to: Take first file and check an indicator if it is Y
Reply with quote

Hi William,

I want the second one.

Thanks,
Venkat
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: Fri Jun 04, 2010 9:46 am    Post subject:
Reply with quote

Hello,

You do understand that what Bill posted is both the same thing - just a different display (Quote versus Code). Did you click on the link he provided (where it says Please refere to. . .)?

You too can post in a more readable way by using the Code tag. . .
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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