-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythonAbapInterface.py
47 lines (45 loc) · 1.93 KB
/
pythonAbapInterface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pyrfc
def createFunctionModule(conn, functionName, importParameters, exportParameters, programcode):
try:
result = conn.call('RS_FUNCTIONMODULE_INSERT',
FUNCNAME=functionName,
FUNCTION_POOL="ZRFCTEST",
SHORT_TEXT="",
REMOTE_CALL="X",
SOURCE=programcode,
IMPORT_PARAMETER=importParameters,
EXPORT_PARAMETER=exportParameters)
return "success"
except pyrfc._exception.ABAPApplicationError as e:
return "FunctionCreate: ApplicationError " + str(e)
pass
except pyrfc._exception.ABAPRuntimeError as e:
return "FunctionCreate: RuntimeError " + str(e.key)
pass
except pyrfc._exception.LogonError as e:
return "FunctionCreate: LogonError " + str(e.key)
pass
except pyrfc._exception.CommunicationError as e:
return "CommunicationError" + str(e.key)
pass
except Exception as e:
return str(e)
def callFunctionModule(conn, functionName, callParams) -> dict:
try:
result = conn.call(functionName, options={"timeout": 10}, **callParams)
return result
except pyrfc._exception.ABAPApplicationError as e:
result = "FunctionCall: ApplicationError " + str(e.key)
except pyrfc._exception.ABAPRuntimeError as e:
result = "FunctionCall: RuntimeError " + str(e)
except pyrfc._exception.LogonError as e:
result = "FunctionCall: LogonError " + str(e.key)
except pyrfc._exception.CommunicationError as e:
result = "FunctionCall: CommunicationError " + str(e.key)
except TypeError as e:
result = "FunctionCall: TypeError: " + str(callParams)
except Exception as e:
result = repr(e)
return {"exception": result}
def deleteFunctionModule(conn, functionName):
conn.call("Z_FUNCTION_DELETE", FUNCNAME=functionName)