Hi,
I am trying to manually create the metadata description for the bapi RFC_SYSTEM_INFO (don't ask why). I have a C++ program that creates the parameters needed for the RfcCreateFunctionDesc api call, it then creates and invokes the function all of these return RFC_OK. The problem is that when I try and get the structure RfcGetStructure I get an RFC_INVALID_PARAMETER error. I have included the test code below does anyone have any ideas what I am doing wrong? I have checked the lengths and offsets on the windows system I am running this on.
Thanks in advance,
Simon
void test {
RFC_ERROR_INFO errorInfo;
// First create the structure for RFC_SYSTEM_INFO
RFC_TYPE_DESC_HANDLE typeDesc = ::RfcCreateTypeDesc(cU("RFCSI_EXPORT"), &errorInfo);
addFieldType(typeDesc, L"RFCPROTO", RFCTYPE_CHAR, 3, 6, 0, 0);
addFieldType(typeDesc, L"RFCCHARTYP", RFCTYPE_CHAR, 4, 8, 3, 6);
addFieldType(typeDesc, L"RFCINTTYP", RFCTYPE_CHAR, 3, 6, 7, 14);
addFieldType(typeDesc, L"RFCFLOTYP", RFCTYPE_CHAR, 3, 6, 10, 20);
addFieldType(typeDesc, L"RFCDEST", RFCTYPE_CHAR, 32, 64, 13, 26);
addFieldType(typeDesc, L"RFCHOST", RFCTYPE_CHAR, 8, 16, 45, 90);
addFieldType(typeDesc, L"RFCSYSID", RFCTYPE_CHAR, 8, 16, 53, 106);
addFieldType(typeDesc, L"RFCHOST", RFCTYPE_CHAR, 8, 16, 45, 90);
addFieldType(typeDesc, L"RFCDATABS", RFCTYPE_CHAR, 8, 16, 61, 122);
addFieldType(typeDesc, L"RFCSAPRL", RFCTYPE_CHAR, 4, 8, 111, 222);
addFieldType(typeDesc, L"RFCMACH", RFCTYPE_CHAR, 5, 10, 115, 230);
addFieldType(typeDesc, L"RFCOPSYS", RFCTYPE_CHAR, 10, 20, 120, 240);
addFieldType(typeDesc, L"RFCTZONE", RFCTYPE_CHAR, 6, 12, 130, 260);
addFieldType(typeDesc, L"RFCDAYST", RFCTYPE_CHAR, 1, 2, 136, 274);
addFieldType(typeDesc, L"RFCIPADDR", RFCTYPE_CHAR, 15, 30, 137, 274);
addFieldType(typeDesc, L"RFCHOST2", RFCTYPE_CHAR, 32, 64, 156, 312);
addFieldType(typeDesc, L"RFCSI_RESV", RFCTYPE_CHAR, 12, 24, 188, 376);
addFieldType(typeDesc, L"RFCIPV6ADDR", RFCTYPE_CHAR, 45, 90, 200, 400);
::RfcSetTypeLength(typeDesc, 245, 490, &errorInfo);
::RfcCreateStructure(typeDesc, &errorInfo);
// Create the export parameter RFSCI_EXPORT
RFC_PARAMETER_DESC pDesc;
wcsncpy(pDesc.name, cU("RFSCI_EXPORT"), 30);
pDesc.type = RFCTYPE_STRUCTURE;
pDesc.direction = RFC_EXPORT;
pDesc.ucLength = 490;
pDesc.nucLength = 245;
pDesc.typeDescHandle = typeDesc;
RFC_FUNCTION_DESC_HANDLE hMyFunc = ::RfcCreateFunctionDesc(cU("RFC_SYSTEM_INFO"), &errorInfo);
::RfcAddParameter(hMyFunc, &pDesc, &errorInfo);
RFC_FUNCTION_HANDLE hSystemInfo = ::RfcCreateFunction(hMyFunc, &errorInfo);
::RfcInvoke(hConnect, hSystemInfo, &errorInfo);
RFC_STRUCTURE_HANDLE hStructure = NULL;
::RfcGetStructure(hSystemInfo, cU("RFCSI_EXPORT"), &hStructure, &errorInfo); // RFC_INVALID_PARAMETER
}
void addFieldType(RFC_TYPE_DESC_HANDLE typeDesc, std::wstring fieldName, RFCTYPE RFCtype,
unsigned lengthNUC, unsigned lengthUC, unsigned offsetNUC, unsigned offsetUC) {
RFC_ERROR_INFO errorInfo;
RFC_FIELD_DESC pFieldDesc;
wcsncpy(pFieldDesc.name, fieldName.c_str(), 30);
pFieldDesc.type = RFCtype;
pFieldDesc.nucLength = lengthNUC;
pFieldDesc.ucLength = lengthUC;
pFieldDesc.ucOffset = offsetUC;
pFieldDesc.nucOffset = offsetNUC;
pFieldDesc.decimals = 0;
pFieldDesc.typeDescHandle = 0;
pFieldDesc.extendedDescription = NULL;
::RfcAddTypeField(typeDesc, &pFieldDesc, &errorInfo);
}