How to differentiate between newly added records and previously added records in Physical file
175 pts.
0
Q:
How to differentiate between newly added records and previously added records in Physical file
i have physical file in which records are added on daily basis. i have to copy record to another Flate file. How can i recognise the block of newly added records?
There is no date field in Physical File sothat i can copy records on date basis.
ASKED: Jul 27 2009  10:45 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
24610 pts.
0
A:
 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0
  • AddThis Social Bookmark Button
No, there is no create date on the record - unless you add one or you could add a CopyDate field or a copyflg field, updated by this process.

Alternative - if your file is journalled you can get the records from the journal.

Phil

At the start of each day, before any records are added to the file, run a job that extracts the number of records in the file. Add 1 to the result & save it in a data area.

DCL &RECORDS *DEC 10 0
RTVMBRD FILE(yourfile) NBRCURRCD(&RECORDS)
CHGVAR VAR(&RECORDS) VALUE(&RECORDS + 1)
CHGDTAARA DTAARA(&dataarea) VALUE(&RECORDS)

At the end of the day, run your job, amended so that it retrieves the record count from the data area & copies records using this value as a starting point.

DCL &RECORDS *DEC 10 0
RTVDTAARA DTAARA(&dataarea) RTNVAR(&RECORDS)
CPYF FROMFILE(yourfile) TOFILE(flatfile) FROMRCD(&RECORDS)

This does assume that records are stored in arrival sequence and that deleted records are not re-used).

Hope this helps
Jeremy

*********************************
Summary answers include:
1. Journalling and recovering puts from the journal
2. Creating a second file with keys that have been copied
3. Keeping record count and coping from record count to end each day
4. Adding a CrtDate, or CopyDt or CopyFlg to the existing file
5. Trigger

issues before you start
1. Journalling sounds like you're not up-to-speed on this.

3. Record count - issues
Deleted records
Reorgs
Reuse Delete
5. Cool but .. up the skill level a bit.

Phil
Last Answered: Jul 27 2009  8:40 PM GMT by Philpl1jb   24610 pts.
Latest Contributors: JSellick   105 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Kapiltiwari   175 pts.  |   Jul 27 2009  1:52PM GMT

How to journal that file on daily basis to copy only newly added records from it.

Please tell me all the steps :

 

Satsho   1235 pts.  |   Jul 27 2009  3:57PM GMT

Step 1 - Create a Journal receiver - CRTJRNRCV

Step 2 - Create a Journal

Step 3 - Add the file to the Journal - STRJRNPF - in your case, it would be with *AFTER image

Ensure you start and end commitment control in your CL programs or COMMIT in RPG.

 

Yorkshireman   3200 pts.  |   Jul 27 2009  4:14PM GMT

To ensure that you collect *ALL records, provide a file containing the keys of the records in the Physical file.
When you copy a record, place its key in the new file.
Tomorrow, and every day therafter, check the new file to see if the record has been copied, and if it has not, copy it, and place its key in the new file.

This will work through every disaster, barring a powerdown in mid updtae, in which case you may lose a record - provide a timestamp on your new file.

I recommend <a href="http://www.IBM.com" title="http://www.IBM. " target="_blank">www.IBM.com</a> for DB2 manuals on how all of this works - journalling - running the above with SQL…..

 

WilsonAlano   2005 pts.  |   Jul 27 2009  7:12PM GMT

Hi,

I suggest a trigger over the original file to add a record to a temp file that you just copy at end of the day and clear it for the next day process.

Regards,
Wilson

 

Kapiltiwari   175 pts.  |   Jul 28 2009  7:05AM GMT

Hearty thanks to all of you. I have solved .

I wanna know more explanation from Mr. Wilson Alano Junior about how to copy only new records of Physical file by CL program called on insert after trigger.
Please explain this in detail.

Thanks

 

WilsonAlano   2005 pts.  |   Jul 28 2009  3:43PM GMT

Hi Kapil,

What I was suggesting was a RPGILE trigger for “after insert”. You can do that in CL but it’s not easy (CL do not have “native” write to files).

If you don’t know how to make a trigger program you can take a look at this link

 <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/dbp/rbaforzahftrb.htm" title="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/dbp/rbaforzahftrb.htm" target="_blank">http://publib.boulder.ibm.com/infocenter…</a>

The idea is, for each record inserted in the original file, trigger a program that take the record image and write it in a temporary file. You must have a end-of-day process to copy this temp file to its final destination and clear the temp file for next day.

Regards,
Wilson

 

Teandy   3250 pts.  |   Jul 28 2009  9:06PM GMT

I’m curious as to why you would bother with a temporary file. Why not write the record to its final destination and be done with it?

 

Kapiltiwari   175 pts.  |   Jul 29 2009  6:09AM GMT

Thanks Mr Wilson.

I m trying to write records to its final destination as Mr Teandy is saying.

 

WilsonAlano   2005 pts.  |   Jul 29 2009  3:31PM GMT

I had the same thoughts about writing directly to the final destination but I assumed (!) that it wasn’t possible for some reason (EOD process needs, remote location of final destination or something like that).

 

Rajgoaj   150 pts.  |   Jul 31 2009  11:53AM GMT

Every EOD the latest RRN number could be stored in a data area, the next day you will find the new records with RRN number greater than the one stored in that data area previous day.

 
0