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

Problem when call method of COM Object

Former Member
0 Likes
1,713

I am trying to call external program from ABAP. I have built and registered COM object.

When Creating Objects it open new process (I can see from Task Manager). But CALL METHOD it gives error SY-SUBRC = 2

PS. This App has Method by name PrintBarcode with 2 params.

What is the problem can be?

INCLUDE OLE2INCL.

DATA: H_LABELPRNCOM TYPE OLE2_OBJECT
      ,RET_CODE TYPE I
     .

    CREATE OBJECT H_LABELPRNCOM 'KGSLabelPrn.Application'.
    IF SY-SUBRC = 0.
       CALL METHOD OF H_LABELPRNCOM 'PrintBarcode'
                 = RET_CODE
                 EXPORTING #1 = SY-HOST
                           #2 = BARCODE.
    ENDIF.


    IF SY-SUBRC <> 0 OR RET_CODE <> 0.
       RAISE ERROR.
    ENDIF.
    FREE OBJECT H_LABELPRNCOM.
                             .
ENDFUNCTION.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
1,597

Problem with types of parameters?

7 REPLIES 7
Read only

Sandra_Rossi
Active Contributor
1,598

Problem with types of parameters?

Read only

0 Likes
1,597

ABAP documentation says:

"The return value of the external method meth can be stored in a data object rc. This data object expects, in accordance with the called method, a character-like data type of length 8 or a data type of type ole2_object from the type group OLE2 to be able to accept the addressed object. "

Read only

0 Likes
1,597

Thank you Sandra,

In my case: I've tried void method and string return method also. But nothing changes same error.

Read only

0 Likes
1,597

What about input params, i have only 4 input params in my .NET application

Read only

0 Likes
1,597

I was also talking about types of arguments. And about RET_CODE too.

Read only

0 Likes
1,597

You should also try rewriting your COM object, with a method without parameter, just to make sure whether you can call it from ABAP, to know whether it's related to parameters.

Read only

1,597

Thank you Sandra

I found the problem. This method must return string value "0"

That it was a problem in my case.

Thanks in advance