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

Answers were Sorted based on User's Feedback



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

Answer / shyam

Use OVRDBF Share(*yes)
Use the Openqry file by specified the values on opnqry file

Key field . . . . . . . . . . *NONE
Key field order . . . . . . . *DESCEND

now read file using RCVF command.

Is This Answer Correct ?    26 Yes 11 No

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

Answer / kavitha

POSDBF (*END) points to last record, wont the RCVF command sets on EOF indicator?

Is This Answer Correct ?    11 Yes 7 No

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

Answer / 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

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

Answer / sai

Use OVRDBF Share(*yes)
Use the Openqry file by specified the values on opnqry file

Key field . . . . . . . . . . Key Field name
Key field order . . . . . . . *DESCEND

Is This Answer Correct ?    3 Yes 0 No

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

Answer / sumit gupta

We can not read a pf in reverse order in CL/CLLE. As POSDBF
only set the pointer to *START or *END and once you set it
to *END and then do the read operation, end of file will
reach and there is not such condition(MONMSG) through which
you can read the pf in reverse order.

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.

Is This Answer Correct ?    9 Yes 7 No

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

Answer / suresh

Since the requirement is to Read from end to start, the
parameter *END should be provided to Position.

The statement should look like:

POSDBF OPNID(file name) position(*END)

Is This Answer Correct ?    16 Yes 15 No

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

Answer / amit

See Opnqryf is the right answer. Use the keyfield as told
by others. But it is not necessary to overide the file.

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sajied

use posdbf opnid(file name)
position (*start)

Is This Answer Correct ?    4 Yes 26 No

Post New Answer

More RPG400 Interview Questions

what is batch debug in as400?

3 Answers  


How to read a record from file where there is multiple record occurrence is available?

1 Answers  


Can someone tell me tell me what is meant by message wait...?

1 Answers  


what built in function can be used with SETLL.If you want to check whether the search argument is successful or not? Please give me answer with example?

3 Answers  


1.Can any body share me about thease opcodes with example please.Im new for AS/400.Could u please tell me in real senario? 1.TESTN, 2.EVAL 3.EVALR, TIME, 4.MONITOR 5. ENDMON 6.ON-ERROR 7.COMMIT ROLLBACK?

1 Answers   CSC,






I have a RPG program of 100 Lines and first line is to SETON indicator LR. Will the program execute rest of the 99 Lines?

6 Answers  


How to update physical file in rpgle without using display file?

4 Answers   GalaxE, IBM, TCS,


How can we read a particular record from the database file which is not having DDS (Flat File). For example, there are 100 records in the flat file. How can we retrive 15th record in RPG/400 program (Without using CL)

6 Answers   CTS, IBM,


i want code and what are used key words are ...like wrkmbrpdm screen (q) i have a file with 3 fields empno,empname,empaddr... here you give the empno it displays from that number to remaining empno's how? sub file screen: employee details pos to:empno then enter empno empname empaddr so file have 100 records from 1 to 100 so the above pos you give the 55 empno...it displays the from 55 to remaining... ...... please share this answel

2 Answers   IBM,


how can we find setll setgt chain read reade readp operations are successfull or not,give example.explain in detail.

4 Answers   iSoft, Wipro,


1. I have2 records in a PF. READ PF DO DSPLY EMPNO RETRN DSPLY EMPNO ENDDO What was the output 2. SETON LR vs RETURN 3. Primary File 4. How to delete a deleted spaces 5. How to read a PF in reverse order in CL 6. I have a object in Lib A, B and C. But it shows in D Lib..Why? 7.

4 Answers   HCL,


1.Suppose my file has 10 fields and I want to make the 2nd field Zeros in all records. And assume I have millions of records and I dont want to read each record and update the desired field with 0. Any other way to do this in one step operation? 2. Assume my file has 100 records and I want to see only first 10 records. Is this possible through LF? 3.I have 3 jobs A B and C. I want to submit B after successful completion of A and want to submit C after successful completion of B. Without using job scheduler or job queue, how can i do that through CL program? 4.What is difference between Bind by copy and bind by reference?

4 Answers   Virtusa,


Categories