|
From: Gene Burnsbefore
CHAIN followed by UPDATE, but with an externally defined DS.
fhclmmas uf E K DISK
| d mstrDS e ds extname(hclmmas)
// get the current record from the file
chain (cmyrin: cmycin) clmmas; // loads mstrDS
// compare the current record in the file to the original
// making changes
if savmstr = mstrDS;
mstrDS = newmstr; // set fields to new values
clchgd = today;
clchgt = %time();
clchgu = userid;
update clmmas;
savmstr = mstrDS; // update saved DS to new values
origscreen = screenDS;
completed = *on;
else; // file has been changed by another user
unlock hclmmas;
completed = *off;
message = NoUpdMst + %trim(clchgu) + Retry;
wrkadj = *zero;
wrkadj2 = *zero;
wrkadj3 = *zero;
endif;
else;
When the file has been updated by someone else the DS are different,
HCLMMAS
is unlocked, and the message is (supposedly) set telling the user who
updated the file.
I'm not sure what you're saying. The code is fine, and you should get
errors if someone changes the record (provided savmstr and newmstr are the
correct size).
The CLCHGU field is in the file, but is blank at thisbeen
point in the program. Checking the file shows that these fields have
updated and CLCHGU is not blank.
At WHAT point? Since the "mstrDS = newmstr" wipes out the original data,
the only place where the fields are guaranteed to match the file is the if
statement immediately after the chain but before the mstrDS = newmstr is
executed. If at that point you see the file different than what you have
in
your program, then you have a problem I have never encountered in my
career.
Anything other than that is more than likely a logic problem.
Joe
P.S. You also aren't checking for a not found condition on the chain, and
you definitely should in case someone deleted the record.
--
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 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.