Skip to content

Instantly share code, notes, and snippets.

@su79eu7k
Created April 2, 2021 06:34
Show Gist options
  • Save su79eu7k/0dc503ef82ac166c9e92ad8055738194 to your computer and use it in GitHub Desktop.
Save su79eu7k/0dc503ef82ac166c9e92ad8055738194 to your computer and use it in GitHub Desktop.
SAP login with pyrfc
from pyrfc import Connection, ABAPApplicationError, ABAPRuntimeError, LogonError, CommunicationError
class RFC_Handle(object):
def __init__(self):
self.conn = None
def login(self, sap_id, sap_pwd):
try:
self.sap_id = sap_id
self.conn = Connection(user=self.sap_id, passwd=sap_pwd, ashost='xxx.xxx.xxx.xxx', sysnr='xx', client='xxx')
return self
except CommunicationError:
print("Could not connect to server.")
raise
except LogonError:
print("Could not log in. Please Check your ID/PW.")
raise
except Exception as err:
print(str(err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment