130 pts.
 copying file in as400 through rpgle
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
ASKED: Jan 2, 2012  7:41 AM GMT
UPDATED: March 17, 2012  6:03:29 AM GMT
285 pts.

Answer Wiki:
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
Last Wiki Answer Submitted:  Jan 3, 2012  10:31 AM (GMT)  by  Renjithgr   285 pts.
Latest Answer Wiki Contributors:  Deepu9321   3,355 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _




 

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

 36,410 pts.

 

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

 36,410 pts.

 

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

 36,410 pts.

 

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

 66,925 pts.

 

rebekahalkhalifa@yahoo.com
Hello…
I wish you best Compliment of the season,with hope that you are physically and healthly alright,l do believe that this mail will reach in good condition. My name is Rebekah i saw your profile in www.itknowledgeexchange.techtarget.com and admire it, i think we can make it together, please i would like you to contact me through my email address:( rebekahalkhalifa@yahoo.com ) i will tell you more about myself, also send you my photo,as soon as you contact me back, hopping for your lovely reply soonest,
Rebekah….

 3,500 pts.