Show TOC

Mappings and ABAP Type EditorLocate this document in the navigation structure

Defines additional type information about properties using ABAP Type Editor and the corresponding ABAP field names and facilitating mapping between ABAP type and EDM type

Introduction
Use the ABAP Type Editor to define additional type information about properties and the corresponding ABAP field names. To facilitate the mapping between ABAP type and EDM type, you can select the determination mode, Structure Binding at Entity or Complex Type, Explicit Assignment or Determination by Runtime Object Generator, that is to be used.

If you choose Structure Binding at Entity or Complex Type , system assigns an ABAP structure to the entity or complex type as appropriate. The automatic ABAP type assignment is derived from the EDM type. You can assign an ABAP structure at entity type or complex type level, but not at the level of the individual properties.ABAP structure assigned is subsequently used by the generator. If an ABAP structure is not assigned at design time, the generator generates a new structure based on information displayed.

If you choose Explicit Assignment, you can maintain the category and subsequently the fields that are applicable for this category become ready for input. Fields that are not applicable remain read only. Use the explicit assignment if you specifically do not want an automatic assignment to take place. Note that structure binding overwrites any explicit assignments that have been maintained.

Exact correlations between ABAP types and EDM types are not always possible due to their individual facets and the automatic determination of a corresponding ABAP or EDM type might not be a perfect match. Consequently, you must always review determined type mappings to ensure that you choose the best match possible. The Service Builder includes a validation check that determines possible inconsistencies and appropriate warning messages are displayed so that you can prevent the loss of data that might otherwise arise through the mapping of ABAP type to EDM type and/or vice versa. The check distinguishes between potential loss of data, possible conversion errors, and the applicability of ABAP types.

Mapping ABAP Types and EDM Types
The following example focuses on ABAP Datetime handling for properties with Edm.Datetime as just one example where inconsistencies can arise when mapping ABAP types and EDM types. For the Edm.Datetime property, in the backend, an ABAP field can be represented as a simple date or timestamp with fractional seconds or a timestamp without fractional seconds. Consequently, a property in the Service Builder with the EDM type Edm.Datetime, requires additional information to map this EDM type to the correct ABAP field type in the backend. If this is not done correctly, wrong type assignments are the result. Correct type assignments are required for MPC generation as the DPC implementation is based on generated types in the MPC class. The original solution to achieve this in the Service Builder was:
  • If precision = 0 & scale = 0, then internal type is type D. If precision = 8 & scale = 0, then internal type is type P length 8 decimals 0 (timestamp without fractional seconds)
  • If scale = 7, then internal type is type P length 11 decimals 7 (timestamp with fractional seconds)
Instead of using the precision and scale attributes in the above example, you can use the ABAP Type Editor in the Service Builder to set the internal type directly. In the ABAP Type Editor, you can set the category manually as Internal Type and:
  • Type Kind = Date, Length = 8, Decimals = 0 (Simple Date, internal type D)
  • Type Kind = Packed, Length = 15, Decimals = 0 (timestamp without fractional seconds, internal type displayed in MPC as type P length 8 decimals 0)
  • Type Kind = Packed, Length = 21, Decimals = 7 (timestamp with fractional seconds, internal type displayed in MPC as type P length 11 decimals 7)
Alternatively, you can use the ABAP Type Editor to assign a data element to a property. In the ABAP Type Editor, you can manually set the category as Date Element and enter the data element name in the Associated Type field. When using an RFC/BOR import or assigning a DDIC type, if the structure is assigned to the parent artifact (entity type or complex type), then no assignment is made at property level. When using the Import from DDIC Structure option, the date fields are handled in the following way:
  • If the field’s domain is of type ‘TZNTSTMPS’ then Timestamp without fractional seconds, internal type in MPC is type P length 8 decimals 0
  • If the field’s domain is of type ‘TZNTSMPl’ then Timestamp with fractional seconds, internal type in MPC is of type P length 11 decimals 7
Refer to the following EdmType usage and conversion to backend ABAP type.
EDM Primitive Type XML Representation ABAP Representation ABAP Type
Edm.Binary binary Binary XSTRING, HEX
Edm.Boolean booleanLiteral Boolean CHAR LENGTH 1
Edm.String string.Literal STRING STRING, CHAR, NUM
Edm.Guid guidLiteral Guid CHAR LENGTH 32, HEX LENGTH 16
Edm.Byte byteLiteral Byte INT1, INT, NUM, HEX, LENGTH 1
Edm.SByte sbyteliteral Integer (1 byte) INT2, INT, NUM
Edm.Int16 int16Literal Integer (2 byte) INT2, INT, NUM
Edm.Int32 int32Literal Integer (4 byte) INT, NUM
Edm.Int64 int64Literal Integer (8 byte) PACKED LENGTH 8 DECIMALS 0, NUM
Edm.Decimal decimalLiteral Decimal PACKED, DECFLOAT16, DECFLOAT34
Edm.Double doubleLiteral Double FLOAT
Edm.Single singleLiteral Single FLOAT
Edm.Float singleLiteral Single FLOAT
Edm.DateTimeEdm.DateTimeOffset dateTimeLiteral DateTime as Timestamp PACKED LENGTH 8, DECIMALS 0, PACKED LENGTH 11, DECIMALS 7
DateTime as Date DATE
DateTime as Time TIME
Edm.DateTimeOffset dateTimeOffsetLiteral DateTimeOffset as Timestamp PACKED LENGTH 8, DECIMALS 0, PACKED LENGTH 11, DECIMALS 7
Edm.Time timeLiteral Duration in seconds PACKED, DECFLOAT16, DECFLOAT34
Duration as Time TIME
Note If an ABAP structure is bound to an entity type, then the entity type properties refer to the ABAP structure’s element types. The properties should have the same ABAP name as the element name of the ABAP structure. When using Datetime and its related properties as an optional field, set the attribute Nullable to true.
Constraint
XML Schema Definition (XSD) types are not supported by SAP Gateway run-time for Property and Function Import Parameter. If Property or Function Import Parameter is mapped with XSD ABAP data type, for example: XSDANY, XSDBOOLEAN, the Service Builder displays an error message during consistency check. You can change the ABAP data type inAssociated type field in ABAP Type Editor dialogue box of Properties or Function Import Parameter.