IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

GetObjectArrayElement returns NULL


IBM Mainframe Forums -> Java & MQSeries
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Majid Hussain

New User


Joined: 18 Aug 2007
Posts: 20
Location: Bangalore

PostPosted: Wed Mar 30, 2016 2:59 am
Reply with quote

Hi all

I am calling a Java program from a COBOL program. In an attempt to return multiple strings, I am returning an Array of Objects to the calling method.

Code:
public class TestClass {

       public static void main(String[] args)
       {
            .
       }

       public TestClass1[] execMethod(byte[] inString) {
            .
            .
            TestClass1[] test = new TestClass1[];
            .
            .
            return TestClass1
       }
}


When called from the Cobol program, I am getting no exceptions and also seems to get the length of the array correctly.

Code:
 
INVOKE Test-Class-obj  'execMethod'                     
USING BY VALUE ws-jbyteArray-obj                   
RETURNING test-class1-obj-array


Call GetArrayLength
   using by value JNIEnvPtr
   test-class1-obj-array   
returning test-class1-len



But when I try to get any element from the Array, it returns NULLs. Could someone please let me know if they have come any such error?

Code:

    Perform varying I from 0 by 1 until I = test-class1-len   
                     
       Call GetObjectArrayElement                 
       using by value JNIEnvPtr test-class1-obj-array I           
       returning test-class1-array-element                       
                                               
       Perform JavaExceptionCheck   

       if test-class1-array-element = null
       then
          display "Null object returned"
       end-if
    End-Perform


test-class1-array-element is always NULL. No matter what reference I use in working-storage section.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 30, 2016 7:30 am
Reply with quote

Inter-language issues are usually difficult to figure out. Have you successfully gotten a single variable to transfer between Java and COBOL? If not, why not start with that and get the interface working there before complicating the interface with arrays? If you have, what is different between the single variable and the array code?
Back to top
View user's profile Send private message
Majid Hussain

New User


Joined: 18 Aug 2007
Posts: 20
Location: Bangalore

PostPosted: Wed Mar 30, 2016 10:24 pm
Reply with quote

Yes. I have already got a String or ByteArray back from java program.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Java & MQSeries

 


Similar Topics
Topic Forum Replies
No new posts how to eliminate null indicator value... DB2 7
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts the system or user abend SF0F R=NULL COBOL Programming 0
No new posts Uploading from desktop, a CSV file, s... DB2 2
Search our Forums:

Back to Top