cancel
Showing results for 
Search instead for 
Did you mean: 

RfcInvoke for SX_OBJECT_RECEIVE is returning ERR_INVALID_VERSION.

bernhard_schuetz
Discoverer
0 Kudos

Hi,

I am trying to call SX_OBJECT_RECEIVE with all the required parameters. I have included my source code here. I am getting the below error. Could you please help me what am I missing here:

Error code: RFC_ABAP_EXCEPTION

Error Group: ABAP_APPLICATION_FAILURE

Error Key: ERR_INVALID_VERSION

Error Message: ID:XS Type:E Number:010

Below are the parameters from my sapnwrfc.ini:

DEST=LOCAL

ASHOST=/H/172.26.56.248/H/ldcic65

CLIENT=800

LANG=EN

SYSNR=03

USER=<MyUserName>

PASSWD=<MyPassword>

TRACE=3

RFC_TRACE=2

Below are the CPIP, RFC logs generated on my machine:

cpic-35724-trc.txt

dev-rfc-log.txt

rfc35724-21372-trc.txt

ws-rfc-35724-trc.txt

#include <stdlib.h>
#include <stdio.h>
#include "sapnwrfc.h"

void errorHandling(RFC_RC rc, SAP_UC* description, RFC_ERROR_INFO* errorInfo, RFC_CONNECTION_HANDLE connection) {
	printfU(cU("%s: %d\n"), description, rc);
	printfU(cU("%s: %s\n"), errorInfo->key, errorInfo->message);
	// It's better to close the TCP/IP connection cleanly, than to just let the backend get a "Connection reset by peer" error...
	if (connection != NULL) RfcCloseConnection(connection, errorInfo);
	exit(1);
}

int mainU(int argc, SAP_UC** argv) {
	RFC_RC rc = RFC_OK;
	RFC_ERROR_INFO errorInfo = { 0 };
	RFC_CONNECTION_PARAMETER repoCon[1] = { 0 };
	RFC_CONNECTION_HANDLE repoHandle = NULL;

	RFC_FUNCTION_DESC_HANDLE sxObjectReceiveDesc = NULL;
	RFC_FUNCTION_HANDLE sxObjectReceiveFuncHandle = NULL;

	RFC_PARAMETER_DESC exportSystemDataParamDesc = { cU("SYSTEM_DATA"), RFCTYPE_STRUCTURE, RFC_IMPORT, 12, 24, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC exportDocumentDataParamDesc = { cU("DOCUMENT_DATA"), RFCTYPE_STRUCTURE, RFC_IMPORT, 204, 408, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC exportReceiveInfoParamDesc = { cU("RECEIVE_INFO"), RFCTYPE_STRUCTURE, RFC_IMPORT, 3856, 7712, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesReceiversParamDesc = { cU("RECEIVERS"), RFCTYPE_STRUCTURE, RFC_TABLES, 3856, 7712, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesPackingListParamDesc = { cU("PACKING_LIST"), RFCTYPE_STRUCTURE, RFC_TABLES, 145, 290, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesObjectHeaderParamDesc = { cU("OBJECT_HEADER"), RFCTYPE_STRUCTURE, RFC_TABLES, 255, 510, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesContentsBinParamDesc = { cU("CONTENTS_BIN"), RFCTYPE_STRUCTURE, RFC_TABLES, 255, 510, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesContentsTxtParamDesc = { cU("CONTENTS_TXT"), RFCTYPE_STRUCTURE, RFC_TABLES, 255, 510, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesObjectParAParamDesc = { cU("OBJECT_PARA"), RFCTYPE_STRUCTURE, RFC_TABLES, 96, 192, 0, 0, cU(""), cU(""), 0, 0 };
	RFC_PARAMETER_DESC tablesObjectParBParamDesc = { cU("OBJECT_PARB"), RFCTYPE_STRUCTURE, RFC_TABLES, 300, 600, 0, 0, cU(""), cU(""), 0, 0 };

	repoCon[0].name = cU("DEST");	repoCon[0].value = cU("LOCAL");

	printfU(cU("Opening the Rfc connection ...."));
	repoHandle = RfcOpenConnection(repoCon, 1, &errorInfo);
	if (repoHandle == NULL) errorHandling(errorInfo.code, cU("Error in RfcOpenConnection()"), &errorInfo, NULL);
	printfU(cU(" ...done\n"));

	printfU(cU("Getting the function description handle for SX_OBJECT_RECEIVE ...."));
	sxObjectReceiveDesc = RfcCreateFunctionDesc(cU("SX_OBJECT_RECEIVE"), &errorInfo);
	if (sxObjectReceiveDesc == NULL) errorHandling(errorInfo.code, cU("Error in getting function description handle of SX_OBJECT_RECEIVE"), &errorInfo, NULL);
	printfU(cU(" ...done\n"));

	rc = RfcAddParameter(sxObjectReceiveDesc, &exportSystemDataParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &exportDocumentDataParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &exportReceiveInfoParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesReceiversParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesPackingListParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesObjectHeaderParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesContentsBinParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesContentsTxtParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesObjectParAParamDesc, &errorInfo);
	rc = RfcAddParameter(sxObjectReceiveDesc, &tablesObjectParBParamDesc, &errorInfo);

	sxObjectReceiveFuncHandle = RfcCreateFunction(sxObjectReceiveDesc, &errorInfo);
	printfU(cU("Invoking the function SX_OBJECT_RECEIVE ...."));
	rc = RfcInvoke(repoHandle, sxObjectReceiveFuncHandle, &errorInfo);
	if (rc != RFC_OK) errorHandling(errorInfo.code, cU("Error in RfcInvoke for the function SX_OBJECT_RECEIVE"), &errorInfo, NULL);
	printfU(cU(" ...done\n"));

	printfU(cU("Destroying the function SX_OBJECT_RECEIVE ...."));
	rc = RfcDestroyFunction(sxObjectReceiveFuncHandle, &errorInfo);
	if (rc != RFC_OK) errorHandling(errorInfo.code, cU("Error in RfcDestroyFunction of SX_OBJECT_RECEIVE"), &errorInfo, NULL);
	printfU(cU(" ...done\n"));

	printfU(cU("Logging out...."));
	rc = RfcCloseConnection(repoHandle, &errorInfo);
	if (rc != RFC_OK) errorHandling(errorInfo.code, cU("Error in RfcCloseConnection()"), &errorInfo, NULL);
	printfU(cU(" ....done\n"));

	return 0;
} 
bernhard_schuetz
Discoverer
0 Kudos

Hi all,

Could someone help me fix the issue requested in the above question?

Accepted Solutions (0)

Answers (0)