After creating an oData service (with trx SEGW) for notifications my collegae (functional consultant) asked me if the time could also be filled in the output of the service. The service already showed the date and time but the time was always shown as 00:00:00, i thought that this would not be that hard….

After searching the net and trying several possible solutions for a day i got it to work. Because i could’nt find it all in one place i will make an effort to bring this together (also being my first blog).

How did i create my initial oData service?

At first i created a view that i imported as a structure in SEGW. Very soon i discoverd that this is not the way to go because now the oData service is very tight coupled to the fields of the database view. So i created a structure with the desired fields, containing some date fields (type dats).
After generating the runtime objects and implementing the …_get_entityset method of the Data Provider Secondary Class the oData service worked fine, except for the fact that the time fields were always shown as 00:00:00 in the oData service (for the obvious reason that the dats fields were mapped to these ….datum fields).

Result at this time was:

Definition in SEGW at this time was:

Abap type editor for field Storingsdatum:

How did i change my oData service?

After some searching i discoverd that i should change the data type in the abap type editor but this was not possible, reason for this was the fact that i imported the fields from an abap structure. After removing the abap structure type name (zspm_wpb_meldingen) in the entity type i was possible to get the abap type editor in change mode.

Now change the mode to ‘Explicit Assignment’, the category to ‘D Data element’ and the associated type to Timestamp. To get it to work i also changed the Edm core type to Edm.DateTimeOffset (the Edm.DateTime just wouldn’t work).

After this the code in the method …get_entityset must be changed beacuse the field Storingsdatumtijd is now of type timestamp. In the abap code the timestamp must be filled with the date and time (i’m using the fm  ‘ABI_TIMESTAMP_CONVERT_INTO’  for this ).

After these changes (and clearing buffers and/or (de)activating service) i got the time in the storingsdatum field:

… after writing this blog i’m wondering if it all would have worked from the start if i had added the timestamp field in the structure that i imported … to be continued.


To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Manuel Garcia

    I’m using  the same kind of element, but I’m using the function

    My structure

    begin of TS_YEAR_WEEK,
    PABRJ type length 4,
    PABRP type length 2,
    end of TS_YEAR_WEEK

    DATA: ls_entity  LIKE LINE OF et_entityset.

    DATA: lv_currday  TYPE sydatum.
    DATA: lv_beguz     TYPE syuzeit.

    lv_currday is the variable with the day to show and  lv_beguz the time, in my case I read the employee daily work schedule

    i_datlo     lv_currday
    i_timlo     lv_beguz “ls_hrdws-beguz
    i_tzone     ‘UTC’
    e_timestamp ls_entitycreated_at.


    1. Erik Mertens Post author

      Hi Manuel,

      After writing this blog i wondered if a different approach would solve my problem. This time i started with the date/time field already defined in the (se11) structure that i import in segw. So my structure looks like this:

      type of the field is: TIMESTAMPL


      After import of this structure the entity in segw looks like this:

      Now i can simply fill the timestamp field in the method of the provider class.

      Long story short: start with the timestampl type in the (SE11) structure.

  2. Erik Mertens Post author

    As mentioned i tried a different approach. So i made a structure with a field of type timestamp and imported this structure in segw. Created the supply methods and that worked right away. My lesson learned: start with the appropriate type in the structure that gets imported!


Leave a Reply