× 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.



Nisha,
My apologies for getting your name wrong in
my first response.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Nisha Ramesh
Sent: Friday, October 19, 2012 8:52 AM
To: RPG programming on the IBM i / System i
Subject: Fetch the correct record - pls help

Hi All,

I have a scenario like this
I have 3 files , File1, File2, File3.

File1 has account number as a filed
File2 has account number, security and Quantity as fields
File3 has Account number Quantity and Security.

suppose File1 has these values
A
B
C

File2 - Accnum and Sec are keyfileds
Accnum Security Qty
A x 2
A x 3
A x 1
A y 2
A y 3
B y 5
B y 1
C x 2
C x 2

I want to create File3 as a summary. The value should be like this

AccNum Security Qty
A x 6
A y 5
B y 6
C x 4

Without using SQL(I have to change the whole program logic if I go for SQL) By using chain or Reade how can I achieve this in mininum steps

I have used a method like this
Point to the first record in file1 and read from there onwards. With Accnum as the key readE file2 in a loop( the file has accnum and security as keufields but am using Accnum alone not sure whether that will cause any
probs) , save the previous security value and in the DoW not %Eof(File2)loop check whether the prev saved security = Current security, If so sum up the Qty fields, else, write to file3. After endDo, I put the write part again otherwise I was missing the last record which will not enter into the DoW not %Eof loop.

Anyone has any better idea? My logic seems to be complex.. :(
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.