SAP NetWeaver RFC SDK 7.50
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Metadata for structures/line-types

Functions for creating, reading and traversing through structure descriptions. More...

Functions

DECL_EXP RFC_TYPE_DESC_HANDLE
SAP_API 
RfcCreateTypeDesc (SAP_UC const *name, RFC_ERROR_INFO *errorInfo)
 Creates an empty type description with the given name. More...
 
DECL_EXP RFC_RC SAP_API RfcAddTypeField (RFC_TYPE_DESC_HANDLE typeHandle, const RFC_FIELD_DESC *fieldDescr, RFC_ERROR_INFO *errorInfo)
 Adds a new field to the type description. More...
 
DECL_EXP RFC_RC SAP_API RfcSetTypeLength (RFC_TYPE_DESC_HANDLE typeHandle, unsigned nucByteLength, unsigned ucByteLength, RFC_ERROR_INFO *errorInfo)
 Sets the total byte length of the type description. More...
 
DECL_EXP RFC_RC SAP_API RfcGetTypeName (RFC_TYPE_DESC_HANDLE typeHandle, RFC_ABAP_NAME bufferForName, RFC_ERROR_INFO *errorInfo)
 Returns the name of the type. More...
 
DECL_EXP RFC_RC SAP_API RfcGetFieldCount (RFC_TYPE_DESC_HANDLE typeHandle, unsigned *count, RFC_ERROR_INFO *errorInfo)
 Returns the number of fields in a structure definition. More...
 
DECL_EXP RFC_RC SAP_API RfcGetFieldDescByIndex (RFC_TYPE_DESC_HANDLE typeHandle, unsigned index, RFC_FIELD_DESC *fieldDescr, RFC_ERROR_INFO *errorInfo)
 Reads the field description of the structure's ith field. More...
 
DECL_EXP RFC_RC SAP_API RfcGetFieldDescByName (RFC_TYPE_DESC_HANDLE typeHandle, SAP_UC const *name, RFC_FIELD_DESC *fieldDescr, RFC_ERROR_INFO *errorInfo)
 Reads the field description of a field given by name. More...
 
DECL_EXP RFC_RC SAP_API RfcGetTypeLength (RFC_TYPE_DESC_HANDLE typeHandle, unsigned *nucByteLength, unsigned *ucByteLength, RFC_ERROR_INFO *errorInfo)
 Returns the total byte length of a structure definition. More...
 
DECL_EXP RFC_RC SAP_API RfcDestroyTypeDesc (RFC_TYPE_DESC_HANDLE typeHandle, RFC_ERROR_INFO *errorInfo)
 Deletes the type description and releases the allocated resources. More...
 

Detailed Description

Functions for creating, reading and traversing through structure descriptions.

Function Documentation

DECL_EXP RFC_RC SAP_API RfcAddTypeField ( RFC_TYPE_DESC_HANDLE  typeHandle,
const RFC_FIELD_DESC fieldDescr,
RFC_ERROR_INFO errorInfo 
)

Adds a new field to the type description.

Note
After a type description has been used (e.g. via RfcCreateStructure(), RfcCreateTable() or RfcAddTypeDesc()), it can no longer be modified!
Parameters
[in]typeHandle
[in]*fieldDescr
[out]*errorInfo
Returns
RFC_RC
DECL_EXP RFC_TYPE_DESC_HANDLE SAP_API RfcCreateTypeDesc ( SAP_UC const *  name,
RFC_ERROR_INFO errorInfo 
)

Creates an empty type description with the given name.

API for creating hard-coded metadata descriptions, e.g. for function modules that don't exist in the R/3 backend. Add field descriptions to the type description using RfcAddTypeField() and at the end set the total byte length of the structure using RfcSetTypeLength().

Warning
It is not easy to get the total length right, as you also need to take alignment bytes into account...

Finished type definitions can then be used for creating data containers (RfcCreateStructure() or RfcCreateTable()) and for adding field/table descriptions to a function module description (in RFC_PARAMETER_DESCs in RfcAddParameter()).

After the handle was used for creating a container, any modifications are forbidden.

Parameters
[in]*nameAn (arbitrary) name for the type.
[out]*errorInfoNot enough memory?
Returns
The new type description.
DECL_EXP RFC_RC SAP_API RfcDestroyTypeDesc ( RFC_TYPE_DESC_HANDLE  typeHandle,
RFC_ERROR_INFO errorInfo 
)

Deletes the type description and releases the allocated resources.

Only descriptions, which are not stored in a repository cache and not used by the application, can be deleted. Deleting a cached description will cause an error, and deleting a description that is still in use, will lead to a crash.

Parameters
[in,out]typeHandleThe type description to be deleted.
[out]*errorInfo
Returns
DECL_EXP RFC_RC SAP_API RfcGetFieldCount ( RFC_TYPE_DESC_HANDLE  typeHandle,
unsigned *  count,
RFC_ERROR_INFO errorInfo 
)

Returns the number of fields in a structure definition.

Parameters
[in]typeHandleThe type description.
[out]*countThe number of (direct) fields of this structure.
[out]*errorInfoShould always return successfully...
Returns
RFC_RC
DECL_EXP RFC_RC SAP_API RfcGetFieldDescByIndex ( RFC_TYPE_DESC_HANDLE  typeHandle,
unsigned  index,
RFC_FIELD_DESC fieldDescr,
RFC_ERROR_INFO errorInfo 
)

Reads the field description of the structure's ith field.

Useful mostly when looping over the fields of a structure.

Parameters
[in]typeHandleThe type description.
[in]indexThe index of the field you are interested in.
[out]*fieldDescrWill be filled with field's description.
[out]*errorInfoIndex out of bounds?
Returns
RFC_RC
DECL_EXP RFC_RC SAP_API RfcGetFieldDescByName ( RFC_TYPE_DESC_HANDLE  typeHandle,
SAP_UC const *  name,
RFC_FIELD_DESC fieldDescr,
RFC_ERROR_INFO errorInfo 
)

Reads the field description of a field given by name.

Parameters
[in]typeHandleThe type description.
[in]*nameThe name of the field of interest.
[out]*fieldDescrWill be filled with field's description.
[out]*errorInfoNo such field?
Returns
RFC_RC
DECL_EXP RFC_RC SAP_API RfcGetTypeLength ( RFC_TYPE_DESC_HANDLE  typeHandle,
unsigned *  nucByteLength,
unsigned *  ucByteLength,
RFC_ERROR_INFO errorInfo 
)

Returns the total byte length of a structure definition.

Parameters
[in]typeHandleThe type description.
[out]nucByteLengthTotal byte length in a non-Unicode system.
[out]ucByteLengthTotal byte length in a Unicode system.
[out]*errorInfoShould always return successfully.
Returns
RFC_RC
DECL_EXP RFC_RC SAP_API RfcGetTypeName ( RFC_TYPE_DESC_HANDLE  typeHandle,
RFC_ABAP_NAME  bufferForName,
RFC_ERROR_INFO errorInfo 
)

Returns the name of the type.

Parameters
[in]typeHandleThe type description.
[out]bufferForNameWill receive the null-terminated DDIC name of the structure definition.
[out]*errorInfoShould always return successfully...
Returns
RFC_RC
DECL_EXP RFC_RC SAP_API RfcSetTypeLength ( RFC_TYPE_DESC_HANDLE  typeHandle,
unsigned  nucByteLength,
unsigned  ucByteLength,
RFC_ERROR_INFO errorInfo 
)

Sets the total byte length of the type description.

Before a type description can be used, this function needs to be called. The RFC library does not automatically calculate the correct length based on the fields that have been added, because this task is non-trivial and possibly platform dependend. (Especially if the structure contains sub-structures.)
For integer and floating point types the correct alignments need to be taken into account (start address divisible by 4 or 8), fixed sub-structures are inlined, complex structures are referenced by an 8-byte pointer, etc. In general you will need to do a bit of trial and error, before you get it right.
If you really need more details/tips for the process of hardcoding metadata, see this article.

Parameters
[in]typeHandleThe type description.
[in]nucByteLengthTotal byte length of the structure in a non-Unicode system (1 byte per CHAR).
[in]ucByteLengthTotal byte length of the structure in a Unicode system (2 bytes per CHAR).
[out]*errorInfoThe function returns an error, if the given byte lengths are smaller than the sum of all field lengths, or if the nucByteLength is smaller than the ucByteLength.
Returns
RFC_RC