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 |