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



Hi Tim,
so I'm trying to understand and explain a solution.
First - I think you have one table (I will call it "items") with the item
master data, and another table (I will call it "boxes") which contains one
record for each box of records, and a quantity how many items are in each
box. Is this near?
If yes - simply use SQL to query both tables at the same time:

exec sql declare csrItemBoxes cursor for
         select boxes.id,
                max(boxes.item_id),
                case 
                  when boxes.id is not null
                  then max(items.description)
                  else "Total Quantities:"
                end,
                sum(boxes.quantity)
         from boxes
         join items on items.id = boxes.item_id
         where boxes.item_id = :itemid
         group by rollup (boxes_id);

Now this will give your cursor one line per box and a summary line for all
boxes.
Now loop through that cursor and add a subfile line for each row fetched.
If the "boxes.id" field is "null", you have the summary line - in this
line, the description field will be filled with the text "Total
Quantities:".
Maybe set a flag to give that line another color, and deactivate a line
selection option field, because this is a summary line.
HTH
Daniel
P.S.: As far as I can see, you haven't received a proper RPGLE training,
and now you should change/maintain existing programs. Ask your supervisor
to give you a proper training, find yourself a training
(like [1]systemideveloper.com) or find a tutor/coach who is willing to
help you (for profit or not) - just my 2ct. 

Am 09.09.2023 um 20:52 schrieb tim ken <timk2574@xxxxxxxxx>:

Hi,
They are like below :-
On display file screen (a subfile)
Enter item number :-   .................
Once we enter item number then program need to look for this item number
in
a item master file and if it successfully finds an item in it then it
further checks corresponding boxes ( for each item there might be
multiple
such boxes  in box id field of this same item master file)  and for each
such box there is corresponding 'quantity' field is there in same item
master file so we need to add all such quantities for all the individual
boxes and then finally sum it up and show on display file screen.
Just for more clarification:-
Box no.       Quantity
Box 1           5
Box 2            7
Box 3           15
Then just for example if all the above 3 boxes are there for item number
'xyz' then
Program should be able to read this item master file for a specfic item
number which is entered on display file(which is a subfile with record,
control, header and footer but does not contain column headings on
display
screen for these boxes but such multiple boxes are present in this item
master file for each such item number )
And then program should add quantities for all these boxes and on the
display file(subfile) it should be able to display like :- "Tot
Quantities:     27   Sum"
Thanks a lot.. ..
On Sun, Sep 10, 2023, 00:00 Glenn Gundermann
<glenn.gundermann@xxxxxxxxx>
wrote:

Sorry, my previous reply was incorrect. No need for GROUP BY.Is each
box a

separate row in the item master table or is each box and quantity a

separate column in the same row? If the former:exec sqlSELECT

sum(quantity)    INTO :totalQtyFROM item_master WHERE item_number =

:itemNo;Your display file will define the field TOTALQTY.Yours
truly,Glenn

Gundermannglenn.gundermann@xxxxxxxxx(416) 317-3144

--

This is the RPG programming on IBM i (RPG400-L) mailing list

To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx

To subscribe, unsubscribe, or change list options,

visit: https://lists.midrange.com/mailman/listinfo/rpg400-l

or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx

Before posting, please take a moment to review the archives

at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related

questions.

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

References

Visible links
1. https://www.systemideveloper.com/

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.