Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

OLE & ABAP

Former Member
0 Likes
1,591

Hi,

I have a problem. I have a function which's signature is;

bool isPossible(); //in .NET environment

And the corresponding code of this signature in ABAP/4;

DATA: RESULT TYPE I VALUE 8.

DATA: APP TYPE OLE2_OBJECT.

...

CREATE OBJECT APP 'X.APPLICATION'.

CALL METHOD OF APP 'isPossible' = RESULT.

But, I see that RESULT is 8, not changed. How can I get the result of isPossible method. Normally, it returns boolean value. But in ABAP, what is the corresponding type of boolean?

Thanks.

1 ACCEPTED SOLUTION
Read only

former_member182670
Contributor
0 Likes
1,385

You should use type C, beacuse OLE methods with return type boolean return '0' or '1' in ABAP instead of 'X' and ' '.

You should note that ABAP buffers OLE statements to first non-OLE statement.

So when you write this code and check value of lv_b in debugger it will be empty:


REPORT ZOLE .

INCLUDE ole2incl .

 DATA: lr_o TYPE ole2_object,
       lv_b type c.


CREATE OBJECT lr_o 'BT.BTester'.

CALL METHOD OF lr_o 'retT' = lv_b .


CALL METHOD OF lr_o 'retF' = lv_b .

but when you write


REPORT ZOLE .

INCLUDE ole2incl .

 DATA: lr_o TYPE ole2_object,
       lv_b type c.


CREATE OBJECT lr_o 'BT.BTester'.

CALL METHOD OF lr_o 'retT' = lv_b .
check sy-subrc = 0.

CALL METHOD OF lr_o 'retF' = lv_b .
check sy-subrc = 0.

you should see that after call of 'retT' lv_b hasa value '1' and after call of 'retF' lv_b is '0'.

Thats beacuse 'check sy-subrc = 0.' is non-OLE statement and it causes ABAP to execute previous buffered OLE statements.

PS. BT.BTester was my test object with two methods:

retT - simply returns true

retF - returns false

Message was edited by: Tomasz Mackowski

Hi,

I have a problem. I have a function which's signature is;

bool isPossible(); //in .NET environment

And the corresponding code of this signature in ABAP/4;

DATA: RESULT TYPE I VALUE 8.

DATA: APP TYPE OLE2_OBJECT.

...

CREATE OBJECT APP 'X.APPLICATION'.

CALL METHOD OF APP 'isPossible' = RESULT.

But, I see that RESULT is 8, not changed. How can I get the result of isPossible method. Normally, it returns boolean value. But in ABAP, what is the corresponding type of boolean?

Thanks.

9 REPLIES 9
Read only

Former Member
0 Likes
1,385

The boolean equivalen in SAP is: <b>SAP_BOOL</b> (X=True, Space=False)

Read only

0 Likes
1,385

Hi Sam,

Is there any include to use SAP_POOL? I can not define like;

DATA RESULT TYPE SAP_BOOL.

Compiler gives error as: "SAP_BOOL IS UNKNOWN"

Thanks.

Read only

0 Likes
1,385

it should work.

try like this.

data: b1 type SAP_BOOL.

Read only

0 Likes
1,385

No you dont! Maybe it is your vesion.

Goto SE11 and see if you have the data type SAP_BOOL

Read only

Former Member
0 Likes
1,385

Hi, I have just checked SAP_BOOL from SE11. There is no type as SAP_BOOL. But there is another type BOOLEAN. I have used this type for my purpose;

DATA RESULT type BOOLEAN.

DATA: APP TYPE OLE2_OBJECT.

...

CREATE OBJECT APP 'X.APPLICATION'.

CALL METHOD OF APP 'isPossible' = RESULT.

isPossible method returns true. But, RESULT is ''. Also, I changed the condition that isPossible return false, but again RESULT is ''. I mean that I can not get the result of this method in OLE. What should I do?

Read only

Former Member
0 Likes
1,385

hi, try this way;

CALL METHOD OF APP 'isPossible' = RESULT <b>NO FLUSH</b>.

Hope it will be helpful

Read only

Former Member
0 Likes
1,385

Hi Huseyin,

1. Try with C(10)

ie. some character having some length

regards,

amit m.

Read only

former_member182670
Contributor
0 Likes
1,386

You should use type C, beacuse OLE methods with return type boolean return '0' or '1' in ABAP instead of 'X' and ' '.

You should note that ABAP buffers OLE statements to first non-OLE statement.

So when you write this code and check value of lv_b in debugger it will be empty:


REPORT ZOLE .

INCLUDE ole2incl .

 DATA: lr_o TYPE ole2_object,
       lv_b type c.


CREATE OBJECT lr_o 'BT.BTester'.

CALL METHOD OF lr_o 'retT' = lv_b .


CALL METHOD OF lr_o 'retF' = lv_b .

but when you write


REPORT ZOLE .

INCLUDE ole2incl .

 DATA: lr_o TYPE ole2_object,
       lv_b type c.


CREATE OBJECT lr_o 'BT.BTester'.

CALL METHOD OF lr_o 'retT' = lv_b .
check sy-subrc = 0.

CALL METHOD OF lr_o 'retF' = lv_b .
check sy-subrc = 0.

you should see that after call of 'retT' lv_b hasa value '1' and after call of 'retF' lv_b is '0'.

Thats beacuse 'check sy-subrc = 0.' is non-OLE statement and it causes ABAP to execute previous buffered OLE statements.

PS. BT.BTester was my test object with two methods:

retT - simply returns true

retF - returns false

Message was edited by: Tomasz Mackowski

Read only

0 Likes
1,385

Thanks Tomasz