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
 

 

Issue in comparing files using EASYTRIEVE
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CA Products
View previous topic :: :: View next topic  
Author Message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 10:35 am    Post subject: Issue in comparing files using EASYTRIEVE
Reply with quote

Hi Friends,

My req is to compare the INFILE3 and INFILE4 and generate the output file OUTFIL2 when there are any inserts/updates happened in the INFILE3.

Code:
FILE INFILE3                             
IN-RECORD-1                  01   30082 A   
IN-PDF-UPN1                   01      09 N   
IN-PDF-MEM-OF-UPN1       11      09 N   
IN-PDF-BU1                     21      40 A   
IN-PDF-PRI-PROD-CD1     62      20 A   
IN-PDF-PROD-CODE1       83   30000 A   

FILE INFILE4                             
IN-RECORD-2                  01   30082 A   
IN-PDF-UPN2                   01      09 N   
IN-PDF-MEM-OF-UPN2       11      09 N   
IN-PDF-BU2                     21      40 A   
IN-PDF-PRI-PROD-CD2     62      20 A   
IN-PDF-PROD-CODE2       83   30000 A   

FILE OUTFIL2                                 
OUT-RECORD                  01    30084 A     
OUT-PDF-UPN                  01         09 N     
OUT-PDF-FILLER-1            10         01 A     
OUT-PDF-MEM-OF-UPN      11         09 N     
OUT-PDF-FILLER-2            20         01 A     
OUT-PDF-BU                     21         40 A     
OUT-PDF-FILLER-3            61         01 A     
OUT-PDF-PRI-PROD-CD    62          20 A     
OUT-PDF-FILLER-4            82          01 A     
OUT-PDF-PROD-CODE       83     30000 A     
OUT-PDF-UPDATE-FLAG    30082      02 A     

FILE SORT3 F 30082 VIRTUAL                   
ST-PDF-UPN1                    01      09 N       
ST-PDF-MEM-OF-UPN1        11      09 N       
ST-PDF-BU1                      21      40 A       
ST-PDF-PRI-PROD-CD1      62      20 A       
ST-PDF-PROD-CODE1        83   30000 A       
*                                             
FILE SORT4 F 30082 VIRTUAL                   
ST-PDF-UPN2                    01      09 N       
ST-PDF-MEM-OF-UPN2        11      09 N       
ST-PDF-BU2                       21      40 A       
ST-PDF-PRI-PROD-CD2       62      20 A       
ST-PDF-PROD-CODE2          83   30000 A       

SORT INFILE3 TO SORT3 USING (IN-PDF-UPN1, IN-PDF-MEM-OF-UPN1, + 
                             IN-PDF-BU1)                         
SORT INFILE4 TO SORT4 USING (IN-PDF-UPN2, IN-PDF-MEM-OF-UPN2, +   
                             IN-PDF-BU2)                     
JOB INPUT (SORT3 KEY(ST-PDF-UPN1, ST-PDF-MEM-OF-UPN1,  +   
                                           ST-PDF-BU1), +   
            SORT4 KEY(ST-PDF-UPN2, ST-PDF-MEM-OF-UPN2,  +   
                                           ST-PDF-BU2))
IF MATCHED                                                   
   IF (ST-PDF-UPN1               = ST-PDF-UPN2)                 AND +   
      (ST-PDF-MEM-OF-UPN1    = ST-PDF-MEM-OF-UPN2)    AND +   
      (ST-PDF-BU1                  = ST-PDF-BU2)                   AND +   
      (ST-PDF-PRI-PROD-CD1  = ST-PDF-PRI-PROD-CD2)   AND +   
      (ST-PDF-PROD-CODE1    = ST-PDF-PROD-CODE2)             
                                                             
   ELSE                                                       
         OUT-PDF-UPDATE-FLAG  =  '|U'                         
         OUT-PDF-UPN               = ST-PDF-UPN1                   
         OUT-PDF-MEM-OF-UPN   = ST-PDF-MEM-OF-UPN1           
         OUT-PDF-BU                  = ST-PDF-BU1                   
         OUT-PDF-PRI-PROD-CD  = ST-PDF-PRI-PROD-CD1           
         OUT-PDF-PROD-CODE    = ST-PDF-PROD-CODE1             
         PUT OUTFIL2                                         
   END-IF                                                     
  ELSE                                                 
     IF SORT3                                           
           OUT-PDF-UPDATE-FLAG  = '|I'                 
           OUT-PDF-UPN                = ST-PDF-UPN1           
           OUT-PDF-MEM-OF-UPN    = ST-PDF-MEM-OF-UPN1   
           OUT-PDF-BU                   = ST-PDF-BU1           
           OUT-PDF-PRI-PROD-CD  = ST-PDF-PRI-PROD-CD1   
           OUT-PDF-PROD-CODE    = ST-PDF-PROD-CODE1     
           PUT OUTFIL2                                 
     END-IF                                             
  END-IF                                               
*                                                       
     OUT-PDF-UPDATE-FLAG  =  ' '                       
     OUT-PDF-PRI-PROD-CD  =  ' '                       
     OUT-PDF-PROD-CODE    =  ' '                       
*                                                       
     GO TO JOB 
Code'd

The issue here is the fields OUT-PDF-PRI-PROD-CD , OUT-PDF-PROD-CODE are not getting populated correctly when the successive records are read. Since these are not initialized after each successive fetch the output OUTFIL2 values overriden in the fileds OUT-PDF-PRI-PROD-CD , OUT-PDF-PROD-CODE. pls help to get this fixed.

Thanks,
Thiru
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 Aug 10, 2011 10:47 am    Post subject:
Reply with quote

Hello,

When posting code and/or jcl and/or data, use copy/paste and the code tag to preserve alignment and improve readability. Your code was "Code'd" but did not align because you added spaces manually. There is a Preview feature so you can see your post as it will appear to the forum. When the post appears as you want, Submit.

You need to post some sample data from the input files and the output that is happening now. You also need to post the expected output when the sample data is processed.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Wed Aug 10, 2011 11:09 am    Post subject:
Reply with quote

Code:

IF MATCHED                                                   
   IF (ST-PDF-UPN1               = ST-PDF-UPN2)                 AND +   
      (ST-PDF-MEM-OF-UPN1    = ST-PDF-MEM-OF-UPN2)    AND +   
      (ST-PDF-BU1                  = ST-PDF-BU2)                   AND +   
      (ST-PDF-PRI-PROD-CD1  = ST-PDF-PRI-PROD-CD2)   AND +   
      (ST-PDF-PROD-CODE1    = ST-PDF-PROD-CODE2)


The first 3 compares are part of your match keys, why dont you
make the other 2 compares also part of your match keys?
Then you could do something like :
Code:

IF MATCHED
END-IF
IF NOT SORT3
END-IF
IF NOT SORT4
END-IF


Or use the whole record as a key.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 11:25 am    Post subject:
Reply with quote

Hi Guys,

Sorry for improper alignment. I will take care going forward.


Input file sample:

Code:
INFILE3 is

000016611|000091588|Farmers Insurance                       |27MA09              |27MA09   ,27MA10   ,27MA11   ,27MA12
000016769|000017481|xyz                       |27MC11              |27MC11
000017155|000017481|xyz                       |27MC04              |27MC15
000017196|000017481|xyz                       |27MC06              |27MC06
000017282|000017481|xyz                       |27MC17              |27MC17
000017360|000091588|xyz                       |27MA05              |27MA05
000017384|000024744|xyz                       |27MB73              |27MB73
000017481|000000000|xyz                       |27MC01              |27MC01
000017495|000017481|xyz                       |27MC05              |27MC27
000019041|000023019|NEWWWWWWWWWWWWWWWWW                     |111111              |37MA09   ,37MA10   ,37MA11   ,37MA12
000019052|000023019|NEWWWWWWWWWWWWWWWWW                     |222222              |37MA09   ,37MA10   ,37MA11   ,37MA12
000019063|000023019|NEWWWWWWWWWWWWWWWWW                     |333333              |37MA09   ,37MA10   ,37MA11   ,37MA12
000019074|000023019|NEWWWWWWWWWWWWWWWWW                     |444444              |37MA09   ,37MA10   ,37MA11   ,37MA12
000019085|000023019|NEWWWWWWWWWWWWWWWWW                     |555555              |37MA09   ,37MA10   ,37MA11   ,37MA12

INFILE4

000016611|000091588|Farmers Insurance                       |27MA09              |27MA09   ,
000016769|000017481|xyz                       |27MC11              |27MC11
000017155|000017481|xyz                      |27MC04              |27MC15
000017196|000017481|xyz                       |27MC06              |27MC06
000017282|000017481|xyz                       |27MC17              |27MC17
000017360|000091588|xyz                       |27MA05              |27MA05
000017384|000024744|xyz                       |27MB73              |27MB73
000017481|000000000|xyz                       |27MC01             |27MC01   ,27MC02
000017495|000017481|xyz                       |27MC05              |27MC27
000019031|000023019|xyz                       |62MT28              |62MT28

My Output file generated is:

Code:
OUTFIL2

000016611|000091588|xyz                       |27MA09  |27MA09   ,27MA10   ,27MA11   ,27MA12
000016769|000017481|xyz                      |27MC11  |27MC11   ,27MA10   ,27MA11   ,27MA12
000017155|000017481|xyz                       |27MC04  |27MC15   ,27MA10   ,27MA11   ,27MA12 
000017196|000017481|xyz                      |27MC06  |27MC06   ,27MA10   ,27MA11   ,27MA12
000017282|000017481|xyz                       |27MC17  |27MC17   ,27MA10   ,27MA11   ,27MA12
000017360|000091588|xyz                       |27MA05  |27MA05   ,27MA10   ,27MA11   ,27MA12 
000017384|000024744|xyz                       |27MB73  |27MB73   ,27MA10   ,27MA11   ,27MA12
000017481|000000000|xyz                       |27MC01  |27MC01   ,27MA10   ,27MA11   ,27MA12
000017495|000017481|xyz                     |27MC05  |27MC27   ,27MA10   ,27MA11   ,27MA12
000019041|000023019|NEWWWWWWWWWWWWWWWWW                     |111111  |37MA09   ,37MA10   ,37MA11   ,37MA12 
000019052|000023019|NEWWWWWWWWWWWWWWWWW                     |222222  |37MA09   ,37MA10   ,37MA11   ,37MA12 
000019063|000023019|NEWWWWWWWWWWWWWWWWW                     |333333  |37MA09   ,37MA10   ,37MA11   ,37MA12
000019074|000023019|NEWWWWWWWWWWWWWWWWW                     |444444  |37MA09   ,37MA10   ,37MA11   ,37MA12 
000019085|000023019|NEWWWWWWWWWWWWWWWWW                     |555555  |37MA09   ,37MA10   ,37MA11   ,37MA12 


In the output file look at the second record. Here
OUT-PDF-PROD-CODE should be 27MC11. Not 27MC11 ,27MA10 ,27MA11 ,27MA12.

Thanks,
Thiru
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 11:54 am    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Hi,

I could nt use the other two fileds as keys since thier record length exceeds 255.

Thanks,
Thiru
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Wed Aug 10, 2011 12:15 pm    Post subject: Re: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Thirumurgann wrote:
Hi,

I could nt use the other two fileds as keys since thier record length exceeds 255.

Thanks,
Thiru


Of course, overlooked that.
Beside in case of a match you only have to compare the last 2 fields
for a record match. But because you cannot sort on the large field
how can you guarantee that there will be any match.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 12:31 pm    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

This could be implemented in easytrieve???

Pls let me knw. If this cant be implemented then pls suggest how to implement this requirement.

Thanks,
Thiru
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 Aug 10, 2011 12:40 pm    Post subject:
Reply with quote

Hello,

Quote:
I will take care going forward.
The Code tag should also be used for data and jcl. I'm not sure exactly how your most recent post is supposed to line up and i deleted the duplicate. . .

Quote:
This could be implemented in easytrieve???
Unless i've misunderstood the requirement this should be doable with Easytrieve.
If you actually write the match code (rather than using the builtin feature) you may have more success. Done properly, this looks like a normal 2-file match/merge exercise.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Aug 10, 2011 1:19 pm    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Are you expecting duplicate keys to be possible on the files?

We need to see the sorted data that is going into the match, and I suspect you do too.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 1:25 pm    Post subject:
Reply with quote

Hi Dick,

The input and the output files have record length greater than 30,000.
Thats what made me complex to handle. since i could nt sort all the 5 fields present in the file. Just i am handling the record with first 3 fields as key. Then what happen's is the record's fectched in to the host variables are being overlapped in the second fetch. I tried to initialize the host variable's

ST-PDF-PRI-PROD-CD1 = ' '
ST-PDF-PROD-CODE1 = ' '
ST-PDF-PRI-PROD-CD2 = ' '
ST-PDF-PROD-CODE2 = ' '

But it dint work. I am getting
A010 INVALID FILE REFERENCE - SORT3

Then i tried with initializing the output fields after every record fetch. I dint get any compilation errors and still i get the records overridden.

Thanks,
Thiru
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


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

PostPosted: Wed Aug 10, 2011 1:34 pm    Post subject:
Reply with quote

A010 INVALID FILE REFERENCE - SORT3

That occurs if there is no match and SORT4 is the active file.
So you can do the following :

Code:

IF MATCHED
 compare the 2 fields not belonging to the keys
 do some processing if equal
 do some processing if not equal
END-IF
IF SORT3
 do some processing with the SORT3 fields
END-IF 
IF SORT4
 do some processing with the SORT4 fields
END-IF
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Aug 10, 2011 1:38 pm    Post subject:
Reply with quote

Thirumurgann wrote:
Hi Dick,

The input and the output files have record length greater than 30,000.
Thats what made me complex to handle. since i could nt sort all the 5 fields present in the file. Just i am handling the record with first 3 fields as key. Then what happen's is the record's fectched in to the host variables are being overlapped in the second fetch. I tried to initialize the host variable's

ST-PDF-PRI-PROD-CD1 = ' '
ST-PDF-PROD-CODE1 = ' '
ST-PDF-PRI-PROD-CD2 = ' '
ST-PDF-PROD-CODE2 = ' '

But it dint work. I am getting
A010 INVALID FILE REFERENCE - SORT3

Then i tried with initializing the output fields after every record fetch. I dint get any compilation errors and still i get the records overridden.

Thanks,
Thiru


Thiru,

There is no sign of DB2 anywhere in your program. You are using non-database files. Files have records. You do not use "host variables". You do not "fetch".

The length of the record is giving you problems, and you are using your DASD very inefficiently. What is the "design" reason behind this?

All the initialisation you show above is unnecessary. The fields you initiliase are the target of an assignment, so previous contents are absolutely irrelevant.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Aug 10, 2011 1:44 pm    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Can you show us how your input files are defined (are they V, VB, F, FB or something else), please?
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 Aug 10, 2011 3:30 pm    Post subject:
Reply with quote

Hello,

How many records does each input file have?

It appears that the 30k fields are not part of the match, but rather are just along for the ride so they shouldnot add to the complexity of the match.

Is there some reason the choice was made to do all of the sorting within the Easytrieve code? This is is a very bad choice for other than small files. . .
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Aug 10, 2011 3:42 pm    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Hello Dick,

TS is comparing the whole record, for an "Update/Insert" extract.

May be a task for SORT.

TS will need to supply all the same answers already asked.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 3:48 pm    Post subject: Re: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Bill Woodger wrote:
Can you show us how your input files are defined (are they V, VB, F, FB or something else), please?


Hi,

I found the issue. I have defined my sort work files wrongly.

FILE SORT3 F 30082 VIRTUAL
ST-PDF-UPN1 01 09 N
ST-PDF-MEM-OF-UPN1 11 09 N
ST-PDF-BU1 21 40 A
ST-PDF-PRI-PROD-CD1 62 20 A
ST-PDF-PROD-CODE1 83 30000 A


FILE SORT4 F 30082 VIRTUAL
ST-PDF-UPN2 01 09 N
ST-PDF-MEM-OF-UPN2 11 09 N
ST-PDF-BU2 21 40 A
ST-PDF-PRI-PROD-CD2 62 20 A
ST-PDF-PROD-CODE2 83 30000 A


But this should be defined as variable block, records varying from 01 to 30082. Please suggest how to define the sort work file for this.

Thanks,
Thiru
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Aug 10, 2011 3:57 pm    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

This will get you a VIRTUAL file with variable length records. You don't need to specify blocking for a virtual file - if my memory is holding-up on this.

[code]FILE SORT3 V 30082 VIRTUAL[/cod]

That is not the end of your problem.

Now your file is variable, but your data definition is not, and if you use that definition you will be looking "beyond the end of the record".

What about your output files? Are they variable? If so, what about your update/insert indicator which is stuck way down the end of the record.

To either proceed with an Easytrieve solution or start with a SORT one, we need answers to the questions already asked.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 4:06 pm    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
Reply with quote

Thanks dude for making me understand.

My input files read from the proc is already variable one and the output files which has been written was also declared as variable.

So i could change my file definition in the easytrieve and i will try to execute.


Thanks to all,
Thiru
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Aug 10, 2011 4:19 pm    Post subject:
Reply with quote

Thiru,

You're not there yet. You need a method to match the variable-length part of your record. You need to relocate you update/insert marker.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Wed Aug 10, 2011 4:38 pm    Post subject:
Reply with quote

Bill Woodger wrote:
Thiru,

You're not there yet. You need a method to match the variable-length part of your record. You need to relocate you update/insert marker.



Hi Bill,

Could you please elobrate on the solution further. I am very new to easytrieve.

Thanks,
Thiru
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 -> CA Products All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

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 Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts DFHRESPONSE returns issue divated CICS 3 Wed Nov 02, 2016 6:32 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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