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



Otto,

If the Java class returns a java array object, you can determine the number of
elements/objects of the array via JNI calls.  You will then have to have some
technique to extract and store the objects in your RPG program.  Again,
this can be done via JNI but is not as simple as using DIM().

While I have RPG code processing array "variables" within a java object, I don't
have any specific code I can share that works with Object arrays.  I would 
expect
the concept's between Object and variable arrays to be similar so here is where
I would start:

1. All Java's Array-types are defined as java.lang.Object (JLO) in the JNI, so 
the RPG
prototype call to your java method should "receive" a JLO type. (assumes your 
class
is returning a JLO)
2. Your RPG program should include the "/DEFINE JNI_COPY_ARRAY_FUNCTIONS".
compiler directive, otherwise the JNI array functions will not be "copied" into 
your
program.
3. Use the "GetArrayLength" JNI call to retrieve the arrays dimensions. 
4. Use the "GetObjectArrayElement" JNI call to extract each array element.
5. The "GetObjectArrayElement" returns a JLO type.  As java.lang.String (JLS) 
"extends"
JLO, you should be able to specify a JLS type to receive the respective 
element.  If
returned object is "*NULL" than there was no object at the specified index.
6. I would use the JNI's "GetStringLength" and GetStringChars" calls to convert 
the
JLS to character field.  (Note: GetStringChars" returns a pointer to character 
string
so use the %str BIF to retrieve the JLS into your RPG character field.)

Hope this helps....

Michael Rooney
Citigroup International

              

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On 
Behalf Of Steffan, Otto (GE Consumer Finance)
Sent: Thursday, April 08, 2004 1:27 PM
To: 'rpg400-l@xxxxxxxxxxxx'
Subject: RE: Java array in ILE RPG


Hello,

thanks all for the contributions, I appreciate your feedback. Let me resume
the discussion on this topic.

Can you give me some hints on how to get rid of DIM(x) specs in
object/method d-specs in order to have a common solution for processing
output array of getRSRows method that is not limited to x objects in array?
Barbara mentioned using JNI; I have succeeded in getting JNIEnv_P pointer,
starting JVM, calling a couple of JNI procedures earlier... so some pure
RPG-JNI solution (if exists) would be very very recognized.

regards
Otto Steffan

PS: modification of Java classes is possible but it is an ultimate solution;
I am not their owner...not programming in java.

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-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.