0

I would like to use PyRFC to do remote procedure call on SAP using the Python programming language.

conn = pyrfc.Connection(user='foouser', passwd='xxxx',
    mshost='sap.example.com', sysid='TE1', client='220',
    group='EXAMPLE',
    )

But it fails like this:

RFC_COMMUNICATION_FAILURE (rc=1): key=RFC_COMMUNICATION_FAILURE, message=
ERROR       service 'sapmsTE1' unknown
TIME        Tue Dec 18 15:49:40 2018
RELEASE     753
COMPONENT   NI (network interface)
VERSION     40
RC          -3
MODULE      /bas/753_REL/src/base/ni/niuxi.c
LINE        1833
DETAIL      NiPGetServByName: 'sapmsTE1' not found
SYSTEM CALL getaddrinfo
COUNTER     1
 [MSG: class=, type=, number=, v1-4:=;;;]

What's wrong?

I guess sapmsTE1 gets looked up in /etc/services. But this file is the default (unmodified) file of my linux server.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
guettli
  • 25,042
  • 81
  • 346
  • 663

1 Answers1

1

I found the answer myself. You need to supply the parameter "msserv". AFAIK this is a constant value. This worked:

conn = pyrfc.Connection(user='foouser', passwd='xxxx',
    mshost='sap.example.com', sysid='TE1', client='220',
    msserv='3600',
    group='EXAMPLE',
    )
guettli
  • 25,042
  • 81
  • 346
  • 663
  • 2
    msserv can be different from 3600, it depends on your SAP configuration. Message server ports can be 3600-3699. It is defined in the OS services. – Sandra Rossi Dec 18 '18 at 17:20
  • @SandraRossi If I am connected via SAP-GUI, how can I see the correct port number which I need to use in the RFC-connection to access the same SAP system? – guettli Dec 19 '18 at 08:27
  • You have to ask the SAP administrator. I can't tell you more. Maybe you could ask a question more technically-oriented like "how to know the port of the SAP message server". – Sandra Rossi Dec 19 '18 at 08:47
  • @SandraRossi yes, you are right. I opened a new question: https://stackoverflow.com/questions/53847912/sap-port-number-for-msserv-rfc – guettli Dec 19 '18 at 09:14