Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

How to pass PB arrays AS REFERENCE to Java using EJB client?

5 posts in EJB Client Last posting was on 2004-02-03 12:57:58.0Z
Samanta Posted on 2004-02-02 11:34:19.0Z
Sender: 21c5.401e341b.1804289383@sybase.com
From: Samanta
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: How to pass PB arrays AS REFERENCE to Java using EJB client?
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <401e3828.21d8.846930886@sybase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 2 Feb 2004 03:44:40 -0800, 10.22.241.42
Lines: 27
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 2 Feb 2004 03:17:16 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 2 Feb 2004 03:34:19 -0800
X-Trace: forums-1-dub 1075721659 10.22.108.75 (2 Feb 2004 03:34:19 -0800)
X-Original-Trace: 2 Feb 2004 03:34:19 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:232
Article PK: 424415

Hi,

I´m trying to pass a PB array (e.g. long) to a Java method
using EJB client. This method call is executed as call by
value instead of call by reference (that I supposed because
Java does it in that way). Can anybody tell me, how to pass
the PB array as reference? I did not found an answer in the
manuals or in the internet.
I´m using the data type mapping as described in
Application Techniques manual with PB 9.0.1 6533 and JDK
1.4.

Bye. Samanta

*** PB code

long ll_value[1]
ll_value[1] = 3 //set value to 3
iejb_dtm.pblongarray(ll_value) //EJB client method call
st_3.text = string(ll_value[1]) //value is still 3

*** Java code

public void PBLongArray(int[] JavaInt)
{
JavaInt[0] += 1; //increment value by 1
}


Jim O'Neil [Sybase] Posted on 2004-02-02 14:04:50.0Z
From: joneil@sybase.com (Jim O'Neil [Sybase])
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: How to pass PB arrays AS REFERENCE to Java using EJB client?
Organization: Sybase Technical Support
Reply-To: joneil_REMOVETHISPART@sybase.com
Message-ID: <401e544e.595055@forums.sybase.com>
References: <401e3828.21d8.846930886@sybase.com>
X-Newsreader: Forte Free Agent 1.21/32.243
NNTP-Posting-Host: joneilpc.sybase.com
X-Original-NNTP-Posting-Host: joneilpc.sybase.com
Date: 2 Feb 2004 06:04:50 -0800
X-Trace: forums-1-dub 1075730690 10.18.61.244 (2 Feb 2004 06:04:50 -0800)
X-Original-Trace: 2 Feb 2004 06:04:50 -0800, joneilpc.sybase.com
Lines: 43
X-Authenticated-User: TeamPS
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:233
Article PK: 424416

In general, if you want to pass something by reference in Java, you
need to provide a holder class (also referred to as a boxed value)-
essentially a class that has a field (or fields) containing the values
you want passed by reference. Use that class as the argument to your
method versus the array itself. Once you do this in the Java
signature, the PowerBuilder side will take care of itself. In this
particular situation though, it would just be easier to return the
array from the method, wouldn't it?

On 2 Feb 2004 03:34:19 -0800, Samanta wrote:

>Hi,
>
>I=b4m trying to pass a PB array (e.g. long) to a Java method
>using EJB client. This method call is executed as call by
>value instead of call by reference (that I supposed because
>Java does it in that way). Can anybody tell me, how to pass
>the PB array as reference? I did not found an answer in the
>manuals or in the internet.
>I=b4m using the data type mapping as described in
>Application Techniques manual with PB 9.0.1 6533 and JDK
>1.4.
>
>Bye. Samanta
>
>*** PB code
>
>long ll_value[1]
>ll_value[1] =3d 3 //set value to 3
>iejb_dtm.pblongarray(ll_value) //EJB client method call
>st_3.text =3d string(ll_value[1]) //value is still 3
>
>*** Java code
>
>public void PBLongArray(int[] JavaInt)
>{
> JavaInt[0] +=3d 1; //increment value by 1
>}

Jim O'Neil
Principal Technical Support Engineer
Sybase, Inc.
Concord, MA


Samanta Posted on 2004-02-02 17:34:55.0Z
Sender: 28cb.401e8c8d.1804289383@sybase.com
From: Samanta
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: How to pass PB arrays AS REFERENCE to Java using EJB client?
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <401e8caf.28d0.846930886@sybase.com>
References: <401e3828.21d8.846930886@sybase.com><401e544e.595055@forums.sybase.com>
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 2 Feb 2004 09:45:19 -0800, 10.22.241.42
Lines: 56
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 2 Feb 2004 09:17:52 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 2 Feb 2004 09:34:55 -0800
X-Trace: forums-1-dub 1075743295 10.22.108.75 (2 Feb 2004 09:34:55 -0800)
X-Original-Trace: 2 Feb 2004 09:34:55 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:234
Article PK: 424417

Hi Jim,

thank you for your answer. Of course, it would be esier to
use a single array as return value. But I need a separte
return value as status message.
Have you a source code example for me please? I understand
your description. But how can I write a Java class, which
member variables are known in PB? Or vice versa. Is this
fact described anywhere in the manuals?

Bye. Samanta.

> In general, if you want to pass something by reference in
> Java, you need to provide a holder class (also referred to
> as a boxed value)- essentially a class that has a field
> (or fields) containing the values you want passed by
> reference. Use that class as the argument to your method
> versus the array itself. Once you do this in the Java
> signature, the PowerBuilder side will take care of itself.
> In this particular situation though, it would just be
> easier to return the array from the method, wouldn't it?
>
> On 2 Feb 2004 03:34:19 -0800, Samanta wrote:
>
> >Hi,
> >
> >I=b4m trying to pass a PB array (e.g. long) to a Java
> method >using EJB client. This method call is executed as
> call by >value instead of call by reference (that I
> supposed because >Java does it in that way). Can anybody
> tell me, how to pass >the PB array as reference? I did not
> found an answer in the >manuals or in the internet.
> >I=b4m using the data type mapping as described in
> >Application Techniques manual with PB 9.0.1 6533 and JDK
> >1.4.
> >
> >Bye. Samanta
> >
> >*** PB code
> >
> >long ll_value[1]
> >ll_value[1] =3d 3 //set value to 3
> >iejb_dtm.pblongarray(ll_value) //EJB client method call
> >st_3.text =3d string(ll_value[1]) //value is still 3
> >
> >*** Java code
> >
> >public void PBLongArray(int[] JavaInt)
> >{
> > JavaInt[0] +=3d 1; //increment value by 1
> >}
>
> Jim O'Neil
> Principal Technical Support Engineer
> Sybase, Inc.
> Concord, MA


Jim O'Neil [Sybase] Posted on 2004-02-02 20:11:44.0Z
From: joneil@sybase.com (Jim O'Neil [Sybase])
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: How to pass PB arrays AS REFERENCE to Java using EJB client?
Organization: Sybase Technical Support
Reply-To: joneil_REMOVETHISPART@sybase.com
Message-ID: <401ea8f0.22261029@forums.sybase.com>
References: <401e3828.21d8.846930886@sybase.com><401e544e.595055@forums.sybase.com> <401e8caf.28d0.846930886@sybase.com>
X-Newsreader: Forte Free Agent 1.21/32.243
X-Original-NNTP-Posting-Host: joneilpc.sybase.com
X-Original-Trace: 2 Feb 2004 12:22:08 -0800, joneilpc.sybase.com
Lines: 93
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 2 Feb 2004 11:54:38 -0800, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 2 Feb 2004 12:11:44 -0800
X-Trace: forums-1-dub 1075752704 10.22.108.75 (2 Feb 2004 12:11:44 -0800)
X-Original-Trace: 2 Feb 2004 12:11:44 -0800, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:235
Article PK: 424419

Well, it's not addressed in the manuals, because it's more of a design
pattern for Java than it relates to PowerBuilder. Something like this
is all you need (my syntax will likely NOT compile here <g>)

public final class myArray {

int[] val;
}

public void PBLongArray(myArray JavaInt)
{
JavaInt.val[0] += 1; //increment value by 1
}

when PowerBuilder generates the proxies for PBLongArray method, it
will see another Java class reference (myArray) and create proxies for
that as well. Your PB code will look something like:

long ll_value[1]
myArray l_javaArray;

ejbConn.CreateJavaInstance(l_javaArray, "myArray")
l_javaArray.val[1] = 3
iejb_dtm.pblongarray(l_javaArray) //EJB client method call
st_3.text = string(l_javaArray[1]) //value is still 3


This should get you pretty close, but I didn't code this out so again
there may be some slight syntax issues here.

On 2 Feb 2004 09:34:55 -0800, Samanta wrote:

>Hi Jim,
>
>thank you for your answer. Of course, it would be esier to
>use a single array as return value. But I need a separte
>return value as status message.
>Have you a source code example for me please? I understand
>your description. But how can I write a Java class, which
>member variables are known in PB? Or vice versa. Is this
>fact described anywhere in the manuals?
>
>Bye. Samanta.
>
>> In general, if you want to pass something by reference in
>> Java, you need to provide a holder class (also referred to
>> as a boxed value)- essentially a class that has a field
>> (or fields) containing the values you want passed by
>> reference. Use that class as the argument to your method
>> versus the array itself. Once you do this in the Java
>> signature, the PowerBuilder side will take care of itself.
>> In this particular situation though, it would just be
>> easier to return the array from the method, wouldn't it?
>>
>> On 2 Feb 2004 03:34:19 -0800, Samanta wrote:
>>
>> >Hi,
>> >
>> >I=b4m trying to pass a PB array (e.g. long) to a Java
>> method >using EJB client. This method call is executed as
>> call by >value instead of call by reference (that I
>> supposed because >Java does it in that way). Can anybody
>> tell me, how to pass >the PB array as reference? I did not
>> found an answer in the >manuals or in the internet.
>> >I=b4m using the data type mapping as described in
>> >Application Techniques manual with PB 9.0.1 6533 and JDK
>> >1.4.
>> >
>> >Bye. Samanta
>> >
>> >*** PB code
>> >
>> >long ll_value[1]
>> >ll_value[1] =3d 3 //set value to 3
>> >iejb_dtm.pblongarray(ll_value) //EJB client method call
>> >st_3.text =3d string(ll_value[1]) //value is still 3
>> >
>> >*** Java code
>> >
>> >public void PBLongArray(int[] JavaInt)
>> >{
>> > JavaInt[0] +=3d 1; //increment value by 1
>> >}
>>
>> Jim O'Neil
>> Principal Technical Support Engineer
>> Sybase, Inc.
>> Concord, MA

Jim O'Neil
Principal Technical Support Engineer
Sybase, Inc.
Concord, MA


Samanta Posted on 2004-02-03 12:57:58.0Z
Sender: 35f5.401f9a19.1804289383@sybase.com
From: Samanta
Newsgroups: sybase.public.powerbuilder.ejbclient
Subject: Re: How to pass PB arrays AS REFERENCE to Java using EJB client?
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <401f9ad6.35fd.846930886@sybase.com>
References: <401e3828.21d8.846930886@sybase.com><401e544e.595055@forums.sybase.com> <401e8caf.28d0.846930886@sybase.com><401ea8f0.22261029@forums.sybase.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 3 Feb 2004 04:57:58 -0800
X-Trace: forums-1-dub 1075813078 10.22.241.41 (3 Feb 2004 04:57:58 -0800)
X-Original-Trace: 3 Feb 2004 04:57:58 -0800, 10.22.241.41
Lines: 114
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.ejbclient:241
Article PK: 424423

Hi Jim,

I´m back again. I realized it via holder class/boxed value
with separate get/set functions. That´s why, if I use a
direct write access like "l_javaArray.val = ll_value", PB
often crashes. If I use the get/set functions it works very
well. Also a mix of a set function (to ensure that the java
member variable of first index exists) and direct write
access (with PB long array or any array) results in a crach
of PB (in most cases). But a mix of set function and direct
read access works. ???
I think, this is a very important fact for the manuals,
because Java uses call by reference for arrays (also for
primitive types). PB does not.

Bye. Thanks for all.

> Well, it's not addressed in the manuals, because it's more
> of a design pattern for Java than it relates to
> PowerBuilder. Something like this is all you need (my
> syntax will likely NOT compile here <g>)
>
> public final class myArray {
>
> int[] val;
> }
>
> public void PBLongArray(myArray JavaInt)
> {
> JavaInt.val[0] += 1; //increment value by 1
> }
>
> when PowerBuilder generates the proxies for PBLongArray
> method, it will see another Java class reference (myArray)
> and create proxies for that as well. Your PB code will
> look something like:
>
> long ll_value[1]
> myArray l_javaArray;
>
> ejbConn.CreateJavaInstance(l_javaArray, "myArray")
> l_javaArray.val[1] = 3
> iejb_dtm.pblongarray(l_javaArray) //EJB client method call
> st_3.text = string(l_javaArray[1]) //value is still 3
>
>
> This should get you pretty close, but I didn't code this
> out so again there may be some slight syntax issues here.
>
> On 2 Feb 2004 09:34:55 -0800, Samanta wrote:
>
> >Hi Jim,
> >
> >thank you for your answer. Of course, it would be esier
> to >use a single array as return value. But I need a
> separte >return value as status message.
> >Have you a source code example for me please? I
> understand >your description. But how can I write a Java
> class, which >member variables are known in PB? Or vice
> versa. Is this >fact described anywhere in the manuals?
> >
> >Bye. Samanta.
> >
> >> In general, if you want to pass something by reference
> in >> Java, you need to provide a holder class (also
> referred to >> as a boxed value)- essentially a class that
> has a field >> (or fields) containing the values you want
> passed by >> reference. Use that class as the argument to
> your method >> versus the array itself. Once you do this
> in the Java >> signature, the PowerBuilder side will take
> care of itself. >> In this particular situation though,
> it would just be >> easier to return the array from the
> method, wouldn't it? >>
> >> On 2 Feb 2004 03:34:19 -0800, Samanta wrote:
> >>
> >> >Hi,
> >> >
> >> >I=b4m trying to pass a PB array (e.g. long) to a
Java
> >> method >using EJB client. This method call is executed
> as >> call by >value instead of call by reference (that I
> >> supposed because >Java does it in that way). Can
> anybody >> tell me, how to pass >the PB array as
> reference? I did not >> found an answer in the >manuals or
> in the internet. >> >I=b4m using the data type mapping
as
> described in >> >Application Techniques manual with PB
> 9.0.1 6533 and JDK >> >1.4.
> >> >
> >> >Bye. Samanta
> >> >
> >> >*** PB code
> >> >
> >> >long ll_value[1]
> >> >ll_value[1] =3d 3 //set value to 3
> >> >iejb_dtm.pblongarray(ll_value) //EJB client method
> call >> >st_3.text =3d string(ll_value[1]) //value is
> still 3 >> >
> >> >*** Java code
> >> >
> >> >public void PBLongArray(int[] JavaInt)
> >> >{
> >> > JavaInt[0] +=3d 1; //increment value by 1
> >> >}
> >>
> >> Jim O'Neil
> >> Principal Technical Support Engineer
> >> Sybase, Inc.
> >> Concord, MA
>
> Jim O'Neil
> Principal Technical Support Engineer
> Sybase, Inc.
> Concord, MA