× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Only guessing but the .txt attachment seems to only
include something about the RPG list at midrange,
but I would check your RPG F spec and make sure you
have specified the exact file name and have a "K" in
the F spec "Record Address Type" (column 34 I believe)


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Nisha Ramesh
Sent: Monday, October 07, 2013 8:48 AM
To: RPG programming on the IBM i / System i
Subject: Keyed file is not appearing in sorted Order

Hi All,

Please consider the below scenario, I need your valuable input on this.

I have a program which ran daily(From monday to friday) and will generate report from a file(Say fileA) which has fields - 'Date the report is ran'
, and Balance keyed by Date.

Now I need to run a monthly report(At month End) which will report all the daily balances for that month. Since there are no daily report for Sat and Sun, I need to report sat and sun with Friday's balance. At the end I need to show the average balance as well

For that I am creating a duplicate of FileA in Qtemp and then with OpnqryF I select only those balances of current Month. Then override the file to Qtemp with Share(*Yes).
Then I call an RPG program am reading FileA in a loop and using an SQL am determining whether the date falls on Friday. If the SQL returns value for Friday, then I will call a subroutine which will increment the date by one and write a record(Using RPG WRITE Opcode). Again the same for Sunday. At the end, using an SQL, am calculating the average balance.

But unfortunately the sat and sun records are not written in order, it writes at the end. Please see the attachment for reference. I am wondering if the file is keyed, then why the WRITE opcode is writing at the end and not inserting the record in the order?

I know the query appears is little big.. but am higly dependent on your valuable inputs. Please help me if you are able to find where am missing.

Regards
Nisha

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.