×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




otto,

Have you tried the JNI function "GetArrayLength" to determine the number of 
elements in the array?
To retrieve elements from an Object array-type you would use the 
"GetObjectArrayElement" JNI
function.

Info on these JNI functions is available at:

http://java.sun.com/j2se/1.3/docs/guide/jni/spec/functions.doc.html#17314

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 01, 2004 12:25 PM
To: 'rpg400-l@xxxxxxxxxxxx'
Subject: Java array in ILE RPG


Hello,

I have run out of ideas how to sort out this problem:
I call a Java method getRSRows in my RPG program that returns an array of
objects; what I need is 
Number of returned objects in the array.
Here are several code snippets from my program (I used IBM manual ILE RPG
Programmer's Guide - chapter RPG and Java
to write the program). I tried to pick up the fragments that I believe are
relevant to the problem:

d GetCustomerAccountsImpl...                               
d                 S               O
class(*JAVA:'classes.GetCustomerAccountsImpl')

d RSRows...                                                    
d                 S               O
class(*JAVA:'classes.GetCustomerAccountsRSRowImpl')
d                                     dim(10)


d getRSRows...                                                     
d                 PR              O   extproc(*JAVA:               
d                                       'classes.GetCustomerAccountsImpl':

d                                       'getRSRows')               
d
class(*JAVA:'classes.GetCustomerAccountsRSRow')
d                                     dim(10)                      
   ...

  RSRows = getRSRows(GetCustomerAccountsImpl); // this row works OK - Java
returns X objects - rows

  // but the pgm fails-JVM even ends abnormally on getOuacct method in
for-loop
  // if it runs i = X+1 (let's assume X is allways less than 10):
  For  i = 1 to 10;                   
    Acct = %dec(getOuacct(RSRows(i))); 
    if  Acct = 0.;                     
      leave;  // (i-1)=X is Number of objects in the array (??)

    endif;                             
  endfor;                             


And Java documentation contains:
CLASS: classes.GetCustomerAccountsImpl
method summary:
...
classes.GetCustomerAccountsRSRow[] getRSRows()
...
CLASS: classes.GetCustomerAccountsRSRowImpl 

INTERFACE: GetCustomerAccountsRSRow
All Known Implementing Classes: classes.GetCustomerAccountsRSRowImpl
method summary:
...
long getOuacct()
....
Thanks for help and sorry about my English.

Otto Steffan
_______________________________________________
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-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 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.