Skip to Content
0

Problem when call method of COM Object

May 05, 2017 at 05:17 PM

67

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sandra Rossi May 05, 2017 at 05:48 PM
1

Problem with types of parameters?

Show 6 Share
10 |10000 characters needed characters left characters exceeded

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. "

0
Former Member

Thank you Sandra,

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

0
Former Member

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

0

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

0

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.

0
Former Member

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

1