CL is not a database processing language, so it shouldn’t be used for processing database files. Use an appropriate language. If reverse reading is needed in CL, then create a VIEW (or LF) that presents the rows in reverse order (descending order) and read the VIEW.
Depending on what exactly you mean by ‘reverse order’, OPNQRYF may be the answer to your question.
If we’re talking about reading a file through a reversed index or key, then OPNQRYF is a perfectly valid solution. I’m not aware of any OPNQRYF function or parameter that will provide a simple reverse reading of a file, though. Record numbers don’t seem to be available to OPNQRYF.
Of course, if the file is ordered by a key value, then reading by descending keys will give the same result as reading the file in reverse (with CL).
just use the Keyfield of opnqryf as *descend.
How to create a LF that represents the records in Reverse Order.i mean what steps i do need to follow while creating LF in this Case?..please reply me.
An indexed (keyed) logical file is created for reading by key in reverse by specifying the DESCEND keyword. But that’s not necessarily the same as “reverse order” for a physical file. If “reverse order” means “reverse arrival sequence”, then there is no specification for it. And “arrival sequence” for a file defined with REUSEDLT(*YES) has even less practical meaning because there’s no way to determine what the actual arrival sequence was without relying on a data column such as a timestamp (or a journal entry sequence that covers the life of the file). — Tom