× 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 just released the public version of JDB/400, which is a package that allows
easy access to AS/400 data.

How easy?  There are only two classes: Jdb400KeyedFile and Jdb400SequentialFile.
Both of them are created with good old AS/400 syntax (like
"LIBRARY/FILE.MEMBER").  Jdb400KeyedFile supports READ, READP, CHAIN, SETLL and
READE methods, while Jdb400SequentialFile supports READ, READP and CHAIN.  And
the best thing is that once you include these classes, you don't need to use
IBM's Java Toolbox to access the AS/400!  All of that is done under the covers.

Oh no, that's not the BEST thing.  The BEST thing is that the public version is
free.  Free as in open source.  Use it, abuse it, modify it, even sell it.
Heck, I don't care.  I just want people to LEARN from it.  There are some real
good object techniques in there (I implement a Singleton pattern to handle the
AS/400 connection, for example, and Jdb400KeyedFile and Jdb400SequentialFile are
subclasses of a common Jdb400File superclass), and I think the package
altogether shows how we object technology can be used to REDUCE the complexity
of APIs, rather than make things MORE complicated.

Here's the keyed file example program in it's entirety:

import java.math.*;
import com.pbd.jdb400.*;

public class TotalOrder
{

  public static void main(String argv[]) {

    Jdb400.setDefaultLibrary("JDB400");

    String orderNumber = argv[0];

    Jdb400KeyedFile ORDHDRL1 = new Jdb400KeyedFile("ORDHDRL1");
    Jdb400KeyedFile ORDDTLL1 = new Jdb400KeyedFile("ORDDTLL1");

    BigDecimal totalAmount = new BigDecimal(0.00);

    if (ORDHDRL1.CHAIN(orderNumber)) {
      totalAmount = (BigDecimal) ORDHDRL1.getField("OHSHIP");
      ORDDTLL1.SETLL(orderNumber);
      while (ORDDTLL1.READE(orderNumber))
        totalAmount = totalAmount.add((BigDecimal) ORDDTLL1.getField("ODXAMT"));
    }

    System.out.println("Total for order " + orderNumber + " is " +
totalAmount.toString());
    System.exit(0);
  }

}

This program takes the order number (passed in from the command line) and CHAINs
to JDB400/ORDHDRL1 to get the shipping amount (OHSHIP) and then does a
SETLL/READE loop through JDB400/ORDDTLL1 totalling up the extended amount for
each line (ODXAMT).  The program then prints the total.  This is about as simple
as the corresponding RPG program, don't you think?

Anyway, if you're interested, feel free to stop by the website at
http://www.zappie.net/Java/Techniques/JDB400/com_pbd.htm to learn more or
download the free version.

Joe


+---
| This is the Midrange System 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/operator: david@midrange.com
+---


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.