def main(function_name): config = ConfigParser() config.read('sapnwrfc.cfg') params_connection = config._sections['connection'] try: connection = Connection(**params_connection) func_desc = connection.get_function_description(function_name) print (u"Parameters of function: {0}".format(function_name)) parameter_keys = [u'name', u'parameter_type', u'direction', u'nuc_length', u'uc_length', u'decimals', u'default_value', u'optional', u'type_description', u'parameter_text'] parameter_widths = [20, 17, 11, 10, 9, 9, 15, 10, 15, 20] for key, width in zip(parameter_keys, parameter_widths): sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ") sys.stdout.write(u"\n") for parameter in sorted(func_desc.parameters, key=parameter_key_function): for key, width in zip(parameter_keys, parameter_widths): if key == u'type_description' and parameter[key] is not None: sys.stdout.write( u"{0}".format(parameter[key].name).ljust(width) + u" " ) else: sys.stdout.write( u"{0}".format(parameter[key]).ljust(width) + u" " ) sys.stdout.write(u"\n") type_desc = parameter['type_description'] if type_desc is not None: # type_desc of class TypeDescription field_keys = [u'name', u'field_type', u'nuc_length', u'nuc_offset', u'uc_length', u'uc_offset', u'decimals', u'type_description'] field_widths = [20, 17, 10, 10, 9, 9, 10, 15] sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n".format(type_desc)) for key, width in zip(field_keys, field_widths): sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ") sys.stdout.write(u"\n") for field_description in type_desc.fields: for key, width in zip(field_keys, field_widths): sys.stdout.write(u"{0}".format(field_description[key]).ljust(width) + u" ") sys.stdout.write(u"\n") sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} )-----------\n".format(type_desc)) sys.stdout.write(u"-" * sum(parameter_widths) + u"\n") connection.close() except CommunicationError: print u"Could not connect to server." raise except LogonError: print u"Could not log in. Wrong credentials?" raise except (ABAPApplicationError, ABAPRuntimeError): print u"An error occurred." raise
class TestTT: """ This test cases cover table types of variable and structure types """ def setup_method(self, test_method): self.conn = Connection(**params) assert self.conn.alive def teardown_method(self, test_method): self.conn.close() assert not self.conn.alive def test_TABLE_TYPE(self): result = self.conn.call( "/COE/RBP_PAM_SERVICE_ORD_CHANG", IV_ORDERID="4711", IT_NOTICE_NOTIFICATION=[{ "": "ABCD" }, { "": "XYZ" }], ) assert len(result["ET_RETURN"]) > 0 erl = result["ET_RETURN"][0] assert erl["TYPE"] == "E" assert erl["ID"] == "IWO_BAPI" assert erl["NUMBER"] == "121" assert erl["MESSAGE_V1"] == "4711"
def test_utclong_rejects_non_string_or_invalid_format(): UTCLONG = RFC_MATH["UTCLONG"] conn = Connection(**connection_info("QM7")) try: res = conn.call("ZDATATYPES", IV_UTCLONG=1) except Exception as ex: assert isinstance(ex, TypeError) is True assert ex.args == ( "an string is required, received", 1, "of type", type(1), "IV_UTCLONG", ) try: res = conn.call("ZDATATYPES", IV_UTCLONG="1") except Exception as ex: assert isinstance(ex, ExternalRuntimeError) is True assert ex.code == 22 assert ex.key == "RFC_CONVERSION_FAILURE" assert ex.message == "Cannot convert 1 to RFCTYPE_UTCLONG : illegal format" conn.close() # # TypeError: # res = conn.call("ZDATATYPES", IV_UTCLONG="1") # pyrfc._exception.ExternalRuntimeError: RFC_CONVERSION_FAILURE (rc=22): key=RFC_CONVERSION_FAILURE, message=Cannot convert 1 to RFCTYPE_UTCLONG : illegal format [MSG: class=, type=, number=, v1-4:=;; conn.close()
def main(function_name): config = ConfigParser() config.read('sapnwrfc.cfg') params_connection = config._sections['connection'] try: connection = Connection(**params_connection) func_desc = connection.get_function_description(function_name) print u"Parameters of function: {0}".format(function_name) parameter_keys = [u'name', u'parameter_type', u'direction', u'nuc_length', u'uc_length', u'decimals', u'default_value', u'optional', u'type_description', u'parameter_text'] parameter_widths = [20, 17, 11, 10, 9, 9, 15, 10, 15, 20] for key, width in zip(parameter_keys, parameter_widths): sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ") sys.stdout.write(u"\n") for parameter in sorted(func_desc.parameters, key=parameter_key_function): for key, width in zip(parameter_keys, parameter_widths): if key == u'type_description' and parameter[key] is not None: sys.stdout.write( u"{0}".format(parameter[key].name).ljust(width) + u" " ) else: sys.stdout.write( u"{0}".format(parameter[key]).ljust(width) + u" " ) sys.stdout.write(u"\n") type_desc = parameter['type_description'] if type_desc is not None: # type_desc of class TypeDescription field_keys = [u'name', u'field_type', u'nuc_length', u'nuc_offset', u'uc_length', u'uc_offset', u'decimals', u'type_description'] field_widths = [20, 17, 10, 10, 9, 9, 10, 15] sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n".format(type_desc)) for key, width in zip(field_keys, field_widths): sys.stdout.write(u"{0}".format(key).ljust(width).upper() + u" ") sys.stdout.write(u"\n") for field_description in type_desc.fields: for key, width in zip(field_keys, field_widths): sys.stdout.write(u"{0}".format(field_description[key]).ljust(width) + u" ") sys.stdout.write(u"\n") sys.stdout.write(u" " * 4 + u"-----------( Structure of {0.name} )-----------\n".format(type_desc)) sys.stdout.write(u"-" * sum(parameter_widths) + u"\n") connection.close() except CommunicationError: print u"Could not connect to server." raise except LogonError: print u"Could not log in. Wrong credentials?" raise except (ABAPApplicationError, ABAPRuntimeError): print u"An error occurred." raise
def test_create_with_multiple_connection(self): c1 = Connection(**params) c2 = Connection(**params) throughput = Throughput([c1, c2]) assert len(throughput.connections) == 2 throughput = Throughput([c1, c1]) assert len(throughput.connections) == 1 c1.close() c2.close()
def test_remove_from_connection(self): c1 = Connection(**params) c2 = Connection(**params) throughput = Throughput([c1, c2]) assert len(throughput.connections) == 2 throughput.removeFromConnection(c2) assert len(throughput.connections) == 1 assert next(iter(throughput.connections)) == c1 c1.close() c2.close()
def test_get_from_connection(self): c1 = Connection(**params) c2 = Connection(**params) x = Throughput(c1) y = Throughput(c2) z = Throughput.getFromConnection(c1) assert z == x z = Throughput.getFromConnection(c2) assert z == y c1.close() c2.close()
class TestOptions: def setup_method(self, test_method): self.conn = Connection(**params) assert self.conn.alive def teardown_method(self, test_method): self.conn.close() assert not self.conn.alive def test_pass_when_not_requested(self): PLNTY = "A" PLNNR = "00100000" NOT_REQUESTED = [ "ET_COMPONENTS", "ET_HDR_HIERARCHY", "ET_MPACKAGES", "ET_OPERATIONS", "ET_OPR_HIERARCHY", "ET_PRTS", "ET_RELATIONS", ] result = self.conn.call( "EAM_TASKLIST_GET_DETAIL", {"not_requested": NOT_REQUESTED}, IV_PLNTY=PLNTY, IV_PLNNR=PLNNR, ) assert len(result["ET_RETURN"]) == 0 def test_error_when_all_requested(self): PLNTY = "A" PLNNR = "00100000" result = self.conn.call("EAM_TASKLIST_GET_DETAIL", IV_PLNTY=PLNTY, IV_PLNNR=PLNNR) assert len(result["ET_RETURN"]) == 1 assert result["ET_RETURN"][0] == { "TYPE": "E", "ID": "DIWP1", "NUMBER": "212", "MESSAGE": "Task list A 00100000 is not hierarchical", "LOG_NO": "", "LOG_MSG_NO": "000000", "MESSAGE_V1": "A", "MESSAGE_V2": "00100000", "MESSAGE_V3": "", "MESSAGE_V4": "", "PARAMETER": "HIERARCHY", "ROW": 0, "FIELD": "", "SYSTEM": "MMECLNT620", }
def test_utclong_accepts_min_max_initial(): UTCLONG = RFC_MATH["UTCLONG"] conn = Connection(**connection_info("QM7")) res = conn.call("ZDATATYPES", IV_UTCLONG=UTCLONG["MIN"]) assert res["EV_UTCLONG"] == UTCLONG["MIN"] res = conn.call("ZDATATYPES", IV_UTCLONG=UTCLONG["MAX"]) assert res["EV_UTCLONG"] == UTCLONG["MAX"] res = conn.call("ZDATATYPES", IV_UTCLONG=UTCLONG["INITIAL"]) assert res["EV_UTCLONG"] == UTCLONG["INITIAL"] conn.close()
class TestMRFC: """ This test cases cover selected functions from the MRFC function group. """ def setup_method(self, test_method): self.conn = Connection(**params) assert self.conn.alive def test_info(self): connection_info = self.conn.get_connection_attributes() assert connection_info["isoLanguage"] == u"EN" def teardown_method(self, test_method): self.conn.close() assert not self.conn.alive """ @unittest.skip("not remote-enabled") def test_ABAP4_CALL_TRANSACTION_VB(self): # ABAP4_CALL_TRANSACTION_VB pass @unittest.skip("not remote-enabled") def test_IS_VERIRUN_ACTIVE(self): # IS_VERIRUN_ACTIVE Determine Whether a Verification Run is Active pass @unittest.skip("not supported yet (trfc)") def test_RFC_CALL_TRANSACTION_USING(self): # RFC_CALL_TRANSACTION_USING Verification Program for Execution of RFCs via CALL TRANSACTION USING pass # ToDo: Class based exceptions def test_RFC_CLASS_BASED_EXCP(self): # RFC_CLASS_BASED_EXCP RFC mit klassenbasierten Exceptions pass # TODO: How to test? @unittest.skip("not supported yet") def test_RFC_PING_AND_WAIT(self): # RFC_PING_AND_WAIT Aufruf und Warten pass """ """
def test_create_with_invalid_connection(self): conn = Connection(**params) try: throughput = Throughput(1) except Exception as ex: assert isinstance(ex, TypeError) is True assert ex.args == ( "Connection object required, received", 1, "of type", type(1), ) try: throughput = Throughput([conn, 1]) except Exception as ex: assert isinstance(ex, TypeError) is True assert ex.args == ( "Connection object required, received", 1, "of type", type(1), ) conn.close()
def test_throutput_single_connection(self): conn = Connection(**params) assert conn.alive throughput = Throughput() throughput.setOnConnection(conn) assert throughput.stats == { "numberOfCalls": 0, "sentBytes": 0, "receivedBytes": 0, "applicationTime": 0, "totalTime": 0, "serializationTime": 0, "deserializationTime": 0, } conn.call("STFC_CONNECTION", REQUTEXT="hello") assert equal_no_time( throughput.stats, { "numberOfCalls": 2, "sentBytes": 1089, "receivedBytes": 2812, "applicationTime": 0, "totalTime": 387, "serializationTime": 0, "deserializationTime": 0, }, ) conn.call("STFC_CONNECTION", REQUTEXT="hello") assert equal_no_time( throughput.stats, { "numberOfCalls": 3, "sentBytes": 1737, "receivedBytes": 4022, "applicationTime": 0, "totalTime": 410, "serializationTime": 0, "deserializationTime": 0, }, ) throughput.reset() assert equal_no_time( throughput.stats, { "numberOfCalls": 0, "sentBytes": 0, "receivedBytes": 0, "applicationTime": 0, "totalTime": 0, "serializationTime": 0, "deserializationTime": 0, }, ) conn.call("BAPI_USER_GET_DETAIL", USERNAME="******")["LASTMODIFIED"] assert equal_no_time( throughput.stats, { "numberOfCalls": 90, "sentBytes": 67028, "receivedBytes": 416456, "applicationTime": 0, "totalTime": 4833, "serializationTime": 2, "deserializationTime": 32, }, ) conn.close() assert not conn.alive
class TestErrors: def setup_method(self, test_method): self.conn = Connection(**params) assert self.conn.alive def teardown_method(self, test_method): self.conn.close() assert not self.conn.alive def test_no_connection_params(self): try: Connection() except RFCError as ex: assert ex.args[0] == "Connection parameters missing" # todo: test correct status after error -> or to the error tests? def test_incomplete_params(self): incomplete_params = params.copy() for p in ["ashost", "gwhost", "mshost"]: if p in incomplete_params: del incomplete_params[p] try: Connection(**incomplete_params) except RFCError as ex: error = get_error(ex) assert error["code"] == 20 assert error["key"] == "RFC_INVALID_PARAMETER" assert error["message"][0] in [ "Parameter ASHOST, GWHOST, MSHOST or SERVER_PORT is missing.", "Parameter ASHOST, GWHOST, MSHOST or PORT is missing.", "Parameter ASHOST, GWHOST or MSHOST is missing.", ] def test_denied_users(self): denied_params = params.copy() denied_params["user"] = "******" try: Connection(**denied_params) except LogonError as ex: error = get_error(ex) assert error["code"] == 2 assert error["key"] == "RFC_LOGON_FAILURE" assert error["message"][ 0] == "Name or password is incorrect (repeat logon)" def test_call_without_RFM_name(self): try: self.conn.call() except Exception as ex: assert isinstance(ex, TypeError) is True assert ex.args[ 0] == "call() takes at least 1 positional argument (0 given)" def test_call_non_existing_RFM(self): try: self.conn.call("undefined") except ABAPApplicationError as ex: error = get_error(ex) assert error["code"] == 5 assert error["key"] == "FU_NOT_FOUND" assert error["message"][0] == "ID:FL Type:E Number:046 undefined" def test_call_non_string_RFM_name(self): try: self.conn.call(1) except RFCError as ex: assert ex.args == ( "Remote function module name must be unicode string, received:", 1, int, ) def test_call_non_existing_RFM_parameter(self): try: self.conn.call("STFC_CONNECTION", undefined=0) except ExternalRuntimeError as ex: error = get_error(ex) assert error["code"] == 20 assert error["key"] == "RFC_INVALID_PARAMETER" assert error["message"][0] == "field 'undefined' not found" def test_non_existing_field_structure(self): IMPORTSTRUCT = {"XRFCCHAR1": "A", "RFCCHAR2": "BC", "RFCCHAR4": "DEFG"} try: result = self.conn.call("STFC_STRUCTURE", IMPORTSTRUCT=IMPORTSTRUCT) except ExternalRuntimeError as ex: assert ex.code == 20 assert ex.key == "RFC_INVALID_PARAMETER" assert ex.message == "field 'XRFCCHAR1' not found" def test_non_existing_field_table(self): IMPORTSTRUCT = {"XRFCCHAR1": "A", "RFCCHAR2": "BC", "RFCCHAR4": "DEFG"} try: result = self.conn.call("STFC_STRUCTURE", RFCTABLE=[IMPORTSTRUCT]) except ExternalRuntimeError as ex: assert ex.code == 20 assert ex.key == "RFC_INVALID_PARAMETER" assert ex.message == "field 'XRFCCHAR1' not found"
class TestErrorsABAP: def setup_method(self, test_method): self.conn = Connection(**params) assert self.conn.alive def teardown_method(self, test_method): self.conn.close() assert not self.conn.alive def test_no_connection_params(self): try: Connection() except RFCError as ex: assert ex.args[0] == "Connection parameters missing" def test_RFC_RAISE_ERROR(self): try: result = self.conn.call("RFC_RAISE_ERROR", MESSAGETYPE="A") except ABAPRuntimeError as ex: assert self.conn.alive == True assert ex.code == 4 assert ex.key == "Function not supported" assert ex.message == "Function not supported" assert ex.msg_class == "SR" assert ex.msg_type == "A" assert ex.msg_number == "006" def test_STFC_SAPGUI(self): # STFC_SAPGUI RFC-TEST: RFC with SAPGUI try: self.conn.call("STFC_SAPGUI") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 3 assert error["key"] == "DYNPRO_SEND_IN_BACKGROUND" def test_RFC_RAISE_ERROR_AbapRuntimeError_E0(self): # RFC_RAISE_ERROR ARFC: Raise Different Type of Error Message # Comment: cf. result_print of the error_test.py # cf. ExceptionTest.c (l. 92ff) try: self.conn.call("RFC_RAISE_ERROR", METHOD="0", MESSAGETYPE="E") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 4 assert error["message"][0] == u"Function not supported" def test_RFC_RAISE_ERROR_AbapApplicationError_E1(self): # Comment: cf. result_print of the error_test.py # '1_E': 'ABAPApplicationError-5-RAISE_EXCEPTION-ID:SR Type:E Number:006 STRING-True', # cf. ExceptionTest.c (l. 75ff) try: self.conn.call("RFC_RAISE_ERROR", METHOD="1", MESSAGETYPE="E") except ABAPApplicationError as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 5 assert error["key"] == "RAISE_EXCEPTION" assert error["msg_class"] == u"SR" assert error["msg_type"] == "E" assert error["msg_number"] == "006" def test_RFC_RAISE_ERROR_AbapApplicationError_E2(self): # '2_E': 'ABAPApplicationError-5-RAISE_EXCEPTION- Number:000-True', # cf. ExceptionTest.c (l. 65ff) try: self.conn.call("RFC_RAISE_ERROR", METHOD="2", MESSAGETYPE="E") except ABAPApplicationError as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 5 assert error["key"] == "RAISE_EXCEPTION" assert error["msg_number"] == "000" def test_RFC_RAISE_ERROR_AbapRuntimeError_E3(self): # '3_E': 'ABAPRuntimeError-3-COMPUTE_INT_ZERODIVIDE-Division by 0 (type I)-True''] == # cf. ExceptionTest.c (l. 164ff) try: self.conn.call("RFC_RAISE_ERROR", METHOD="3", MESSAGETYPE="E") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 3 assert error["key"] == "COMPUTE_INT_ZERODIVIDE" def test_RFC_RAISE_ERROR_AbapRuntimeError_A(self): # cf. ExceptionTest.c (l. 112ff) try: self.conn.call("RFC_RAISE_ERROR", MESSAGETYPE="A") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 4 assert error["msg_class"] == "SR" assert error["msg_type"] == "A" assert error["msg_number"] == "006" assert error["msg_v1"] == "Method = 0" def test_RFC_RAISE_ERROR_AbapRuntimeError_X(self): # cf. ExceptionTest.c (l. 137ff) try: self.conn.call("RFC_RAISE_ERROR", MESSAGETYPE="X") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 4 assert error["key"] == "MESSAGE_TYPE_X" assert error["msg_class"] == "00" assert error["msg_type"] == "X" assert error["msg_number"] == "341" assert error["msg_v1"] == "MESSAGE_TYPE_X" def test_RFC_RAISE_ERROR_AbapRuntimeError_E36(self): # '36_E': 'ABAPRuntimeError-4-Division by 0 (type I)-Division by 0 (type I)-True''] == try: self.conn.call("RFC_RAISE_ERROR", METHOD="36", MESSAGETYPE="E") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 4 assert u"Division by 0" in error["message"][0] def test_RFC_RAISE_ERROR_AbapRuntimeError_E51(self): # '51_E': 'ABAPRuntimeError-3-BLOCKED_COMMIT-A database commit was blocked by the application.-True''] == try: self.conn.call("RFC_RAISE_ERROR", METHOD="51", MESSAGETYPE="E") except (ABAPRuntimeError) as ex: assert self.conn.alive == True error = get_error(ex) assert error["code"] == 3 assert error["key"] == "BLOCKED_COMMIT" """ todo Windows test crashes!
def main(function_name): config = ConfigParser() config.read("sapnwrfc.cfg") params_connection = config._sections["connection"] try: connection = Connection(**params_connection) func_desc = connection.get_function_description(function_name) print("Parameters of function: {0}".format(function_name)) parameter_keys = [ "name", "parameter_type", "direction", "nuc_length", "uc_length", "decimals", "default_value", "optional", "type_description", "parameter_text", ] parameter_widths = [20, 17, 11, 10, 9, 9, 15, 10, 15, 20] for key, width in zip(parameter_keys, parameter_widths): sys.stdout.write("{0}".format(key).ljust(width).upper() + " ") sys.stdout.write("\n") for parameter in sorted(func_desc.parameters, key=parameter_key_function): for key, width in zip(parameter_keys, parameter_widths): if key == "type_description" and parameter[key] is not None: sys.stdout.write( "{0}".format(parameter[key].name).ljust(width) + " ") else: sys.stdout.write( "{0}".format(parameter[key]).ljust(width) + " ") sys.stdout.write("\n") type_desc = parameter["type_description"] if type_desc is not None: # type_desc of class TypeDescription field_keys = [ "name", "field_type", "nuc_length", "nuc_offset", "uc_length", "uc_offset", "decimals", "type_description", ] field_widths = [20, 17, 10, 10, 9, 9, 10, 15] sys.stdout.write( " " * 4 + "-----------( Structure of {0.name} (n/uc_length={0.nuc_length}/{0.uc_length})--\n" .format(type_desc)) for key, width in zip(field_keys, field_widths): sys.stdout.write("{0}".format(key).ljust(width).upper() + " ") sys.stdout.write("\n") for field_description in type_desc.fields: for key, width in zip(field_keys, field_widths): sys.stdout.write( "{0}".format(field_description[key]).ljust(width) + " ") sys.stdout.write("\n") sys.stdout.write( " " * 4 + "-----------( Structure of {0.name} )-----------\n".format( type_desc)) sys.stdout.write("-" * sum(parameter_widths) + "\n") connection.close() except CommunicationError: print("Could not connect to server.") raise except LogonError: print("Could not log in. Wrong credentials?") raise except (ABAPApplicationError, ABAPRuntimeError): print("An error occurred.") raise
class R3rfcconn(object): def __init__(self, r3user, r3pwd, r3ashost, r3sysnr, r3client): self.conn = Connection(user=r3user, passwd=r3pwd, ashost=r3ashost, sysnr=r3sysnr, client=r3client) def get_connection_attributes(self): return self.conn.get_connection_attributes() def get_function_description(self, func_name): return self.conn.get_function_description(func_name) def get_table_data( self, tablename: str, offset: int = 0, limit: int = 0, options: List = [], fields: List = [], ): read_table_fm = 'RFC_READ_TABLE' kwparam = {} kwparam['QUERY_TABLE'] = tablename kwparam['ROWSKIPS'] = offset kwparam['ROWCOUNT'] = limit kwparam['OPTIONS'] = options kwparam['FIELDS'] = fields result = self.conn.call(read_table_fm, **kwparam) return result def get_rfc_data(self, fm: str, **kwparam: dict): result = self.conn.call(fm, **kwparam) # return json.dumps(result, cls=JsonCustomEncoder) return result def get_server_wp_list(self, servername): ''' get workprocess list and info by servername :param servername: s4ides1_DM0_00 :return: ''' kwparam = {} kwparam['SRVNAME'] = servername kwparam['WITH_CPU'] = b'00' kwparam['WITH_MTX_INFO'] = 0 kwparam['MAX_ELEMS'] = 0 return self.get_rfc_data('TH_WPINFO', **kwparam)['WPLIST'] def get_user_list(self): ''' get SID overall wp info :return: ''' kwparam = {} return self.get_rfc_data('TH_USER_LIST', **kwparam)['USRLIST'] def get_bkjob_status_count(self): ''' tables: TBTCP,TBTCO and TBTCS, views: V_OP get per 15s by promethues define scrawl The statuses have the following meanings: Scheduled: not yet been released to run. P Released: released to run. S Ready: start date and time have come: awaiting execution. Active: currently running. R After a system failure, can indicate that a job was interrupted by the failure and must be manually restarted. Finished: successfully completed. F Aborted: not successfully completed. A :param servername: :return: ''' job_finish = self.get_table_data( 'V_OP', options=[ f"STATUS EQ 'F' AND ENDDATE EQ '{date.today()}' AND ENDTIME GT '{(datetime.now()-timedelta(seconds=15)).strftime('%H%M%S')}'" ], fields=[ 'JOBNAME', 'STRTDATE', 'STRTTIME', 'ENDDATE', 'ENDTIME', 'PRDMINS', 'PRDHOURS', 'STATUS' ]) job_running = self.get_table_data('V_OP', options=[f"STATUS EQ 'R'"], fields=[ 'JOBNAME', 'STRTDATE', 'STRTTIME', 'ENDDATE', 'ENDTIME', 'PRDMINS', 'PRDHOURS', 'STATUS' ]) job_cancel = self.get_table_data( 'V_OP', options=[ f"STATUS EQ 'A' AND ENDDATE EQ '{date.today()}' AND ENDTIME GT '{(datetime.now()-timedelta(seconds=15)).strftime('%H%M%S')}'" ], fields=[ 'JOBNAME', 'STRTDATE', 'STRTTIME', 'ENDDATE', 'ENDTIME', 'PRDMINS', 'PRDHOURS', 'STATUS' ]) return { "finish": len(job_finish['DATA']), "running": len(job_running['DATA']), "cancel": len(job_cancel['DATA']) } def get_dump_list(self): # date.today() - timedelta(1), DATE_TO = date.today(), TIME_FROM = '000000', TIME_TO = '235959') kwparam = {} kwparam['DATE_FROM'] = date.today() kwparam['TIME_FROM'] = b'000000' kwparam['DATE_TO'] = date.today() kwparam['TIME_TO'] = b'235959' try: return self.get_rfc_data('/SDF/GET_DUMP_LOG', **kwparam)['ET_E2E_LOG'] except: return [] def get_rfcresource_list(self, servername): ''' need confirm :param servername: :return: ''' kwparam = {} return self.get_rfc_data('RFC_SERVER_GROUP_RESOURCES', **kwparam) def get_transport_list(self): tablename = 'E070' return self.get_table_data(tablename) def get_st02_data(self): kwparam = {} st02data = self.get_rfc_data('SAPTUNE_GET_SUMMARY_STATISTIC') del st02data['TABLE_QUALITIES'] del st02data['TABLE_STATISTIC'] del st02data['TABLE_STATISTIC_64'] del st02data['CURSOR_CACHE_INFO'] del st02data['MODE_MEMORY_HISTORY'] del st02data['INTERNAL_EXTERNAL_MODES_MEMORY'] del st02data['BUFFER_STATISTIC_64'] st02data_json = json.dumps(st02data, cls=DecimalEncoder) return json.loads(st02data_json) def get_st03_data_summary(self): kwparam = {} kwparam['READ_START_DATE'] = date.today() kwparam['READ_END_DATE'] = date.today() kwparam['READ_START_TIME'] = (datetime.now() - timedelta(seconds=60)).strftime('%H%M%S') kwparam['READ_END_TIME'] = (datetime.now() - timedelta(seconds=0)).strftime('%H%M%S') st03datadetail = self.get_rfc_data('SAPWL_SNAPSHOT_FROM_REMOTE_SYS', **kwparam) st03datadetail_json = json.dumps(st03datadetail['SUMMARY'], cls=DecimalEncoder) return json.loads(st03datadetail_json) def close(self): self.conn.close()
def test_create_with_single_connection(self): conn = Connection(**params) throughput = Throughput(conn) assert len(throughput.connections) == 1 conn.close()
def test_wsrfc_call_client_cert(self): client = Connection(dest="WS_ALX_CC") assert client.alive is True client.close()
def test_wsrfc_call_basic_auth(self): client = Connection(dest="WS_ALX") assert client.alive is True client.close()