350 pts.
 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.

Software/Hardware used:
ASKED: July 27, 2009  10:45 AM
UPDATED: July 31, 2009  11:53 AM

Answer Wiki:
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 Wiki Answer Submitted:  July 27, 2009  8:40 pm  by  philpl1jb   44,180 pts.
All Answer Wiki Contributors:  philpl1jb   44,180 pts. , JSellick   115 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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

Please tell me all the steps :

 350 pts.

 

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.

 1,245 pts.

 

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 http://www.IBM.com for DB2 manuals on how all of this works – journalling – running the above with SQL…..

 5,505 pts.

 

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

 2,385 pts.

 

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

 350 pts.

 

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

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/dbp/rbaforzahftrb.htm

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

 2,385 pts.

 

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?

 5,830 pts.

 

Thanks Mr Wilson.

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

 350 pts.

 

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).

 2,385 pts.

 

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.

 280 pts.