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



I can help a little.  Conversion classes in the IBM Toolbox for Java can
help convert between Java and iSeries formats.  For example, you use the
AS400PackedDecimal class to convert between a Java double and an iSeries
packed decimal number.  The following converts a Java double number into
iSeries packed decimal format and stuff them into a byte array.  It then
reverses the process.  It grabs the numbers out of the bytes byte array and
converts them back into Java numbers.

             byte[] data = new byte[1000];
             AS400PackedDecimal pd = new AS400PackedDecimal(6, 2);    //
Six digits including 2 decimal positions

             int offset = 0;
             double number = 1.0;
             while(offset < data.length)
             {
               offset = offset + pd.toBytes(number, data, offset);
               number++;
             }

             // byte array data now has numbers in iSeries packed decimal
format

             offset = 0;
             while(offset < data.length)
             {
               double d = pd.toDouble(data, offset);
               System.out.println(d);
               offset = offset + 4;                // in this testcase each
number takes four bytes in the buffer
             }

You can use the Toolbox ProgramCall class to call your RPG program.  In the
following example I call a program with one parameter, an input/output
parameter.

             AS400 system = new AS400();
             ProgramCall pc = new ProgramCall(system);
             pc.setProgram("/QSYS.LIB/MYLIB.LIB/MYPROGRAM.PGM");

             ProgramParameter[] parms = new ProgramParameter[1];
             parms[0] = new ProgramParameter(data, 1000);  // input/output
parm
             pc.setParameterList(parms);

             if (pc.run() == false)
             {
                 // the program did not run (program or lib not found, not
authorized, etc., a message will say why)
                 AS400Message[] msgs = pc.getMessageList();
                 for (int m = 0; m < msgs.length; m++)
                 {
                     System.out.println("    " + msgs[m].getID() + ": " +
msgs[m].getText());
                 }
             }
             else
             {
                 data = parms[0].getOutputData();
             }

You would combine the two concepts.  You would use converters to create a
buffer to hold your numbers and dates.  You pass this buffer to your RPG
program via program call.  Program Call returns the buffer updated by your
RPG program.  You use converters to parse the returned buffer.

Hope this helps,

David Wall
AS/400 Toolbox for Java




                      OKogan@capitalfac
                      tors.com                 To:       java400-l@midrange.com
                      Sent by:                 cc:
                      java400-l-admin@m        Subject:  Java to RPG question
                      idrange.com


                      02/14/2002 03:44
                      PM
                      Please respond to
                      java400-l





This is a multi-part message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
Hi, All.

Can somebody answer any of my questions and possibly provide an example of
how to:

1) Send and receive data structure(about 40 packed and *USA date fields) as
a parameter to the RPG and then parse it in the bean?

2) Make the bean constructor receive a parameter when it is put into a
session and populate all the attributes based on the parameter?

Any help will be greatly appreciated.

Oleg.





The information transmitted by the following E-Mail is intended only for
the addressee and may contain confidential and/or privileged material. Any
interception, review, retransmission, dissemination, or other use, or
taking any action upon this information by persons or entities other than
the intended recipient is prohibited by law and may subject them to
criminal or civil liability. If you received this communication in error,
please contact us immediately at 954-730-2900 ext. 3600 and delete the
communication from any computer or network system.

--

_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.







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.