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


  • Subject: Re: What record return from getNewRecord() ??
  • From: dawall@xxxxxxxxxx
  • Date: Thu, 9 Mar 2000 13:06:53 -0600

I think getNewRecord() is working correctly.  Maybe I can help clear things
up.  GetNewRecord's main use is for adding records to a database file.
getNewRecord will create a record based on the default values for the
fields of a database file.  You then update some or all of the fields then
use SequentialFile or KeyedFile to add the record to the database.  In your
case, you have one field of type char.  When you call getNewRecord(), it
checks the record description and sees one character field.  My guess is
the default for that field is a String of length 0 so your record contains
one empty string.  The "println" is working, but there isn't anything to
show since the record contains only a zero length string.

If you want to read existing records out of a database file you use a read
method on Sequential or Keyed file.  For example,
         AS400 system = new AS400();
// this is a sample database file that is on most AS/400s
         SequentialFile dataf = new SequentialFile(system,
"/QSYS.LIB/QIWS.LIB/QCUSTCDT.FILE");

         AS400FileRecordDescription file_desc =
                                     new AS400FileRecordDescription(system,
 "/QSYS.LIB/QIWS.LIB/QCUSTCDT.FILE");

         RecordFormat datarec = file_desc.retrieveRecordFormat()[0];

         dataf.setRecordFormat(datarec);


dataf.open(AS400File.READ_ONLY,0,AS400File.COMMIT_LOCK_LEVEL_NONE);
         Record dat = dataf.readNext();
                                            // changed from you example
         System.out.println(dat.toString());


David Wall
AS/400 Toolbox for Java


Martinus Ivan <IVANM@MULTIPOLAR.CO.ID> on 03/08/2000 11:36:16 PM

Please respond to JAVA400-L@midrange.com

To:   "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com>
cc:
Subject:  What record return from getNewRecord() ??





> Hi All,
>
> I have a confusion about getNewRecord() method from RecordFormat Class
> (I'm using ToolBox version from JBuilder/400).
> I create a small PF file call MyData and its only have one field (20
*char
> long).
> I add two record in it. And develop a small java program just to learn
the
> characteristic of getNewRecord().
>
> Base on my code below I don't understand :
>    Why the.......System.out.println(dat.toString()).......print nothing
>
> And the disconnectAllServices() didn't work. The program seems do not
> return/finished.
> I'm very sure it not because of object authority problem in AS/400.
> Hope some who have try this method can share it....:)
> Thanks in Advance
>
> regards,
> Ivan. L
>
>
/*************************************************************************
> **********
> import com.ibm.as400.access.*;
>
> class filedesc {
>        public static void main (String args[]) {
>    AS400 TheAS400 = new AS400("XXX.XXX.XXX.XXX");
>
>            try {
>               SequentialFile dataf = new
> SequentialFile(TheAS400,"/QSYS.LIB/MyLib.LIB/MyData.FILE");
>
>      AS400FileRecordDescription file_desc = new
> AS400FileRecordDescription
>
> (TheAS400,"/QSYS.LIB/MyLib.LIB/MyData.FILE");
>
>          //Retrieve the MyData file record format description
>               RecordFormat datarec = file_desc.retrieveRecordFormat()[0];
>
>         // Set the record format for dataf file object before open it
>      dataf.setRecordFormat(datarec);
>
>        // Open the file
>
> dataf.open(AS400File.READ_ONLY,0,AS400File.COMMIT_LOCK_LEVEL_NONE);
>               Record dat = datarec.getNewRecord();
>              System.out.println(dat.toString());
>          }
>      catch(Exception e) {
>         e.printStackTrace();
>          }
>
>    mpcas410.disconnectAllServices();
>
>    }
> }
> /*****************************************************************
>
>
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---



+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.