AS SAP NetWeaver -> External program
(registered program)
An ABAP program of an SAP NetWeaver system starts a non-SAP program on another computer and exchanges data with this program.
The external program may also be a Registered Program.
Communication is possible with the following external target programs:
● ANSI-C programs on all supported platforms by RFC or CPI-C call
● Visual Basic programs on Windows and Windows platforms by RFC
With this constellation, you must note the following guidelines:
● Using the RFC interface:
– Choose the target system using transaction SM59.
– The called function must be an ABAP function module, which has the “remote” ID in the function library.
– A C target program must have the following structure:
:
#include
"saprfc.h"
:
main(int argc,char
**argv)
{
:
Rfc_Handle handle;
handle=RfcAccept(argv)
:
}
To link the C program, use the RFC library librfc.a.
– A Visual Basic target program must be structured as follows:
:
Sub Main()
gCommand$ =
Command$
:
hRfc =
RfcAcceptExt(gCommand$)
:
End
Sub
To link the Visual Basic program, use the librfc.lib (Windows) or ntlibrfc.lib libraries.
The following DLLs are used:
– librfc.dll
– librfc2.dll
– nidll.dll (for Windows only)
For more
details on the RFC interface, refer to the documentation
Remote
Communications Error! No
bookmark name given..
● Using the CPI-C interface
– Table TXCOM in the calling SAP NetWeaver system must contain the following parameter values:
Symbolic destination
Logical unit of the partner: Host name
Transaction program of the partner
Communication types
E |
Partner is an external program |
R |
Partner is a registered program |

DEST1 is0001 cpict2 E
Use transaction code SM54 to maintain TXCOM.
For details on the configuration of TXCOM, refer to the relevant topic in the following documentation:
BC - SAP
Communication:
Configuration
– A C target program must have the following structure.
Non-registered program |
Registered Program |
.
|
. .
|
To link the C program, use the function library pictlib.o.
The function SAP_CMACCPError! No bookmark name given. is used to pass the parameters needed to establish the connection to the CPI-C interface.
If an error occurs, SAP_CMALLC gives a return code not equal to CM_OK. After calling SAP_CMACCP, you can use CPI‑C programming as usual.

The pointer passed when SAP_CMACCP is called cannot point to data in the stack.
This is because the pointer is also used in the subsequent CPI-C functions.
● If the gateway host and the target host are the same:
UNIX:
The program must be in the search path of the of the User ID of the SAP Gateway and be startable with the User ID. (HP-UX: Gateway host and target host must always be the same.)
Windows:
The program must be in the work directory of the SAP Gateway.
OS/2:
The program is in the work directory of the SAP Gateway or it is defined in the configuration file config.sys via the PATH variable.
● If the gateway host and the target host are not the same:
The SAP Gateway starts the C program on the target host. The following conditions must be met:
UNIX:
The file .rhosts must be available in the HOME directory of the User ID of the SAP Gateway. The rhosts file must contain the name of the gateway host.
The User ID, under which the SAP Gateway is running, must be known on the target host.
The target program or a link to it must be available in the HOME directory.
CPI-C: |
limited to 8 characters |
RFC: |
no limitation, relative or explicit path |
OS/2:
The IP address of the respective partner computer must exist in the hosts file on both computers.
The program is in a path defined in the configuration file config.sys via the PATH variable.
● The started program can also be a shell script or a command procedure, which calls the actual CPIC-C program. In this case, all parameters must be passed to the C program.
Examples:
Command file for OS/2:
@REM ***********************
@REM * CPICPGM.CMD for OS/2
@REM ***********************
@SETLOCAL
@REM set up environment
@SET CPIC_TRACE=1
:
@REM start Remote Partner Program
D:\CPIC\CPICPGM.EXE %1 %2 %3
:
@ENDLOCAL
C shell script for UNIX:
#!/bin/csh
.
<Shell commands>
.
<cpic-c program> $argv
.
