From R/3 to an External Program (registered program) 

Purpose

An ABAP program in an R/3 System starts a non-SAP program on another system and exchanges data with this program.

The external program may also be a Registered Program.

Communication is possible with the following external target programs:

Prerequisites / Process flow

With this constellation, you must note the following guidelines:

:
#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.

:
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:

For more details on the RFC interface, refer to the documentation Remote Communications.

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

Non-registered program

Registered program

.
.
< poss. host type define, see
Define Variables for Host Types >
.
.
#define SOCK 1
#include "cpic.h"
.
.
main(int argc,char **argv)
{
.
.
SAP_CMACCP(argv);
.
.
CMACCP(..);
.
.
}

.
.
<poss. computer type define >
:
.
#define SOCK 1
#include "cpic.h"
.
.
main(int argc,char **argv)
{
SAP_CMREGTP(argv);
.

.
SAP_CMACCPTP(argv);
.
.
CMACCP(..);
.
.
}

To link the C program, use the function library pictlib.o.

The function SAP_CMACCP 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.

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.)

WindowsNT:

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.

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..rhosts 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.

Example:

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
.