Question:
I've a C++ application that can successfully call all standard SAP BAPIs through RFC. However we recently came across a custom BAPI whose import parameter is not a structure of simple types but also contains a table as a field.
Calling RFC_GET_STRUCTURE_DEFINITION_P I get the following info:
TABNAME ZSALES_ORDER
FIELD, POSITION, OFFSET, INTLENGTH, DECIMALS, E
VBELN, 1, 0, 10, 0, C
ERDAT, 2, 10, 8, 0, D
VBTYP, 3, 18, 1, 0, C
ITEMS, 4, 24, 8, 0, h
TRVOG, 5, 32, 1, 0, C
ERNAM, 6, 33, 12, 0, C
ITEMS itself is a table of a basic structure (plenty of fields, mostly strings).
How must I initalize the RFC_UNICODE_TYPE_ELEMENT entry for the field ITEMS to call RfcInstallUnicodeStructure and successfully call RfcCallEx afterwards?
I already tried an entry RFCTYPE_ITAB, but that simply terminated the software within the librfc with an SAP error "SYSTEM_TYPE_NOT_ELEMENTARY".
I also tried RfcGetStructureInfoAsTable(ZSALES_ORDER) to get some more info, but that one throws a "exception UNSUPPORTED_TYPE". Oh, and RFC_GET_UNICODE_STRUCTURE doesn't like that field either.
The RFCSDK Guide doesn't offer any help as all the import/export examples are for simple field types.
I'm going mad!
Ideas? Any input is greatly appreciated!
regards
Adrian
Answer:
Ok, I figured it out:
These kind of parameters are often refered to as "Deep Structures". If an importing/exporting parameter contains such a deep structure, the whole parameter will be transmitted as RFCTYPE_XMLDATA instead of RFCTYPE_STRUCTURE. See RFCTYPE_STRING example in RFCSDK documentation for more info about how to use variable length strings in RFC calls.
regards
Adrian
Answer:
Hello Adrian,
I'm trying to send a table as parameter as well. I do not get it working.
I'm using RfcAddExportParam and provide an it handle.
If i use Type = XMLDATA I'm getting 'CALL_FUNCTION_OBJECT_SIZE'
and if I use Type = ITAB I'm getting 'SYSTEM_TYPE_NOT_ELEMENTARY'.
Could you provide some code snippets how you solved this problem?
The RFCSDK says if a parameter has variable length it must be zero-terminated.... How can I zero-terminate a table???
./. P.
Answer:
So far I only implented the receiving part. The error SYSTEM_TYPE_NOT_ELEMENTARY points to the same issue though.
See chapter 5.1.3.1 in RFC Guide for an example (simply replace RFC_STRING with RFC_XMLDATA and RFCTYPE_STRING with RFCTYPE_XMLDATA).
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/RFCGUIDE.pdf
I however would try to pass the length too.
I didn't find any documentation about the XML format and reverse-engineered it from the SAP trace files. It's quite straight forward with identical attribute names as you would use in regular structures. Tables are encoded as follows:
<PARAMETERNAME>
<FIELDNAMEX></FIELDNAMEX>
<FIELDNAMEY></FIELDNAMEY>
<TABLENAME>
<item>
<FIELDNAME1></FIELDNAME2>
<FIELDNAME2></FIELDNAME2>
</item>
<item>
...
</item>
</TABLENAME>
</PARAMETERNAME>
I hope this helps.
regards
Adrian