Announcing! JDB/400 public version 1.0P is up on the website, folks. In order to access a keyed file on your AS/400, you now need a total of ONE, count 'em, ONE class. The Jdb400KeyedFile class is created using good old AS/400 QSYS syntax ("MYLIB/MYFILE(MYMEMBER)" or ".MEMBER") and supports READ, READP, CHAIN, SETLL and READE processing. The Jdb400SequentialFile class has the same syntax and supports READ, READP and CHAIN. Both handle all the vagaries of connecting to the AS/400 automatically: the first time you create one of these objects, the package attempts to logon to the AS/400. Here's one of the example programs:import java.math.*; import com.pbd.jdb400.*; public class TotalOrder { public static void main(String argv) { Jdb400.setDefaultLibrary("JDB400"); String orderNumber = argv0; 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); } }That program takes an order number from the command line, chains to the ORDHDRL1 file to get the shipment amount (OHSHIP) and then spins through the ORDDTLL1 file adding in the extended amount (ODXAMT), then prints the total. The zip file has two example programs, full source and full javadoc, and it's open-source, meaning you are free to copy it, modify it, use it, even sell it to your heart's content. Click href="http://www.zappie.net/Java/Techniques/JDB400/com_pbd.htm">here to find out more. (Um... there IS a professional version, of course... but we won't advertise that here grin) href="//www.zappie.net/java">src="//www.zappie.net/java/_derived/index.htm_cmp_zero110_vbtn_p.gif" width="140" height="60" border="0" alt="Zappie's Java Home" align="middle">

Reply With Quote