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



There must be an assignemnt of some sort.

YMDDate = %date( filefield : *YMD);

is a valid expression, but

%date( filefield : *YMD);

is not. There is no assignment there.

On Wed, Jul 2, 2008 at 9:19 AM, Robert Rogerson <robertrogerson@xxxxxxxxxx>
wrote:

Hi Adam, it may be a typo but could omitting the semi-colon in free have
caused this...

/free
%date( filefield : *YMD);
/end-free

RobR
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Adam West
Sent: July 2, 2008 9:24 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Using Subdur

Scott, I used this example and get an error, an SEU error I guess you would
call it.

/free
%date( filefield : *YMD)
/end-free


"Item is not valid as the left-hand side of an EVAL operation. "


--- On Tue, 7/1/08, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:

From: Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
Subject: Re: Using Subdur
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Date: Tuesday, July 1, 2008, 11:49 PM

Adam West wrote:
Also the dates in my file are YYMMDD. I would use the UDATE which is
MMDDYY..

Unless your code needs to be S/36 compatible, don't use UDATE. There
are many, many better ways to do things.

a) Do you really want the job date instead of the system date? The job
date reports the date that your job started (i.e. the date that you
signed on, or the date that a batch job was submitted). The system
date, by contrast, is the current date.

One nice thing about using the "job date" is that you can change it
with
the CHGJOB command. You can change the job date, and that can be useful
for testing programs.

However, it's been my experience that using the system date is USUALLY
what people mean. For example, imagine that 5 years from now, your
company/client decides to have a "never-ending" batch job that's
submitted at IPL time, and it just sits in batch and does stuff. Then
one day it calls your program -- and since the last IPL was 3 months
ago, your UDATE code returns the date from 3 months ago instead of the
current date. Is that what you want it to do? If not, use the system
date..

b) If you decide to keep the job date, you can get the job date in three
ways:
1) You can keep using the archaic UDATE. Problem is, it returns
the date in a 6-digit format, which means that it doesn't
know which century you're in. (Which caused many Y2K
problems -- remember Y2K?)

2) There's *DATE, which is identical to UDATE, except that it
returns an 8-digit date, and thus doesn't have the Y2K
issues. This requires V3R1 or later -- which hopefully
is a non-issue!

3) You can use a date-type field with INZ(*JOB) on the D-spec.
This is a much better option (IMNO) than UDATE or *DATE
because you don't have to muck around with the date format.
UDATE/*DATE are always in the job's date format, and the
user can change that, and it can be different per job
description, etc. It's never a good idea to hard code
*MDY or *USA just because "that's what UDATE is on my
system". When you use INZ(*JOB) on a date field, you
don't have to worry about the format, and your code will
work anywhere, no matter what the user specifies for their
date format.

c) If you decide to use the system date instead (much better, IMHO):

1) Historically this was retrieved with the TIME op-code
(for example, in RPG II or RPG III -- though, it still
works in RPG IV).

2) You can also specify %date() (the %date BIF with no
parameters) and it'll return the current system date
as a date field.

3) You can (similar to the job date) use INZ(*SYS) on a D-spec
to get the current system date.


d) Using a date field is better, even if the field is numeric in the
program. A date field can easily/trivially be converted to a
character or numeric field. It requires almost nothing.

%dec(myDateField: *ISO) <-- returned in YYYYMMDD
%dec(myDateField: *USA) <-- returned in MMDDYYYY
%dec(myDateField: *MDY) <-- returned in MMDDYY
%dec(myDateField: *YMD) <-- returned in YYMMDD
%dec(myDateField: *DMY) <-- returned in DDMMYY

There's a %char() BIF to convert it to character as well. In
character format, you can control which separators are used.

e) You can also easily convert a numeric date to a date field
with the %date() BIF. Just %date( field: format);

%date( filefield : *YMD) <-- reads from a YYMMDD field
and makes it a date field

f) Date fields can be compared against other date fields (even if
they're specified in different formats) without any problems. You can
easily add or subtract days, months or years from any date field.


With all of these options (and there sure are a lot of them) why would
you even consider using the old 6-digit job date in UDATE? IT just
doesn't seem like a good choice to me.
--
This is the RPG programming on the AS400 / iSeries (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.



--
This is the RPG programming on the AS400 / iSeries (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.
--
This is the RPG programming on the AS400 / iSeries (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.