Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaBean -> PCML -> RPG

Status
Not open for further replies.

foongkim

MIS
Apr 8, 2002
5
MY
Hi dear,
I was wondering is it anyone out there tried using this method before to retrieve or call the legacy system that coded in RPG?

This is because I am having some problem where my IBM WebSphere Application Server couldn't locate my PCML files althought I have put tha file in my CLASSPATH.

:)
 
Yes I have tried it. I have got it working from within WDSc. The pcml file has to reside in the same location as the .class file. Also if this class file is in a package then the PCML file name has to be prefixed with that package. See my example code:

Code:
    public static double lookup(AS400 as400, String customer, String branch, String product) throws PcmlException {
        double price = 0.0;
        
        // Create Data Objects 
        ProgramCallDocument pcml;                // com.ibm.as400.data.ProgramCallDocument
        boolean rc = false;                      // Return code for program call
        String msgId, msgText;                   // Messages returned from AS/400

        // Instantiate the Objects (assign the variables)
        pcml = new ProgramCallDocument(as400, "com.ejiw.mincron.hd.PricingLookup");
        pcml.setValue("program.cust", customer);
        pcml.setValue("program.brch", branch);
        pcml.setValue("program.prod", product);

        // Debug statement...Use to view outbound and inbound parms if you need it
        //com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true);

        // Call the Program
        System.out.println("Calling JVCPRICE...");
        rc = pcml.callProgram("program");
        
        // If return code is false, get messages from the iSeries
        if(rc == false) {
            // Retrieve list of AS/400 messages
            AS400Message[] msgs = pcml.getMessageList("program");

            // Loop through all messages and write them to standard output
            for (int m = 0; m < msgs.length; m++)
            {
                msgId = msgs[m].getID();
                msgText = msgs[m].getText();
                System.out.println("    " + msgId + " - " + msgText);
            }
            System.out.println("Call to PROGRAM failed. See messages listed above");
        }
        else { // Return code was true, call to PROGRAM succeeded - woo-hoo!
            BigDecimal prc = (BigDecimal)pcml.getValue("program.price");
            price = prc.doubleValue();
        }

        return price;
    }

Code:
<pcml version="4.0">
    <program name="program" path="/QSYS.LIB/TESTJM.LIB/JVCPRICE.PGM" threadsafe="false">
        <data name="cust" length="6" type="char" usage="input" />
        <data name="brch" length="3" type="char" usage="input" />
        <data name="prod" length="12" type="char" usage="input" />
        <data name="price" length="7" precision="2" type="packed" usage="output"/>
    </program>
</pcml>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top