cancel
Showing results for 
Search instead for 
Did you mean: 

RFCSDK programming to check RFC destinations if working

Former Member
0 Kudos

Hi all,

I'm trying to develop a C program using RFCSDK in order to monitor whether RFC R/3 connections (as listed in SM59) are working or not. I've been reading the sample codes under .../rfcsdk/text such as sapinfo.c and srfctest.c but I've not made any good progress about it.

How can I modify the existing code in order to suit my needs?

Regards,

Chipi.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

This doesn't make sense to me. The RFC destinations defined in SM59 are there to allow ABAP programs to reach out to external programs. The destinations have no meaning to an RFC client outside of SAP.

You need to write an ABAP program that looks up and pings the relevant RFC destinations, best done by something like:

CALL FUNCTION 'RFC_PING' DESTINATION xxx.

I wouldn't be surprised if such a program already exists. Check programs beginning with RSRFC*.

Scott

Former Member
0 Kudos

Scott:

Wrong!

SAP RFC destinations are used for inter-system communication for ANY system that conforms to the SAP protocol.

SAP supplies a set of C libraries that allow writing of C programs that communicate with SAP systems. The sapinfo.c program is one of the test programs shipped with the C programming SDK; this program, when compiled, allows the programmer to test the RFC connections (or the code that tries to open them!).

Regards,

D.

Former Member
0 Kudos

I'm sorry Dorian, but it seems to me that your response is not following the line of the original question posted.

I am aware of the RFC protocol and the availability of the C libraries, in fact I have been coding RFC programs since 1994 when the SDK was initially released (with R/3 2.1C if I recall correctly).

Whilst you are undoubtedly correct in your analysis of the functionality of the sapinfo.c example: in that it can allow test connections to RFC servers, most typically SAP systems. However, client RFC programs such as sapinfo.c have nothing to do with RFC destinations defined in transaction SM59.

I'm probably telling you how to suck eggs, however when a client program seeks to connect to an RFC server program, it can obtain the connection information in a number of ways. The current version of the RFC SDK includes a function RfcOpenEx which receives connection information as a series of command-line like switches, for example:

"SAPLOGON_ID=<...> CLIENT=100 USER=FRED PASSWD=PASS LANG=EN"

The point here is that this information is essentially the equivalent of the connection information stored in SM59 RFC destinations - however at no point do C-based (or Java or whatever) RFC clients use RFC destinations defined in SM59 to obtain connnection information.

In fact it is a contradiction to think that a C-based RFC client could, because to access the RFC destination defined in SM59 they would first need to know the connection information to connect to the concerned SAP system!

Rather, the RFC destinations defined in SM59 provide ABAP programs (acting as RFC clients) with the connection information necessary to call external RFC servers (be they functions in other SAP systems or non-SAP programs such as C program utilising the RFC SDK).

The benefit of SM59 RFC destinations is that they provide a level of abstraction that allows an ABAP program to call into an external RFC server without needing to know where or how the RFC server is implemented. It makes no difference to the ABAP program whether the RFC server is running on the user's PC, another SAP system or perhaps a Java program.

So getting back to the original question posted; I interpreted the question to ask how one could verify that the RFC destinations defined in SM59 were working - that is, that the target RFC server was accessible. The only way to do this is through ABAP logic that invokes the RFC destination. Of course this can only be done properly by knowing a function of the target RFC server that can be called. Fortunately every RFC server program automatically implements a number of functions, such as RFC_PING. Therefore the following logic might be used:

LOOP AT GT_RFCDEST INTO GV_RFCDEST.

CALL FUNCTION 'RFC_PING'

DESTINATION GV_RFCDEST

EXCEPTIONS

COMMUNICATION_FAILURE = 1 MESSAGE GV_MESSAGE

SYSTEM_FAILURE = 2 MESSAGE GV_MESSAGE.

IF SY-SUBRC NE 0.

WRITE: / GV_RFCDEST, SY-SUBRC, GV_MESSAGE.

ENDIF.

ENDLOOP.

So, in summary, I would adapt your sentence to read:

SAP RFC destinations (defined in SM59) are used for program-to-program communication between ABAP client programs and any system that implements the server portion of the RFC protocol.

Kind regards,

Scott

Former Member
0 Kudos

Chipi:

Best way to start for testing connection is to find the default connection values defined in RFC_OPT structure in sapinfo.c (in my file it is on line 38) and replace the current values with those suitable for your SAP system. See code below:

======================================================

/* -


  • Defaults

  • ---------------------------------------------*/

rfc_opt.client = "000";

rfc_opt.user = "SAP*";

rfc_opt.language = "E";

rfc_opt.password = "PASS";

rfc_opt.trace = 0;

rfc_opt.mode = RFC_MODE_R3ONLY;

=======================================================

Alternatively, simply compile the existing file, then execute "./sapinfo" with no arguments. You will be given a command usage message; follow the instructions to specify the logon parameters on the command line.

Regards,

D.