× 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: Calling RPGIV from Java
  • From: "L. S. Russell" <leslier@xxxxxxxxxx>
  • Date: Wed, 21 Jun 2000 22:35:58 -0500

That was a good one James :) Lol

"James W. Kilgore" wrote:
> 
> I'm glad to see an example of how much easier JAVA is to program in and how 
>much our productivity
> will increase.
> Stupid me, when I want the price, I just CHAIN. ;-)
> 
> Since JAVA is a code once, run anywhere, sort of deal, I'm sure that this 
>code will work on all
> platforms that support JAVA.
> 
> Kalman Shor wrote:
> 
> > The following calls an RPG program that passes back a packed numeric field -
> > the price.
> > It actually works reasonably quickly. Most of the code is just to set up the
> > call and convert the data back and forth.
> >
> > ****************************************************************************
> > *******
> > try {
> >         // create program call
> >         com.ibm.as400.access.ProgramCall pgm = new
> > com.ibm.as400.access.ProgramCall();
> >
> >         // identify the program to run
> >         String progName = "/QSYS.LIB/YOUR.LIB/GETPRCB.PGM";
> >
> >         
>RLAccess.xx2000201.connectService(com.ibm.as400.access.AS400.COMMAND);
> >
> >         // create parameter list for the program
> >         com.ibm.as400.access.ProgramParameter[] pList = new
> > com.ibm.as400.access.ProgramParameter[3];
> >
> >         // this is for conversion of java String to/from native
> >         com.ibm.as400.access.AS400Text rtParm = new
> > com.ibm.as400.access.AS400Text(1);
> >
> >         // identify fist param
> >         pList[0] = new 
>com.ibm.as400.access.ProgramParameter(rtParm.toBytes(" "),
> > 1);
> >
> >         // this is used to convert between java(BigDecimal) and Packed 
>floating
> > point decimal
> >         com.ibm.as400.access.AS400PackedDecimal cust = new
> > com.ibm.as400.access.AS400PackedDecimal(6, 0);
> >
> >         // identify param
> >         pList[1] = new 
>com.ibm.as400.access.ProgramParameter(cust.toBytes(new
> > java.math.BigDecimal(custNumber")), 4);
> >
> >         // this is for conversion of java String to/from native
> >         com.ibm.as400.access.AS400Text item = new
> > com.ibm.as400.access.AS400Text(15);
> >
> >         // identify param
> >         pList[2] = new 
>com.ibm.as400.access.ProgramParameter(item.toBytes(new
> > String(skuNumber)), 15);
> >
> >         // this is used to convert between java(BigDecimal) and Packed 
>floating
> > point decimal
> >         com.ibm.as400.access.AS400PackedDecimal pric = new
> > com.ibm.as400.access.AS400PackedDecimal(7, 2);
> >
> >         // identify param
> >         pList[3] = new 
>com.ibm.as400.access.ProgramParameter(pric.toBytes(new
> > java.math.BigDecimal("0")), 4);
> >
> >         // set the system to AS/400
> >         pgm.setSystem(RLAccess.xx2000201);
> >
> >         // set program and parameters
> >         pgm.setProgram(progName, pList);
> >
> >         // run the program
> >         if (pgm.run() != true) {
> >
> >                 com.ibm.as400.access.AS400Message[] messageList = 
>pgm.getMessageList();
> >                 for (int msg = 0; msg < messageList.length; msg++) {
> >
> >                 // this is to print error message to standard out
> >                 System.out.println(messageList[msg]);
> >                 }
> >         } else {
> >
> >                 if (((String) (rtParm.toObject(pList[0].getOutputData(), 
>0))).equals(" "))
> >                 {
> >                         // get the price
> >                         intPrice = (((java.math.BigDecimal) (new
> > com.ibm.as400.access.AS400PackedDecimal(7, 2)).toObject(pList
> > [3].getOutputData(), 0)).doubleValue());
> >
> >                         // add to the orderPrice;
> >                         OrderDetail.orderPrice = OrderDetail.orderPrice + 
>intPrice;
> >
> >                         // create number format for displaying the price
> >                         java.text.NumberFormat nf = 
>java.text.NumberFormat.getCurrencyInstance();
> >
> >                         // set the text
> >                         
>getJLabelOrderPrice().setText(nf.format(OrderDetail.orderPrice));
> >
> >                         // set instance variable
> >                         this.childPrice = intPrice;
> >                         }
> >         }
> > } catch (Exception e) {
> >         e.printStackTrace();
> > }
> > ***********************************************************************
> >
> 
> +---
> | This is the RPG/400 Mailing List!
> | To submit a new message, send your mail to RPG400-L@midrange.com.
> | To subscribe to this list send email to RPG400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: david@midrange.com
> +---

--
L. S. Russell Programmer/Analyst
Datrek Professional Bags, Inc.
2413 Industrial Drive
Springfield, TN. 37172
mailto:leslier@datrek.com
http://www.datrek.com
--
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-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 ...

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.