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



Re: your comment on values for %range()- Factor 1 > Factor 2

From the documentation for %range()...
****
The expression using the IN operator with %RANGE is true if the first operand of the IN operator is greater than or equal to the first operand of %RANGE and less than or equal to the second operand of %RANGE.
****

Similar to SQL "BETWEEN", the first operand is the lower limit and the second operand s the upper limit.

I got bit by that many years ago in SQL and developed the habit of wrapping my operands with %min() and %max() to avoid potential issues.

I would argue that the min/max could occur under the covers but... it doesn't so we have to adapt.

Of course, none of this has any bearing on the RDi formatting issue you seem to be experiencing.
Just wanted to point out the limitation(?) of %range().

Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power



-----Original Message-----
From: WDSCI-L <wdsci-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of x y
Sent: Friday, October 13, 2023 10:21 AM
To: Rational Developer for IBM i <wdsci-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: [WDSCI-L] "Formatting failed..." with %RANGE/RDi 9.8/SQLRPGLE

GPIEFF and GPICAN are date data-type variables with values set at run time;
the event is in RDi's source code formatting and not during execution. I
assume %RANGE's code is robust and wouldn't have a digital thrombo if
factor 1 was greater than factor 2.

The application is testing for transactions by effective and cancel date
when I load a subfile (and cancel date, if present, is always >= the
effective date). The date formats are ISO and the code is in a subroutine.

Here's the current code:
select;
when %date in %range(gpieff:gpican) //Between effective
and cancel
or (%date >= gpieff and gpican = *loval); //Past effective, no
cancel (perpetual)
//Currently effective (make row pink)

when %date < gpieff; //Effective in the
future
//Not effective yet (make row blue)

other; //Everything else
//Expired (no color/stay green)

endsl;

Using this logic with a tweak and an ORDER BY CASE construct, you can push
all your effective transactions to the beginning of the data. Many
customers like having current data at the beginning of the subfile.

On Fri, Oct 13, 2023 at 12:04 AM Peter Dow <petercdow@xxxxxxxxx> wrote:

Is it possible that GPIEFF > GPICAN? The online documentation does not
say whether that would cause an error, but since it says

IF x IN %RANGE(y1 : y2);

is equivalent to

IF x >= y1 AND x <= y2;

then it does not seem like it would care. You would simply not get the
result you expect, e.g. if x is 5 and y1 is 9 and y2 is 6, then

IF 5 IN %RANGE( 9 : 3);

and

IF 5 >= 9 AND 5 <= 3;

would both would be false.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx
pdow@xxxxxxxxxxxxxx /



On 10/12/2023 11:39 PM, x y wrote:
This code
when %date in %range(gpieff:gpican)...

in a subroutine appears to cause an intermittent error in RDi: it appears
to break the outlining function that causes and causes the "Formatting
failed--no model available" message. Commenting the code out makes
formatting work and formatting again breaks it. I've used this opcode in
seven other programs and don't recall having a problem with this before
but
I'm going to check.

I ran the problem down by deleting 600 lines of subroutines, adding SR's
back individually, and then trying the formatter. I finally discovered I
had to comment out the line and fiddle with the formatting a couple of
times to make it work.

I'm reading a book written by my old Latin teacher, Bob Gula (R.I.P.), in
which he mentioned Bloch's Law: "Tinker with something long enough and it
will break." Lesson learned!
--
This is the Rational Developer for IBM i (WDSCI-L) mailing list
To post a message email: WDSCI-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/wdsci-l.



--
This is the Rational Developer for IBM i (WDSCI-L) mailing list
To post a message email: WDSCI-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/wdsci-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.