How to use the pyrfc.RFCError function in pyrfc

To help you get started, we’ve selected a few pyrfc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / PyRFC / material / test_unit.py View on Github external
def test_unit_destroy(self):
        self.assertFalse(self.conn.get_connection_attributes()['active_unit'], u"No active TA (base condition).")

        unit = self.conn.initialize_unit(background=False)
        with self.assertRaises(pyrfc.RFCError) as e: # missing transaction
            self.conn.destroy_unit(unit)
        self.assertEqual(e.exception.message, u"No transaction handle for this connection available.")

        unit = self.conn.initialize_unit(background=False)
        idoc = self._get_idoc_desc(41)
        with self.assertRaises(pyrfc.RFCError) as e: # already destroyed transaction
            self.conn.fill_and_submit_unit(unit, [(u"IDOC_INBOUND_ASYNCHRONOUS", idoc)])
            self.conn.destroy_unit(unit)
            self.conn.destroy_unit(unit)
        self.assertEqual(e.exception.message, u"No transaction handle for this connection available.")

        unit = self.conn.initialize_unit(background=False)
        idoc = self._get_idoc_desc(42)
        with self.assertRaises(pyrfc.RFCError) as e: # already confirmed transaction
            self.conn.fill_and_submit_unit(unit, [(u"IDOC_INBOUND_ASYNCHRONOUS", idoc)])
            self.conn.confirm_unit(unit)
            self.conn.destroy_unit(unit)
        self.assertEqual(e.exception.message, u"No transaction handle for this connection available.")
github SAP / PyRFC / material / test_unit.py View on Github external
def test_unit_destroy(self):
        self.assertFalse(self.conn.get_connection_attributes()['active_unit'], u"No active TA (base condition).")

        unit = self.conn.initialize_unit(background=False)
        with self.assertRaises(pyrfc.RFCError) as e: # missing transaction
            self.conn.destroy_unit(unit)
        self.assertEqual(e.exception.message, u"No transaction handle for this connection available.")

        unit = self.conn.initialize_unit(background=False)
        idoc = self._get_idoc_desc(41)
        with self.assertRaises(pyrfc.RFCError) as e: # already destroyed transaction
            self.conn.fill_and_submit_unit(unit, [(u"IDOC_INBOUND_ASYNCHRONOUS", idoc)])
            self.conn.destroy_unit(unit)
            self.conn.destroy_unit(unit)
        self.assertEqual(e.exception.message, u"No transaction handle for this connection available.")

        unit = self.conn.initialize_unit(background=False)
        idoc = self._get_idoc_desc(42)
        with self.assertRaises(pyrfc.RFCError) as e: # already confirmed transaction
            self.conn.fill_and_submit_unit(unit, [(u"IDOC_INBOUND_ASYNCHRONOUS", idoc)])
            self.conn.confirm_unit(unit)
github SAP / PyRFC / material / test_server.py View on Github external
msg_class='SR', # message id or class
            msg_type='E', # out of e.g. 'E', 'A' or 'X'
            msg_number='007', # 3 char numeric
            msg_v1='V1 text' # 50 char
        )
    elif REQUTEXT == 'MESSAGE':
        raise ABAPRuntimeError(
            msg_class='SM', # message id or class
            msg_type='E', # out of e.g. 'E', 'A' or 'X'
            msg_number='107', # 3 char numeric string
            msg_v1='V1 text (ABAP_MESSAGE)'
        )
    elif REQUTEXT == 'FAILURE':
        raise ExternalRuntimeError("Something very bad happened.")
    elif REQUTEXT == 'INVALID':
        raise RFCError("Invalid exception")
    return {
        'ECHOTEXT': REQUTEXT,
        'RESPTEXT': u"Local (raise error) server here. Use the following values"
                    u"for REQUTEXT: EXCEPTION, EXCEPTION_MESSAGE, MESSAGE, "
github SAP / PyRFC / tests / test_errors.py View on Github external
def test_no_connection_params(self):
        try:
            pyrfc.Connection()
        except pyrfc.RFCError as ex:
            assert ex.args[0] == "Connection parameters missing"
github SAP / PyRFC / tests / test_errors_abap.py View on Github external
def test_no_connection_params(self):
        try:
            pyrfc.Connection()
        except pyrfc.RFCError as ex:
            assert ex.args[0] == "Connection parameters missing"
github SAP / PyRFC / tests / test_connection.py View on Github external
def test_call_over_closed_connection(self):
        conn = pyrfc.Connection(config={"rstrip": False}, **config_sections["coevi51"])
        conn.close()
        assert conn.alive == False
        hello = u"Hällo SAP!"
        try:
            result = conn.call("STFC_CONNECTION", REQUTEXT=hello)
        except pyrfc.RFCError as ex:
            print(ex.args)
            assert (
                ex.args[0]
                == "Remote function module STFC_CONNECTION invocation rejected because the connection is closed"
            )