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

Easytrieve - logic to add/change when matching files


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Mon Aug 22, 2011 9:34 am
Reply with quote

Hi Guys,

I wanted to compare the two files say current and previous day files.

1)If match found then set a indicator D in first byte then the actual record follwing that.

2)If new record got inserted then set a flag I in first byte and then the actual record.

3)If an already existing record is updated (i.e) the set an indicator U in first byte.

In this code either insert or update has been coded. but no both of them.
Please suggest some way to code both the logic.

My code is given below:

SORT INFILE1 TO SORT1 USING (IN-PC-UPN1, IN-PC-MEM-OF-UPN1, +
IN-PC-BUI1, IN-PC-PRI-PRD-CD1, +
IN-PC-PRD-CD1, IN-PC-FULL-NAME1)
*--------------------------------------------------------------------
*SORT PREVIOUS VERSION OF PROFILE FEED FILE
*--------------------------------------------------------------------
*
SORT INFILE2 TO SORT2 USING (IN-PC-UPN2, IN-PC-MEM-OF-UPN2, +
IN-PC-BUI2, IN-PC-PRI-PRD-CD2, +
IN-PC-PRD-CD2, IN-PC-FULL-NAME2)
*--------------------------------------------------------------------
JOB INPUT (SORT1 KEY(ST-PC-UPN1, ST-PC-MEM-OF-UPN1, +
ST-PC-BUI1, ST-PC-PRI-PRD-CD1, +
ST-PC-PRD-CD1, ST-PC-FULL-NAME1), +
SORT2 KEY(ST-PC-UPN2, ST-PC-MEM-OF-UPN2, +
ST-PC-BUI2, ST-PC-PRI-PRD-CD2, +
ST-PC-PRD-CD2, ST-PC-FULL-NAME2))
*
IF MATCHED
OUT-PC-CHNG-FLG = 'D'
OUT-PC-UPN = ST-PC-UPN1
OUT-PC-MEM-OF-UPN = ST-PC-MEM-OF-UPN1
OUT-PC-BUI = ST-PC-BUI1
OUT-PC-PRI-PRD-CD = ST-PC-PRI-PRD-CD1
OUT-PC-PRD-CD = ST-PC-PRD-CD1
OUT-PC-FULL-NAME = ST-PC-FULL-NAME1
PUT OUTFIL1
ELSE
IF SORT1
OUT-PC-CHNG-FLG = 'I'
OUT-PC-UPN = ST-PC-UPN1
OUT-PC-MEM-OF-UPN = ST-PC-MEM-OF-UPN1
OUT-PC-BUI = ST-PC-BUI1
OUT-PC-PRI-PRD-CD = ST-PC-PRI-PRD-CD1
OUT-PC-PRD-CD = ST-PC-PRD-CD1
OUT-PC-FULL-NAME = ST-PC-FULL-NAME1
PUT OUTFIL1
END-IF
END-IF

Here i have declared all the fields of input file as key to faclitate the compare without any dups.

The problem i faced was since the inserted/updated record would present
only in current version (i.e) in this case its SORT1. here plese suggest how to code so that inserted and updated records are identified.


Thanks,
Thiru
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 Aug 22, 2011 10:04 am
Reply with quote

Hello,

When you have a new question, you need to start a new topic. This has been split from the original topic.

Suggest you post some sample input data for both files, the output you want when this is processed, and where you are stuck. It seems to me that when there is a match, the current would be the update. If you insist on comparing the entire record, i don't see how you would get what you want. You need to match on the "key" and when they are equal, compare the other fields. . .

Possibly i misunderstand.
Back to top
View user's profile Send private message
Thirumurgann

New User


Joined: 13 Feb 2008
Posts: 36
Location: India

PostPosted: Mon Aug 22, 2011 10:29 am
Reply with quote

Hi Dick,

Since this question is more similar to the one which already had been posted, so i posted the new question in same post.

The issue here is whenever the insert/update happens it would happen only in latest file that is SORT1 not in the SORT2.

So i couldnt code these logic because there wont be any seperate check point for insert/updated records in SORT1.

when i try to compare the ST-PC-UPN1 = ST-PC-UPN2 To get the update record the runjob endup with RC 16.

Hence when i code for inserted records the updated records also comes along with that. I hope this time i am clear possibly.

Here is the full code:

IF MATCHED
OUT-PC-CHNG-FLG = 'D'
OUT-PC-UPN = ST-PC-UPN1
OUT-PC-MEM-OF-UPN = ST-PC-MEM-OF-UPN1
OUT-PC-BUI = ST-PC-BUI1
OUT-PC-PRI-PRD-CD = ST-PC-PRI-PRD-CD1
OUT-PC-PRD-CD = ST-PC-PRD-CD1
OUT-PC-FULL-NAME = ST-PC-FULL-NAME1
PUT OUTFIL1
ELSE
IF SORT1 AND (ST-PC-UPN1 = ST-PC-UPN2)
OUT-PC-CHNG-FLG = 'U'
OUT-PC-UPN = ST-PC-UPN1
OUT-PC-MEM-OF-UPN = ST-PC-MEM-OF-UPN1
OUT-PC-BUI = ST-PC-BUI1
OUT-PC-PRI-PRD-CD = ST-PC-PRI-PRD-CD1
OUT-PC-PRD-CD = ST-PC-PRD-CD1
OUT-PC-FULL-NAME = ST-PC-FULL-NAME1
PUT OUTFIL1
ELSE
OUT-PC-CHNG-FLG = 'I'
OUT-PC-UPN = ST-PC-UPN1
OUT-PC-MEM-OF-UPN = ST-PC-MEM-OF-UPN1
OUT-PC-BUI = ST-PC-BUI1
OUT-PC-PRI-PRD-CD = ST-PC-PRI-PRD-CD1
OUT-PC-PRD-CD = ST-PC-PRD-CD1
OUT-PC-FULL-NAME = ST-PC-FULL-NAME1
PUT OUTFIL1
END-IF
END-IF

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

Global Moderator


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

PostPosted: Mon Aug 22, 2011 10:34 am
Reply with quote

IF SORT1 AND (ST-PC-UPN1 = ST-PC-UPN2)
means there is no SORT2 record, hence all SORT2 fields will
be undefined, and an error will happen.
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: Mon Aug 22, 2011 11:08 am
Reply with quote

For an "insertion", a record will only appear on the current file.

For an "update", a record will appear on both files (with the keys matched).

For a "delete", (if it is possible for your system) a record will only appear on the previous file.

For a "nothing has happened to this today", a record will appear on both files (with the keys matched).

So, once you get the match you have to, as Dick has said, check whether anything has changed.

You do have a potential problem. In this, and your previous Easytrieve on here, you haven't coded for "deletes", you haven't done anything with SORT2 where it might exist on it's own.

Maybe you don't allow deletes, so that is OK? But if you change anything in one of your fields defined as a key, then it will "look" like a delete, ie the matching will find it only on SORT2 and you will miss it completely.
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 -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top