× 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: "William A.(Tony) Corbett" <corbett@xxxxxxxxxxxxxxx>
  • Date: Thu, 22 Jun 2000 01:26:21 -0700
  • Organization: AS/Resources, Inc.

Yeah, that does look simple (and intuitive), doesn't it...  That darn fixed-format RPG is really hard to follow.

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();
> }
> ***********************************************************************
>

------------------------------

--
William A.(Tony) Corbett
corbett@asresources.com
http://www.asresources.com
http://www.cbt400.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.