Replies: 12 comments 7 replies
-
Not in Python, but here is a detailed example in C. If all required NW RFC functions have been exported to Python, you may be able to convert the C sample to Python?! https://help.sap.com/docs/SUPPORT_CONTENT/abapconn/3354079405.html See the PDF document for some instructions and the samples.zip for the C coding. (Can be compiled into a complete executable that receives and manages simple IDocs of type TXTRAW. There is also a client program, that can send TXTRAW IDocs.) |
Beta Was this translation helpful? Give feedback.
-
Experimental support is implemented in
Two properties are provided, just like for bgRFC handlers, Can you build from source and test? |
Beta Was this translation helpful? Give feedback.
-
The error message “Application's transaction state database currently unavailable” means that the onCheck-function was executed, but it returned an error code.
So it looks like the registered C-function was called by the NW RFC lib, but it couldn’t find/execute the corresponding Python function?
|
Beta Was this translation helpful? Give feedback.
-
Is server logging activated and what is it telling? To activate, set The check handler should provide more info then: cdef RFC_RC __onCheckTransaction(RFC_CONNECTION_HANDLE rfcHandle, const SAP_UC *tid) with gil:
handler = Server.__transactionHandler["check"]
if not callable(handler):
_server_log("Transaction check handler is not registered for server connection handle '{<uintptr_t>rfcHandle}'")
return RCStatus.OK.value
try:
transaction_id = wrapString(tid)
return handler(<uintptr_t>rfcHandle, transaction_id).value
except Exception as ex:
_server_log("Error in transaction check handler:", ex)
return RCStatus.RFC_EXTERNAL_FAILURE.value |
Beta Was this translation helpful? Give feedback.
-
Thanks @Ulrich-Schmidt, I fixed a syntax error in the Python script which resolved that problem. Both the C function was well as the onCheck Python function is now being executed successfully. However, when it gets to actually executing the Python function that should handle the IDoc, the connection between the Python RFC Server and the ABAP backend gets broken. I get the the following message on the ABAP backend in transaction SM58: @bsrdjan I added the [2024-03-06 12:48:31.890969 UTC] Server '1962248167024 created' Press Enter to stop server... The IDoc is sent from the backend server, the |
Beta Was this translation helpful? Give feedback.
-
@bsrdjan attached the ABAP backend RFC trace files as well as the pyRFC trace files. (The dev_rfc.log file contains no entries). dev_rfc.log |
Beta Was this translation helpful? Give feedback.
-
The trace simply ends. Well, if you ask me, I would say that the “user function” crashes at that point. Do you see a core dump file being generated?
How does the Python runtime behave, when a segmentation fault is caused in native code outside the virtual machine? I know that the Java VM writes a special dump file called “hs_err_<pid>.log” with detailed stack information about where the crash happened.
|
Beta Was this translation helpful? Give feedback.
-
Python has faulthandler, let try it if following does not help. @duanmark, can you send your python server test script, including idoc_inbound_asynchronous python handler function, so that I can try to reproduce? Also describe how the IDOC is created and sent. I extended exceptions catching and pushed changes to transaction_handlers branch. You can pull the changes, repeat the test and send also the PyRFC server log (redirect Python server console to log file). It was not included in already sent logs and could show more error info now |
Beta Was this translation helpful? Give feedback.
-
Hello @bsrdjan, I built the console log.txt The problem is not only for "IDOC Server" scenario, I created another simple test, where I try and handle Step 1: Set up pyRFC server to handle STFC_WRITE_TO_TCPIC: Step 2: Run RSARFCT0 report on ABAP backend to generate STFC_WRITE_TO_TCPIC tRFC calls: I hope this helps? |
Beta Was this translation helpful? Give feedback.
-
I could reproduce the issue. There was one PyRFC bug in transactional handler logic, now fixed. There was also an error in your Python server function handle_rfc. Python server function should behave like corresponding ABAP function and return a dict instance, not RCStatus. That error was causing another exception, which is now exposed in server log, in case it occurs again. You can now rebuild PyRFC from transaction_handlers branch and test with fixed test_trfc.py |
Beta Was this translation helpful? Give feedback.
-
I initially received the following error while testing actual IDocs from an ABAP backend with [2024-03-11 14:35:38.410106 UTC] genericHandler 'Request for 'IDOC_INBOUND_ASYNCHRONOUS' raises ExternalRuntimeError 22 (rc=22): key=RFC_CONVERSION_FAILURE, message=PSGNUM of type RFCTYPE_NUM value= cannot be converted to type RFCTYPE_NUM [MSG: class=, type=, number=, v1-4:=;;;] - code set to RFC_EXTERNAL_FAILURE.' After changing the SM59 TCP/IP ABAP backend connection to Unicode, everything now works as expected: I see the |
Beta Was this translation helpful? Give feedback.
-
The support is still experimental and backward incompatible changes might happen. Could you please describe how IDocs are sent in your test scenario? |
Beta Was this translation helpful? Give feedback.
-
I’m curios to find out if anyone has managed to build an “IDoc Receiver” using the pyRFC Server, and if so, how was the tRFC/qRFC transactions handled within pyRFC for the received IDocs?
As stated previously in SAP/pyRFC#340 (comment) and SAP/node-rfc#279 (comment) receiving the IDocs is only half the battle, however I’m still curious to see if anyone has managed to get something working?
Beta Was this translation helpful? Give feedback.
All reactions