Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Does PyRFC support IDoc communication?

sdas2021
Discoverer

Hi All,

We have some interfaces using Python (PyRFC) to send data to SAP via rfc.

Now there is a new integration requirement for which SAP already supports IDoc (inbound sales orders).

Looking at documentation, it is not clear if PyRFC is the correct framework for sending IDoc to SAP, or is there another officially supported library?

For Java connector (Jco), it seems to have extension for idocs. But for python/Pyrfc, it is not clear, no sample code available.

Any help guidance on this is really appreciated.

Thanks in advance.

Das

2 REPLIES 2

Srdjan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Das,

IDoc library for parsing IDocs and more convenient sending and receiving IDocs is available for Java only:

https://support.sap.com/en/product/connectors/jco.html?anchorId=section_754631833

PyRFC can be used as IDoc client (send IDocs) as in this example:

https://github.com/SAP/PyRFC/blob/main/examples/clientIDoc.py

Kind regards,

Srdjan

greety-varghese
Discoverer
0 Kudos

Hi ,

We are having same requirement to send the below IDOC to SAP using pyRFC. https://github.com/SAP/PyRFC/blob/main/examples/clientIDoc.py is the only file we could find the implementation. But thats very generic. We are struggling to form proper idoc_data_dicts for the below IDOC.

Were you able to proceed with pyRFC or are you using JCo for your requriement ?

<?xml version='1.0' encoding='UTF-8'?>
<Z_PM_IORDER01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>2</DIRECT>
<IDOCTYP>IORDER01</IDOCTYP>
<SNDPRT>LS</SNDPRT>
<SNDPRN>MYDEVENV</SNDPRN>
<RCVPOR>SAPA01</RCVPOR>
<SNDPOR>MYDEVENV_S</SNDPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>LOGA01C007</RCVPRN>
<CREDAT>20231012</CREDAT>
<CRETIM>20231012</CRETIM>
<CIMTYP>Z_PM_IORDER01</CIMTYP>
<MESTYP>IORDER</MESTYP>
<MESFCT>NEW</MESFCT>
<MESCOD>POC</MESCOD>
</EDI_DC40>
<E1ORHDR SEGMENT="1">
<AUART>ABC1</AUART>
<PRIOK>1</PRIOK>
<ILART>B01</ILART>
<E1OROPR SEGMENT="1">
<LTXA1>Test Desc</LTXA1>
<ZE1_PM_E1OROPR SEGMENT="1">
<USR00>SFDC_TEST</USR00>
</ZE1_PM_E1OROPR>
</E1OROPR>
<E1OROPR SEGMENT="1">
<LTXA1>Test Desc 1</LTXA1>
<ZE1_PM_E1OROPR SEGMENT="1">
<USR00>SFDC_TEST</USR00>
</ZE1_PM_E1OROPR>
</E1OROPR>
<E1OROPR SEGMENT="1">
<LTXA1>Test Desc 2</LTXA1>
<ZE1_PM_E1OROPR SEGMENT="1">
<USR00>SFDC_TEST</USR00>
</ZE1_PM_E1OROPR>
</E1OROPR>
<E1OROPR SEGMENT="1">
<LTXA1>Test Desc 3</LTXA1>
<ZE1_PM_E1OROPR SEGMENT="1">
<USR00>SFDC_TEST</USR00>
</ZE1_PM_E1OROPR>
</E1OROPR>
<ZE1ORHDR SEGMENT="1">
<ZZ_DMP_ORD/>
<RELKZ>X</RELKZ>
</ZE1ORHDR>
<E1ORTOB SEGMENT="1">
<EQUNR>123456</EQUNR>
</E1ORTOB>
</E1ORHDR>
</IDOC>
</Z_PM_IORDER01>