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
what are the key words you must use when using a subfile?
how do I declare a table or array in rpg iv?
during execution, an rpg/400 program automatically follows a sequence of operations for each record that is processed. The built-in program cycle includes the following logical steps.
What is the diff bw PF/LF Name and their Record format name? what is restriction in record format then file name?
Please tell me how to read the records from a file with load an array of size with error conditions(The logic answer for this question is ARR is array of 99 elements Z-ADD 0 IDX *LOVAL SETLL FILE READ FILE 99 *IN99 DOWEQ *OFF IDX ANDLT 99 ADD 1 IDX MOVE FIELD ARR,IDX READ FILE 99 ENDDO).So,Please give me the complete of this code.
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?
Set on command is used for closed all opened files , initialize var and release resource , return cmd is used for return to calling program but my req. Is dnt close opened files and resource must released while doing transactions , how can i do this...?
how do I preserve and clean the array?
How would display prime numbers using CL program?
When it is desirable to describe files Internally?
Assume 2 users are using the same file and first user updates some record in the file. Will the 2nd user will be able to see the updated record or not?
thanks mr.Harshad R Suryawaunshi,i'm new to as400 i think you are telling in rpgile i know only rpg400 if possible can you tell in rpg400
We have job which is running as batch. It takes atleast 06 hours to complete tht job. But I wanna do tht job with in 3 hours?
how do you use commitment control in rpg?
How can we override a file during runtime in rpg?