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

I don't know how you can process a java array using RPG, I think you will
have to create a method in your java class to access the elements of the
java array.

Not quite the same, but when I wanted to pass an array of objects as an
object parameter to a java class, 
the way I did it was create a java method to load one java array into
another java array.

                                                                     
 * new java object                                                   
Dnew_string       PR              O   EXTPROC(                       
D                                       *JAVA:                       
D                                       'java.lang.String':          
D                                       *CONSTRUCTOR)                
D                                     CLASS(                         
D                                       *JAVA:                       
D                                       'java.lang.String')          
D bytes                      65535A   const varying                  
                                                                      
 * loadTo java method                                    
DloadTo           PR              O   EXTPROC(*JAVA:class:            
D                                     'loadTo')                       
D                                     static                          
D                                     CLASS(*JAVA:'java.lang.Object') 
D                                 O   CLASS(*JAVA:'java.lang.Object') 
D                                     dim(15)                         
D                                     const                           

                                                                  
 * java string array object                                       
Dattachments      S               O   CLASS(                      
D                                       *JAVA:'java.lang.String') 
D                                     DIM(30)                     

// For each attachment                                
For Z = 1 to NbrFiles;                                
  If AttachFile(Z) <> '*NONE';                        
                                                      
    attachments(Z) = new_string(%trim(AttachFile(z)));
  Endif;                                              
Endfor;                                               

args(8) = loadAtt(attachments); 



cheers
Colin.W
 
Extension   353
Direct dial   0870 429 6676
 


-----Original Message-----
From: Steffan, Otto (GE Consumer Finance) [mailto:Otto.Steffan@xxxxxx] 
Sent: 01 April 2004 18:25
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.


This e-mail has been sent by a company of Bertram Group Ltd, whose registered 
office is The Nest, Rosary Road Norwich NR1 1TF. 
This message, and any attachments, are intended solely for the addressee and 
may contain privileged or confidential information.  If you are not the 
intended recipient, any disclosure, copying, distribution or any action taken 
or omitted to be taken in reliance on it, is prohibited and may be unlawful.  
If you believe that you have received this email in error, please contact the 
sender immediately. Opinions, conclusions and statements of intent in this 
e-mail are those of the sender and will not bind a Bertram Group Ltd company 
unless confirmed in writing by a director independently of this message. 
Although we have taken steps to ensure that this email and any attachments are 
free from any virus, we advise that in keeping with good computing practice the 
recipient should ensure they are actually virus free.


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.