|
We have a small function in one of our service programs that was
recently changed (no names or reasons to be given). The change seemed
small but is having an immediate impact.
The value keyword was taken off the interface of one of the parameters
so it will be passed by reference now. The callers were not recompiled
to use the new interface.
The passed param and receiving param are both defined exactly as 15p0.
In the function there is a blank name DS with fields. No INZ is on the
DS definition. The sub field is defined as 15s0.
In version 1 the system passed the callers data by value to the function
and then that value was loaded into the DS subfield. No problems. The
subfield loaded just fine.
Now in version 2 (the one without the value keyword) the program crashes
attempting to load the subfield with a data decimal error.
The question I want to answer is why is the function causing a data
decimal error only when passed by reference and not by value?
<code version="1">
<interface>
D CalcUPCChkD PI 1P 0
D UPC 15P 0 Value
</interface>
<blankds>
D DS
D UPCField 15S 0
D UPCAr 1S 0 DIM(15) Overlay(UPCField)
</blankds>
<cspec>
UPCField = UPC*10; // move to left by one
</cspec>
</code>
<code version="2">
<interface>
D CalcUPCChkD PI 1P 0
D UPC 15P 0
</interface>
<blankds>
D DS
D UPCField 15S 0
D UPCAr 1S 0 DIM(15) Overlay(UPCField)
</blankds>
<cspec>
UPCField = UPC*10; // move to left by one
</cspec>
</code>
When I check the field addressing in both versions they are all
different between the caller and callee as I would expect on anything
not call by reference (although pass by reference the addresses are very
close to each other).
Thanks for any insight, Matt
Full function code here http://code.midrange.com/461e637167.html.
--
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 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.