× 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 have been running debug and it has yielded no results that I can find


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