Metadata for structures/line-types
[Metadata and Repository API]


Detailed Description

Functions for creating, reading and traversing through structure descriptions.


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.
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.
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.
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.
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.
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.
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.
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.
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.


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] *name An (arbitrary) name for the type.
[out] *errorInfo Not 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] typeHandle The 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] typeHandle The type description.
[out] *count The number of (direct) fields of this structure.
[out] *errorInfo Should 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] typeHandle The type description.
[in] index The index of the field you are interested in.
[out] *fieldDescr Will be filled with field's description.
[out] *errorInfo Index 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] typeHandle The type description.
[in] *name The name of the field of interest.
[out] *fieldDescr Will be filled with field's description.
[out] *errorInfo No 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] typeHandle The type description.
[out] nucByteLength Total byte length in a non-Unicode system.
[out] ucByteLength Total byte length in a Unicode system.
[out] *errorInfo Should 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] typeHandle The type description.
[out] bufferForName Will receive the null-terminated DDIC name of the structure definition.
[out] *errorInfo Should 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] typeHandle The type description.
[in] nucByteLength Total byte length of the structure in a non-Unicode system (1 byte per CHAR).
[in] ucByteLength Total byte length of the structure in a Unicode system (2 bytes per CHAR).
[out] *errorInfo The 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


Generated on Fri Aug 29 16:54:53 2014 for SAP by  doxygen 1.5.5