Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8594

Unexpected Behavior of Create Object OLE

$
0
0

Hello community,

 

in our case we use Create Object of an OLE class. In a normal case this command was executed in a context of a UI application, the SAP GUI for Windows. To check the existence of a class we instantiate it and look for the result in a remote enabled FM.

 

FUNCTION ZEXISTSPROGID.
"-----------------------------------------------------------------------
"  Local Interface:
*"  IMPORTING
*"     VALUE(PROGID) TYPE  CHAR128
*"  EXPORTING
*"     VALUE(RESULT) TYPE  BYTE
*"----------------------------------------------------------------------

  "-Variables-----------------------------------------------------------
    Data obj Type OLE2_OBJECT.

  Create Object obj ProgID.
  If sy-subrc <> 0 Or obj-Handle = 0 Or obj-Type <> 'OLE2'.
    Result = 0.
  Else.
    Free Object obj.
    Result = 1.
  EndIf.

ENDFUNCTION.

 

Here the problem starts. If you use this FM with the USE_SAPGUI option from the SAP RFC library and a dialog user all works as expected. If you run this FM without USE_SAPGUICreate Object delivers always sy-subrc = 0, obj-Handle = -1 and obj-Type = OLE2, independently whether the ProgID exists or not. I expected in this cases as sy-subrc = 1 (error in communication with the SAP GUI), because no SAP GUI exist - but it isn't.

 

I catch this behavior with the GUI_IS_AVAILABLE function.

So far so good, now my question: Why delivers Create Object this obviously wrong results? Or are the results correct and I don't understand the logic behind this behavior?

 

Thanks for answers and tips.

 

Cheers

Stefan



Viewing all articles
Browse latest Browse all 8594

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>