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
 

 

Easytrieve - logic to add/change when matching files

 
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: Mon Aug 22, 2011 9:34 am    Post subject: Reply to: Issue in comparing files using EASYTRIEVE
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

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Aug 22, 2011 10:04 am    Post subject:
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    Post subject:
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: 2429
Location: Netherlands, Amstelveen

PostPosted: Mon Aug 22, 2011 10:34 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Mon Aug 22, 2011 11:08 am    Post subject: Reply to: Easytrieve - logic to add/change when matching fil
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    IBMMAINFRAMES.com Support Forums -> CA Products All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Easytrieve report shalem CA Products 4 Sun Feb 26, 2017 9:08 am
No new posts Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 am
No new posts Matching and unmatching records scdinesh DFSORT/ICETOOL 11 Tue Feb 07, 2017 12:41 am


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