If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
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.
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).
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
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.
Tom
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).
Tom
just use the Keyfield of opnqryf as *descend.
Hi Tom,
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