How to differentiate between newly added records and previously added records in Physical file

350 pts.
Tags:
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: July 27, 2009  10:45 AM
UPDATED: July 31, 2009  11:53 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 10  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Kapiltiwari
    How to journal that file on daily basis to copy only newly added records from it. Please tell me all the steps :
    350 pointsBadges:
    report
  • Satsho
    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 pointsBadges:
    report
  • Yorkshireman
    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 www.IBM.com for DB2 manuals on how all of this works - journalling - running the above with SQL.....
    5,520 pointsBadges:
    report
  • WilsonAlano
    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,450 pointsBadges:
    report
  • Kapiltiwari
    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 pointsBadges:
    report
  • WilsonAlano
    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,450 pointsBadges:
    report
  • Teandy
    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,860 pointsBadges:
    report
  • Kapiltiwari
    Thanks Mr Wilson. I m trying to write records to its final destination as Mr Teandy is saying.
    350 pointsBadges:
    report
  • WilsonAlano
    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,450 pointsBadges:
    report
  • Rajgoaj
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following