SAP RFC SERVER PGM

Get Example source ABAP code based on a different SAP table
  


SECRET
ARTICLE

ABAP server program does not run
An RFC server program is a program that uses the SAP RFC interface and is started from an ABAP system using CALL FUNTION ....

Cause and conditions
There are various possible causes, depending on the program:
Wrong or incomplete entries in SM59 (parameterization of RFC destination)
Network problems
Missing authorizations
Errors in RFC server program

Solution
The following checklist will help you to identify problems with RFC server programs:
SM59 settings:
The destination must have been entered in transaction SM59 with type T.
If possible, specify a full path for the program you want to start.
Did you save the destination?
Configuration at operating system level:
The following points depend on the host name in the destination:
You have entered a name for the host name (radio button 'explicit' in Release 3.0), or you have stored a non-standard gateway in the gateway options:
In this case, the program is started by the standard gateway or the explicitly specified gateway (gwrd) using 'Remote shell'. Ensure that the specified host can be reached from the host of the gateway process. Enter the following on the gateway host:
/etc/ping <(><<)>host name> or ping <(><<)>host name>
In order for a program to be started on another host using 'Remote shell' the user ID of the gateway process must be known in the target system, and the HOME directory of the user in the target system must have a file .rhosts. This file should contain the name of the calling host. You can test this by logging onto the host containing the gateway process under the name user ID used by the process and entering the following command:
remsh <(><<)>hostname> <(><<)>programname> <(><<)>hostname> and <(><<)> programname<(><<)> must be the same as those you specified in SM59 . If you call an RFC server program without parameters, the call of RfcAccept always returns an error code (RFC_HANDLE_NULL) and the program terminates immediately.
There is no entry in 'Hostname' (or, in Release 3.0, you selected 'Server') :
The program is started by the SAP application server. Make sure that it can be reached from this server.
Make sure that the SAP application server has the authorization to start the program. Check this by logging on under the user ID of the SAP application server (usually c11adm). Go to the 'work' directory of the application server (/usr/sap/.../D.../work) and try to start the RFC server program manually. (As above, if you call an RFC server program without parameters, the call of RfcAccept always returns an error ( RFC_HANDLE_NULL) and the sample program terminates immediately.
In Release 3.0, you can also choose the 'User' radio button.
In this case, the program is started by 'SAPgui', that is, under the user ID and environment of the user.
* Ensure that the program can be reached from 'sapgui'/'saptemu'.
* Ensure that 'sapgui has the authorization to start the program.
* Try to start the RFC server program from your own user environment.
Problems in the RFC server program itself
You can catch the 'stderr' output of the server program by entering a main program instead of the server program as the destination. The frame program starts the actual server program using the same command line, and routes the standard output of the server program to a file.
Example :
RFC server program /xxx/xxxx
However, you call the C shell script (do not forget to specify the shell in the first line) :
#!/bin/csh
date >> /tmp/rfclog
/xxx/xxxx $* >><(> <)> /tmp/rfclog
echo $status >><(> <)> /tmp/rfclog

You can the use the log file /tmp/rfclog to analyze the errors.
You can also activate the trace switch in the destination (do not forget to save). Then, the RFC server program writes a file 'dev_rfc' to its current directory, containing all of the data, operations, and errors that occurred.
Debugging an RFC server program: You can debug an RFC server program using a C debugger like dbx, xdb or codeview. Proceed as follows:
In transaction SM59 enter a program for the destination that writes the command line passed to a defined file:
Example (C shell)

#!/bin/csh
echo $* > /tmp/rfc

Start the C debugger with your RFC server program, for example, xdb <(> <<)><(><<)>)programname> and set a breakpoint after the call of RfcAccept.
Start the calling ABAP program. This results in the above main program writing its command line to the output file (/tmp/rfc in our example).
Read this file and start the RFC server program loaded into the debugger with the same command line.