× 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: "Kalman Shor" <kshor@xxxxxxxxxxxxxxxx>
  • Date: Thu, 22 Jun 2000 10:51:43 -0400
  • Importance: Normal

FYI:

I have been programming in RPG for 19 years (System/34 and on). I love RPG
and couldn't agree more with the knocks on Java. Only one problem...the
lemmings have spoken. The market for Java today is huge. If you listen to
IBM, the AS/400 programmer needs both RPG and Java in his/her skill set
going forward. Java is a difficult language to pick up, but the marketplace
is talking.

P.S. This could have been a 5 line RPG program. I'm hoping to get paid by
the line in the future.

-----Original Message-----
From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On
Behalf Of James W. Kilgore
Sent: Wednesday, June 21, 2000 11:18 PM
To: RPG400-L@midrange.com
Subject: Re: Calling RPGIV from Java


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
+---

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

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.