Queue Interface for C Programs: RFC to R/3 

Definition

You can use the SAP interface Remote Function Call (RFC) to call the function modules of the queue interface in R/3 from external C programs to place data in - or read data from - a queue. The necessary functions are provided by the RFC library.

Use

For details of the SAP interface RFC, see the documentation Remote Communications.

For details of the Q-API function modules, see Queue Interface in the R/3 System.

An ABAP program calls a queue function module in another R/3 System (C11) as follows:

CALL FUNCTION 'QUEUE_OPEN'
DESTINATION 'C11'
EXPORTING NAME = 'TESTQUEUE'
OPENMODE = 'W'
TYPE = 'A'.

Accordingly, a C program calls the same queue function module in the R/3 System as follows:

/***
*/

#include "saprfc.h"

char queue[20] = 'TESTQUEUE';
char openmode = 'W';
char qtype = 'A';
int rc;
char *exception ;
RFC_OPTIONS rfc_options;
RFC_PARAMETER exporting[5],importing[5];
RFC_HANDLE handle = RFC_HANDLE_NULL;

:
rfc_options.destination = "C11";
handle = RfcOpen( &rfc_options); /* link to RFC Partner */
:

exporting[0].name = "NAME";
exporting[0].nlen = 4;
exporting[0].type = TYPC;
exporting[0].addr = queue;
exporting[0].leng = 20;

exporting[1].name = "OPENMODE";
exporting[1].nlen = 8;
exporting[1].type = TYPC;
exporting[1].addr = &openmode;
exporting[1].leng = 1;

exporting[2].name = "TYPE";
exporting[2].nlen = 4;
exporting[2].type = TYPC;
exporting[2].addr = &qtype;
exporting[2].leng = 1;

exporting[3].name = (char *)0; /* no more export parameters */

importing[0].name = NULL; /* no import parameter(s) */
tables[0].name = NULL; /* no internal table(s) */
exception = NULL; /* default exception handling*/

rc = RfcCallReceive( handle,
"QUEUE_OPEN",
exporting,
importing,
tables,
&exception);
...
...

An ABAP/4 program calls a queue function module in another R/3 System (C11) as follows:

CALL FUNCTION 'QUEUE_OPEN'
DESTINATION 'C11'
EXPORTING NAME = 'TESTQUEUE'
OPENMODE = 'W'
TYPE = 'A'.

Accordingly, a C program calls the same queue function module in the R/3 System as follows:

/***
*/

#include "saprfc.h"

char queue[20] = 'TESTQUEUE';
char openmode = 'W';
char qtype = 'A';
int rc;
char *exception ;
RFC_OPTIONS rfc_options;
RFC_PARAMETER exporting[5],importing[5];
RFC_HANDLE handle = RFC_HANDLE_NULL;

:
rfc_options.destination = "C11";
handle = RfcOpen( &rfc_options); /* link to RFC Partner */
:

exporting[0].name = "NAME";
exporting[0].nlen = 4;
exporting[0].type = TYPC;
exporting[0].addr = queue;
exporting[0].leng = 20;

exporting[1].name = "OPENMODE";
exporting[1].nlen = 8;
exporting[1].type = TYPC;
exporting[1].addr = &openmode;
exporting[1].leng = 1;

exporting[2].name = "TYPE";
exporting[2].nlen = 4;
exporting[2].type = TYPC;
exporting[2].addr = &qtype;
exporting[2].leng = 1;

exporting[3].name = (char *)0; /* no more export parameters */

importing[0].name = NULL; /* no import parameter(s) */
tables[0].name = NULL; /* no internal table(s) */
exception = NULL; /* default exception handling*/

rc = RfcCallReceive( handle,
"QUEUE_OPEN",
exporting,
importing,
tables,
&exception);
...
...

Data objects which are read from a queue by an ABAP program must not exceed the field length of field APQD-VARDATA, which is defined in the Data Dictionary.