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



I am sorry for the stupid questions I have been asking, I am doing as
much reading as I can and maybe I am getting ahead of myself, but I
really do want to learn this and learn it right...I suppose I probably
should just write everything in C since I have been doing it for so many
years but I really need and want to learn RPG.

I did add the move statements to the C specs and that seemed to fix the
problem, I was not aware of the problem you indicated, thank you for
pointing that out to me....I suppose after having an accident with my
truck yesterday (less than a week old and totaled - one of those nice
big Illinois Bucks through the windshield) I have learned two lessons :)

Douglas


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Pluta
Sent: Sunday, December 05, 2004 3:10 PM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Assistance in writing new / updating existing records


<chuckle>

This brings back memories, Douglas.  You're running across each and
every problem a beginning RPG programmer will run across.  What you need
to do is spend some time learning DEBUG (or better yet, get WDSC and use
the integrated debugger) so that you can walk through your program and
see what it does, line by line.  But until then, let's try a simple mind
exercise.

> C                   EXFMT     EDTCHRTACT                     
  (...)
> C     ACCTNO        CHAIN     ACCTS                          
> C                   UPDATE    ACCTS                          

These are the lines in question.  You have a field DESCRIP in your
display file and in your database file.  Let's say the DESCRIP field
starts out as "DESC1" in the database.  When you execute the EXFMT, the
user sees "DESC1" and types over it, changing it to "DESC2".  You want
this value, DESC2, to go into the database, correct?

Well, when you do ACCTNO CHAIN ACCTS, guess what happens to DESCRIP?  It
gets set back to the value currently in the database, "DESC1" (this is
fact happens to ALL the fields).  So when you do the UPDATE, you're just
updating the record with its existing values.  In order to change a
record, you must have some MOVE instructions between the CHAIN and the
UPDATE.

So how do you get around this?  There are many schools of thought, but a
lot of us decided against using the same field name in the display file
as the database file, especially for maintenance programs.  Instead, we
use temporary fields in the display file.  This means we have to move
the data from the dataabse to the display file fields, but that's the
price you pay.

As you get out of the RPG III type of coding you're doing and start
using the more powerful features of RPG IV, you'll find that some of
this can be done using data structure, especially qualified data
structures.

Good luck!

Joe


> From: D.W. Palme
> 
> I have written a program where the user enters an account
> number, then the program loosk for a record and if it finds 
> one displays the information on a second display file....that 
> part of this works just fine....the user can then change any 
> information and with a press of the F10 key the record should 
> be updated, or added if it does not exist.....this is the 
> problem.  I will give the code below of the RPGLE program, if 
> anyone wants to see the relevant display file dds I will be 
> happy to give that as well, but I can tell you it has an 
> ACCTNO, DESCRIP, STATUS, CLASS field which are the same names 
> as the fields in the physical file.

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

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.