1

I have a question about SAP silent logon which I implemented using win32com this way

from win32com.client import Dispatch

R3 = Dispatch("SAP.Functions")
R3.Conn.System = 'xxx'
R3.Conn.Client = '100'
# other values needed to pass to R3.Conn
R3.Conn.logon #here is the problem

In VB i can use R3.Conn.Logon(1, True) to make logon siliencely. But in Python Logon seems not to be a method and do not allow me to pass parameters to it.

I tried using R3.Conn.Logon(1, True) in Python, but it returned an error

Logon was not callable.

How should I call silent logon in Python?

Thanks

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • Just guessing, but AFAIR Python is case sensitive - maybe you need to call `R3.Conn.Logon` instead of `R3.Conn.logon`? – vwegert Feb 15 '17 at 16:59
  • Either works for logon, but i cannot pass any parameters to it. Neither of them is callable. – Cheney Wang Feb 16 '17 at 02:57
  • According to http://help-legacy.sap.com/saphelp_46c/helpdata/en/39/7e0194ac6011d189c60000e829fbbd/content.htm?frameset=/en/39/7dffa6ac6011d189c60000e829fbbd/frameset.htm&current_toc=/en/39/7e11e0ac6011d189c60000e829fbbd/plain.htm&node_id=425, you should call `Logon`. Unfortunately I am not able to test since I can't instantiate the COM object. – CristiFati Mar 25 '17 at 17:08

1 Answers1

1

This works for me. Still experimenting, I want to add field selection and of course a filter to the RFC_READ_TABLE. But the connection works.

from win32com.client import Dispatch

Functions = Dispatch("SAP.Functions")

Functions.Connection.Client = "000"
Functions.Connection.ApplicationServer = "your server"
Functions.Connection.Language = "EN"
Functions.Connection.User = "you"
Functions.Connection.Password = "your pass"
Functions.Connection.SystemNumber = "00"
Functions.Connection.UseSAPLogonIni = False

if (Functions.Connection.Logon (0,True) == True):
    print("Logon OK")
    RfcCallTransaction = Functions.Add("RFC_READ_TABLE")
    strExport1 = RfcCallTransaction.exports("QUERY_TABLE")
    strExport2 = RfcCallTransaction.exports("DELIMITER")
    strExport3 = RfcCallTransaction.exports("ROWSKIPS")
    strExport4 = RfcCallTransaction.exports("ROWCOUNT")
    tblOptions = RfcCallTransaction.Tables("OPTIONS")
    #RETURNED DATA
    tblData = RfcCallTransaction.Tables("DATA")
    tblFields = RfcCallTransaction.Tables("FIELDS")


    strExport1.Value = 'AGR_DEFINE'
    strExport2.Value = ";"
    strExport3.Value = 0
    strExport4.Value = 10

    if RfcCallTransaction.Call == True:
        print ("Function call successful")
        #print (tblData.RowCount)
        j = 1
        while j < tblData.RowCount:
            print (tblData(j,"WA"))
            j = j + 1
Lorenzo
  • 167
  • 1
  • 4