How can read PF in reverse order (end to start) in CL pgm..

Answer Posted / harkesh

you can read a physical file in DESENDING ORDER. You can
first sort the physical file in decending order through
OPNQRYF using KEYFLD. This will sort your PF in decending
order based on your key field and then do the RCVF on this
file.
But for this you first need to do OVRDBF on the file.

THIS IS ONLY THE WAY ON THE WE CAN READ PF IN REVERSE ORDER
BUT FOR THIS FILE SHOULD BE KEYED FILE.
ANOTHER WAY FOR THIS ON THE BASIS OF RRN. FIRST FIND OUT
TOTAL NO OF RECORD USING RTVMBRDSC COMMMAND IN CL PROGRAM.
THEN MOVE TOTAL NO TO RRN. THEN BY USING OVRDBF COMMAND SET
POINTER ON THE BASIS OF RRN. AND IN LOOP ON THE BASIS OF
RRN. LIKE
LOOP: OVERDBF FILENAME POINTER = &RRN
IF RRN NOT = 0
RCVF RCDFMTNAME.

RRN= RRN-1.

ELSE
ENDPGM
END-IF.

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is kids-rpg?

916


Hi Viewers can any body explain me how to update and ahange the already existed data in physical file using subfile ? please explain me with the code if possible?

4793


what is an online rpg?

1008


can anybody help me to solve this problem. the program that i m checking display error message saying "Record format for file AJDSPFFD does not match model file and decimal error. how to solve this problem. The AJDSPFFD is snapshot the AJTLOG that is the audit trail list.

2579


give an eg of ACQ-(ACQUIRE),BIT OFF,BIT ON,DEALLOC,DUMP,FEOD,FORCE,MHHZO,MHLZO,MHLLZO,MLHZO,REL,RESET,TESTZ,TESTB,TESTN----GIVE SMALL EXAMPLE TO THE OPCODES...TO UNDERSTAND FUNCTIONING...........

3588


what is program status data structure?

1872


When we have a file with Duplicate records and I want to read the unique record from the file. For example a file containing Emp Name as 'Ram' and there are 3 entries of it. So how to read a unique record from File?

760


what is the rpg system?

974


What is difference between bind by copy and bind by reference?

2155


what is data area and how it is used in rpg program ?

1059


what is a rpg?

953


write an RPG program to calculate the marks of 5 students (A,B, C, D, E)in 3 different subjects (eng, math, sci) an display on the screen

1096


Suppose we have one database file and it is used by 5 programs and in 3 program we have to add some records in datbase file s what is the impact on other program?

1701


what are the key words you must use when using a subfile?

917


if there is a module object , how to find the program object for this module object.Assume the module object name and program object name is not same.

2429