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



On Tue, 20 Mar 2007, Joe Pluta wrote:

The Java Toolbox (JTOpen) will allow a Java program on any machine
(including a servlet under Tomcat) to call a program on the iSeries.  The
machine has to be at V4R4 or above, I believe, but that's pretty much the
only issue.

Ok, I've been reading and re-reading the javadocs on how to do this. I think I have it mostly correct, but when I try to load a page that uses my class the page never finishes loading and appears to never return from program.run(). Could some kind soul look at my code below and tell me what I've done wrong?

The RPG program *entry plist:

C     *entry        plist
C                   parm                    customer          5 0
C                   parm                    discountcode      2
C parm linecode 2 C parm part 18
C                   parm                    quantity          7 0
C                   parm                    price             9 4

The first five parms are all input, the last is returned.

The relavent portion of my class:

(here customer.getDiscountCategory(), supplier, and formatted are all Strings, price is a Double)

ProgramCall program = new ProgramCall(newConn1);
try {
    // Initialize the name of the program to run.
    String programName = "/QSYS.LIB/DSTCUST.LIB/TCGETPRCIR.PGM";
    // Set up the 6 parameters.
    ProgramParameter[] parameterList = new ProgramParameter[6];
    // First parameter is customer number (5,0)
    AS400PackedDecimal custnum = new AS400PackedDecimal(5, 0);
    //parameterList[0] = new 
ProgramParameter(custnum.toBytes(customer.getId()));
    parameterList[0] = new ProgramParameter(custnum.toBytes(60600.0));
    // Second parameter is discount code (2)
    AS400Text disctext = new AS400Text(2);
    parameterList[1] = new 
ProgramParameter(disctext.toBytes(customer.getDiscountCategory()));
    // Third parameter is line code (2)
    AS400Text linetext = new AS400Text(2);
    parameterList[2] = new ProgramParameter(linetext.toBytes(supplier));
    // Fourth parameter is part (18)
    AS400Text parttext = new AS400Text(18);
    parameterList[3] = new ProgramParameter(parttext.toBytes(formatted));
    // Fifth parameter is quantity (7,0)
    AS400PackedDecimal qtynum = new AS400PackedDecimal(7, 0);
    parameterList[4] = new ProgramParameter(qtynum.toBytes(1));
    // Sixth parameter is price (9,4)
    AS400PackedDecimal pricepd = new AS400PackedDecimal(9, 4);
    parameterList[5] = new ProgramParameter(pricepd.toBytes(0.0));
    // Set the program name and parameter list.
    program.setProgram(programName, parameterList);
    // Run the program.
    if (program.run() != true) {
        // Report failure.
        System.out.println("Program failed!");
        // Show the messages.
        AS400Message[] messagelist = program.getMessageList();
        for (int i = 0; i < messagelist.length; ++i) {
            // Show each message.
            System.out.println(messagelist[i]);
        }
        // Else no error, get output data.
    } else {
        AS400PackedDecimal priceresult = new AS400PackedDecimal(9, 4);
        price = priceresult.toDouble(parameterList[5].getOutputData());
        System.out.println("Price obtained");
    }
} catch (Exception e) {
    System.out.println("Program " + program.getProgram() + " issued an 
exception!");
    e.printStackTrace();
}
// Done with the server.
system.disconnectAllServices();
// Return connection to pool.

testPool1.returnConnectionToPool(newConn1);


James Rich

It's not the software that's free; it's you.
        - billyskank on Groklaw

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.