copying file in as400 through rpgle

130 pts.
Tags:
PF
RPGLE retrieval
I have a req: i have a PF (PF1) from which i populate another PF (PF2).Now PF2 can contain max of 24 records.PF1 can have unlimited records.I need to fetch last 24 records from PF1 into PF2.Can any1 give any idea as how to do it? My logic is: i will read PF1 until %eof ,by incrementing a counter. So i will get max records in PF1.Then i will call a CLP pgm,which will CPYF PF1 to PF2 from RCDNBR (counter-24) to counter. After this i will read this file in my pgm. regards, Supriyo

Software/Hardware used:
as400

Answer Wiki

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

You can set the cursor at last record of PF1. Use READP in do loop for 24 records and write in the file. If u want in arrival sequence, move the records in to an array(1 to 24) and after completion, load the file with array values from (24 to 1).

Thanks,
Renjith

Discuss This Question: 4  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
  • philpl1jb
    Trival discussion follows: Total Number of Records - 24 to *END is actually 25 records. Costello used this confusion to short change Abbott in every movie they made. In the film "In the Navy", 1941. Costello also has three ways to prove that 7 times 13 equals 28. . To get 24 records subtract 23 and If the Total Number of Records -23 < 1 then use 1 as the COPY FROM RECORD NUMBER. Phil
    49,550 pointsBadges:
    report
  • philpl1jb
    More serious, trival discussion. There are a number of assumptions in either the CL or the RPG process 1 - no deleted records in the file 2 - no deleted records in the last 24 records 3 - the last 24 records in the file are really the records that you want -- see numerious discussions of Reuse Deleted Records in Physical File REUSEDLT(*YES) Phil
    49,550 pointsBadges:
    report
  • philpl1jb
    If an RPG program calls the CL then the RPG should not have the Copy TO file open at the time of the call. Phil
    49,550 pointsBadges:
    report
  • TomLiotta
    In RPG (or other HLL), an actual READ with a program counter will ignore deleted records. However, a CPYF with FROMRCD() is affected by deleted records. If the file is first reorganized to condense deleted records, then the counts will match. If the file is not reorganized and deleted records are possible, the RPG program can use an INFDS to capture the relative record number of the 24th record from the end. That relative record number can then be used for a CPYF FROMRCD() parameter. Tom
    125,585 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