cancel
Showing results for 
Search instead for 
Did you mean: 

SAP.Functions and VBA connectivity fail

Former Member
0 Kudos

Hi All,

MS Office 2010 Professional
SAP GUI 7.40 Patch 2 Hotfix1

Standard VBA code for connectivity using SAP.Functions.

   Set oSAP = CreateObject("SAP.Functions")

    Set oCon = SAP.Connection

  

       oCon.ApplicationServer = "IP Address"

        oCon.SystemNumber = "Number"

        oCon.Client = "Client"

        oCon.Language = "EN"

        oCon.User = "Username"

        oCon.Password = "Password"

  

    If oCon.Logon(0, True) = False Then

        MsgBox "Error"

    Else      

       MsgBox "OK"

    End If

  

Several computers with the same GUI and Office are OK with this code, but one has an error.

First attempt to logon user receives "Error" (from MsgBox)

Second: user receives dialog

Runtime error '-2147417848 (80010108)'

Method 'Logon' of object '_CSAPLogonConnection' failed

By clicking "Debug" error is in the line If oCon.Logon(0, True) = False Then

Third: the same as the first etc.

Tried to reinstall SAP GUI and to install Patch 4 for GUI 7.40, in both cases the error is the same.

Any further ideas?

Thanks and regards,

Ekaterina

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

SAP Support has created note 2215972 for me, the error will be corrected in one of the next patches, until one can use one of three workarounds above.

I mark this topic as answered now.

Answers (4)

Answers (4)

Former Member
0 Kudos

The issue is somewhere in Landscape Format principle, a lot was detected, below is not the full list just for information. Some of them are already corrected, some are planned to be corrected in SP5.

2107181, 2035293 - collective notes

2201134, 2120549 - individual not listed

Current workaround with SP4 HF1 is to switch off the Landscape Format manually:

Regedit, #HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAPLogon#, set LandscapeFormatEnabled to 0

I keep this topic updated.

stefan_schnell
Active Contributor
0 Kudos

Hello Ekaterina,

thanks for sharing this information.

Cheers

Stefan

Former Member
0 Kudos

Had a small web session with SAP and they are investigating.

Meanwhile I have found one more workaround, add to code

oCon.System = "SysID"

and it starts working properly. But 7.30 never needed it...

stefan_schnell
Active Contributor
0 Kudos

Hello Ekaterina,

have you tried the TraceLevel attribute?

oCon.ApplicationServer = "IP Address"

oCon.SystemNumber = "Number"

oCon.Client = "Client"

oCon.Language = "EN"

oCon.User = "Username"

oCon.Password = "Password"

oCon.TraceLevel = 7

If you set this attribute you get a trace file e.g. like rfc07984_07980.trc in your Users\YourName\Documents directory. So you can compare the trace file from a computer where it works and where it not works. Maybe it gives you a hint for the reason of the different behavior.

Let us know your results.

Cheers

Stefan

Former Member
0 Kudos

Hi Stefan,

Tracing was a great idea (really should think about it myself first). And I received strange results.

A bit more explanation: in a real life we have a workbook uploaded to BPC server (all the landscape D-Q-P), with the code that have variables for IP Address, Number, Username and Password. User logs on to the EPM Add-In (BPC Add-in in Office, we do it in Excel), when macro starts, variables are filled in automatically from the IP address and Number fields in Workbook and Username-password dialog. Macro on the corrupted machine filled in all the variables correctly, but failed.

But even if I try with this code from a local machine and/or values instead of variables, it fails, so it is definitely not BPC/EPM issue.

In the traces I mentioned that on the corrupted machine macro always tries to connect not to the system defined in the code (with variables or values) but to another system that had the first Name in SAP GUI when sorting ascending.

I know it sounds crazy, but I changed the system names adding "1" to move it to the first position and received the different results. If SAP GUI has no entries, it seems that macro looks for the first entry in a old saplogon.ini file in Windows directory (here I am not 100% sure). Amazing!


These are logs (blue - replaced concrete values, red - my comments)

dev_rfc.trc and like rfc07984_07980.trc


**** ERROR file opened at 20150812 075608 Mitteleuropäische Sommerzeit, SAP-REL 740,0,89 RFC-VER 3  MT-SL

T:6976 Error in program 'EXCEL': ======> Client XXX is not available in this system

T:6976 Error in program 'EXCEL': <* RfcReceive [1] : returns 3:RFC_SYS_EXCEPTION


**** Trace file opened at 20150812 075607 Mitteleuropäische Sommerzeit, by EXCEL

**** Versions SAP-REL 740,0,89 RFC-VER nU 3  MT-SL

resize I/O buffer to 28000 bytes

>>>> [1] <unknown>    : EXT  <ac: 1> L IP ADDRESS >>> OPEN   (incorrect IP)

UUID: ab_drvstate create uuid {D2B640E5-45CF-F110-9CFC-2016D8A0CF8D}

        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_0

        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_0

>>>> [1] <unknown>    : EXT  <ac: 2> L IP ADDRESS >>> 78803978 (78803978) (incorrect IP)

  -{D2B640E5-45CF-F110-9CFC-2016D8A0CF8D}

>TS> Wed Aug 12 07:56:08 2015

        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_0

>>> RfcOpenEx ...

Got following connect_param string:

   USER=USER CLIENT=CLIENT LANG=EN PASSWD=******* SYSNR=NUMBER ASHOST=IP ADDRESS ICCE=1 TRACE=7 CODEPAGE=1100 GETSSO2=1 PCS=1 (incorrect values)

Send RFCHEADER: 01/LIT/IEEE/SPACE/1100

Send UNICODE-RFCHEADER: cp:1100/ce:IGNORE/et:5/cs:1/rc:0x00000023

L-CodePages: default=1100, logon_lang=1100, curr_locale=1100, front_locale=1100, default_pcs=1100

DT ERROR> ab_dtrfcSendInfo (rc: 1        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_1

>>> Logon check: calling RFCPING

>>> RfcCall [1] ...

*> RfcCall

FUNCTION RFCPING

<skipped - Trying to call incorrect system + information about local machine>

<* RfcCall [1] : returns 0:RFC_OK

>>> RfcListen [1] ...

>>>> [1] <unknown>    : EXT  <ac: 5> L IP ADDRESS>>> FLUSH(WRITE) (78803978) (incorrect IP)

  -{D2B640E5-45CF-F110-9CFC-2016D8A0CF8D}

        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_1

>>> RfcListen [1] ...

>>> RfcListen [1] ...

>>> RfcListen [1] ...

>>> RfcListen [1] ...

>>>> Listen/WaitForRequest (counter = 5)

>>>> [1] <unknown>    : EXT  <ac: 6> L IP ADDRESS >>> LISTEN (78803978) (incorrect IP)


<skipped - system info and error message>


<* RfcListen [1] : returns 0:RFC_OK

>>> RfcReceive [1] ...

Received RFCHEADER [1]: 01/LIT/IEEE/SPACE/1100

Received UNICODE-RFCHEADER [1]: cp:4103/ce:IGNORE/et:3/cs:2/rc:0x00000023

L-CodePages: default=1100, logon_lang=1100, curr_locale=1100, front_locale=1100, default_pcs=1100

Error in program 'EXCEL': ======> Client XXX is not available in this system

>>>> [1] <unknown>    : EXT  <ac: 7> L IP ADDRESS >>> FREE D:/depot/bas/740_REL/src/krn/rfc/abrfcio.c 3626 (78803978) (incorrect IP)

  -{D2B640E5-45CF-F110-9CFC-2016D8A0CF8D}

        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_1

>>>> [1] <unknown>    : EXT  <ac: 8> L IP ADDRESS >>> CLOSE D:/depot/bas/740_REL/src/krn/rfc/abrfcio.c 3315 (78803978) (incorrect IP)

  -{D2B640E5-45CF-F110-9CFC-2016D8A0CF8D}

        {root-id= }_{conn-id= }_0-

        {root-id=00000000000000000000000000000000}_{conn-id=D2B640E545CFF1109CFC2016D8A0CF8D}_1

==== Delta HO 0,  0 LOG DROPPED

**** Trace file opened at 20150812 075608 Mitteleuropäische Sommerzeit, by EXCEL

**** Versions SAP-REL 740,0,89 RFC-VER nU 3  MT-SL

*> RfcReceive

        handle = 1

        parameter   = <NULL>

        tables      = <NULL>

Error in program 'EXCEL': <* RfcReceive [1] : returns 3:RFC_SYS_EXCEPTION

<<< RfcOpenEx failed

And one more computer I considered OK is really not OK. But it has only one system entry in SAP GUI so nobody thought it was not working properly. Now I need to check some more computers.

I investigate it further and also appreciate more ideas. For now SAP GUI 7.40 Patch 4 as well as SAP GUI 7.40 Patch 2 without Hotfix1 have the same issue.

Regards

stefan_schnell
Active Contributor
0 Kudos

Hello Ekaterina,

it seems that the trace protocoll dosn't help us.

But your oberservation with the saplogon.ini file seems to be promising.

I check it on my test system. The saplogon.ini file is in access of SAP logon control in the following direction

"C:\Users\MyUser\Documents\AppData\Roaming\SAP\Common\saplogon.ini"

"C:\Dummy\SAPLOGON.INI" (Your actual directory)

"C:\WINDOWS\SAPLOGON.INI"

You use the attribute ApplicationServer and SystemNumber, these identifies your target system unique. I suggest - only for experimental reasons - that you rename all saplogon.ini files on a computer where your script doen't run and check if it works now. Don't forget to rename the files back. In my case a saplogon.ini is not necessary, it works without perfect. If it runs you know it is a saplogon.ini conflict.

Let us know your results.

Cheers

Stefan

Former Member
0 Kudos

Hi Stefan,

And what GUI build and version do you use?

Ekaterina

stefan_schnell
Active Contributor
0 Kudos

Hello Ekaterina,

Version 7.30 PL 12.

But I will try also Version 7.40 in the next days.

Cheers

Stefan

Former Member
0 Kudos

So, saplogon.ini files exist in the following directories.

C:\Users\MyUser\AppData\Roaming\SAP\Common\

C:\WINDOWS\

And SAPUILandscape.xml in

C:\Users\MyUser\AppData\Roaming\SAP\Common\

Loaded local file is SAPUILandscape.xml and really I do not need saplogon.ini, SAPUILandscape.xml is enough for all SAP GUI purposes now.

But until I renamed them all I had an error. Code looks for the entry with the first alphabetical name in the section "name" of SAPUILandscape.xml, if doesn't find, in [Description] of saplogon.ini (one of the paths above), and only if all three destinations have nothing - the variables or values.

I have now SAP GUI 7.40 SP4 + BEx P3 and it doesn't work, so I think it is now the time to create an OSS Message.

stefan_schnell
Active Contributor
0 Kudos

Hello Ekaterina,

you are right. The behavior of the SAP Logon Control or Classic RFC library between SAP GUI version 7.30 and 7.40 is different. I monitored the complete activities of the script, and I can't find any file access to SAPlogon.ini. All SAPlogon accesses are only in the registry.

Anyway, if you open the OSS note and you get a result, please let us know. It is very a interesting topic.

Thanks and cheers

Stefan

P.S. Here my test script:

'-Begin-------------------------------------------------


  Set oFunc = CreateObject("SAP.Functions")

  Set oCon = oFunc.Connection

  oCon.ApplicationServer = "localhost"

  oCon.SystemNumber = "00"

  oCon.Client = "001"

  oCon.Language = "EN"

  oCon.User = "BCUSER"

  oCon.Password = "minisap"

  If oCon.Logon(0, True) = False Then

    MsgBox "R/3 connection failed"

  Else

    MsgBox "R/3 connection successful"

    oCon.LogOff

  End If

  Set oCon = Nothing

  Set oFunc = Nothing

'-End---------------------------------------------------


Former Member
0 Kudos

...Created. Waiting for the answer.

script_man
Active Contributor
0 Kudos

Hi Ekaterina,

I was looking for a bit on the web and found this:

It could be that it will help you.

Regards,

ScriptMan

Former Member
0 Kudos

Hi,

Thanks, but it seems to be a bit too old... And I played with macro settings already. No result.

What haven't I tried yet is to reinstall the Office, from my point of view even if it can work it is not a proper solution but a workaround in a crucial case (it is not in our case), so I prefer to look for other options first.

Oh, and we don't use the code with BEx, BEx Add-In is even not loaded when executing the code, we need it for BPC (EPM Add-In) purposes.

However it doesn't work as a pure code anyway on one particular machine.

Regards