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



Aside from the fact this is a bad design, it is a simple matter, as someone else suggested early on:

Total = qty1 + qty2 + .....

But that is so simple, I just know I missed something - again.

Jerry C. Adams
IBM i Programmer/Analyst
Tradition is just peer pressure from dead people.
--
NMM&D
615-585-2175


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of tim ken
Sent: Sunday, September 10, 2023 7:22 AM
To: RPG programming on IBM i
Subject: Re: Adding all the box quantities for a item

Thanks,

Just for more clarification it's a single file item master which has all
these fields in it item number (which we search on display file screen),
box id, quantities for box id.


One item number mave one or more boxes andeach box has unique box id and
it's quantity in the Quantity field.

Considering this what would be the updated rpgle and sqlrpgle program which
could display the sum of all the corresponding quantities for all such
boxes( I mean sum of quantities associated with each box id) for an item
number on display file screen ?



Thanks much...



On Sun, Sep 10, 2023, 17:13 Jerry Adams <midrange@xxxxxxxx> wrote:

Please excuse me if I missed it, but, like Daniel, I am trying to figure
out exactly what the objective is here. Superficially, I admit, it seems
simple: How much (quantity) do we have in the warehouse for a specific
item. But it could be that we want to know how much is available for
shipment (unallocated).

As Daniel said two tables are needed: (1) an Item Master, and (2) a Lot
Inventory. The Lot Inventory is needed only, in my experience, for
inventory valuation at month-end; i.e., each Lot (or Box) was bought for a
different prices. Here, by the way, I am assuming that we are talking
about generic items, such as books, candy, etc., not high value, discrete
items, such as jewelry that are inventoried, well, discretely.

If all you want to know is how much of any item, regardless of price, is
in inventory, then an SQL over the Lot Table will suffice, as Daniel
illustrated. However, if you want to know how much is available for sales,
then one must include any order allocation. That could be done in the Lot
Table, but the minimum wage packers in the warehouse will pull the item
from whichever Lot (Box) is closest at the time. Because of that and other
quirks, I always keep the allocation in the Item Master and then, as the
order is filled, reduce inventory in the Lot/Boxes since, at the end of the
day the auditors (usually) do not care which box was used.

This is, of course, a simplification; it ignores whether the inventory is
valued on a FIFO or LIFO basis. That distinction is usually only pertinent
when the order is filled and on-hand inventory is reduced. Naturally, your
auditor’s rules may differ or vary somewhat. On the other hand, as someone
else speculated earlier, this seems like a textbook exercise; in which case
ignore everything I said. If not, get the objective defined better and the
rules needed to meet that objective.

Jerry C. Adams
IBM i Programmer/Analyst
What the world needs is more geniuses with humility. There are so few of
us left.
--
NMM&D
615-585-2175

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of
Daniel Gross
Sent: Sunday, September 10, 2023 4:12 AM
To: RPG programming on IBM i
Subject: Re: Adding all the box quantities for a item

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



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.