Because we want high availability and scalability in our SAP, we use multiple application servers and spread the load between them with help from a so called message server. Connection thru this message server has some special requirements, though, so I hope this short post will help somebody in the same position that we were.
Normally, you'd use something like this to connect:
<?php
$rfc = saprfc_open (array (
"ASHOST"=>"server",
"SYSNR"=>"01",
"CLIENT"=>"001",
"USER"=>"test",
"PASSWD" =>"test"
) );
?>
Where ASHOST is your application server hostname, SYSNR is the system number etc. Even if you are using a message server, you can still connect to any of your application servers like this directly.
With the message server however, you have to use different connection variables:
<?php
$rfc = saprfc_open (array (
"CLIENT"=>"001",
"USER"=>"test",
"PASSWD" =>"test",
"MSHOST"=>"server1",
"R3NAME"=>"ABC",
"GROUP"=>"PUBLIC"
) );
?>
Where MSHOST is the hostname of your message server, R3NAME is the three-letter system name and the GROUP parameter specifies a logon group to use. If you do not use logon groups, leave the parameter empty or use a " " string (blank space). Logon group PUBLIC is almost always defined as well.
But, here is the catch: this will not work by itself. You may have noticed, that in the connect parameters, we never specified which port to use to connect. This must be defined in you /etc/services file on the server, where you run the PHP code.
You must add a line to /etc/services specifying on what port does the message server listen on:
sapmsABC 3601/tcp
The service name is constructed as sapms<SID>, where the <SID> is the three-letter system name used in the R3NAME connection attribute. The port obviously must be the one you use. If you do not know the port number, it is most usually 3600 + system number. So if our system has system number 01, the port is 3601. If the system number is 40, the port is 3640.
After adding this line to your services definition, the connection should start working.
2 komentářů: