cancel
Showing results for 
Search instead for 
Did you mean: 

Edm.DateTime format and conversion error.

avishek_gorai2
Participant

Hi,

What is the correct way to define Date fieldsin Gateway services? I defined a field as Edm.DateTime in SEGW made it nullable but am getting runtime exception.

I tried defining a precision but then the runtime artifact generation fails saying Gateway field and RFC (DATS) field mapped to it are incompatible. Without precision the runtime artifacts are generated but failing at runtime with XML Serialization error.

Please let me know if we have to do anything special to map/define Date /DateTime fields of Gateway service.

Thanks,

Avishek.

P.S. We are on SP6 so hoping the earlier issues of SEGW mapping validation for DateTime fields is taken care of (Note: 1763390).

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor

Avishek,

Edm.DateTime (ABAP type Packed(11,7))should work fine.

Either define it using EDM Core type or define it using Pre. and Scale. Do not use both to avoid conflicts.

What is the runtime exception you are getting? and at while doing what?

Thanks

Krishna

avishek_gorai2
Participant
0 Kudos

Hi Krishna,

These are the errors loggoed against various cases:

GW Service Type        ABAP Type          Error

Edm.DateTime (0,0)     P(8,0)                    Value 734977 is not a valid date in accord with the XML format for ABAP

Edm.DateTime (0,0)     P(11,0)                  When converting the value 0.0 the values after the decimal place were lost

Edm.DateTime (0,0)     P(21,7)                  When converting the value 0.0 the values after the decimal place were lost

Edm.DateTime (21,7)   P(11,0)                  When converting the value 0.0 the values after the decimal place were lost

Edm.DateTime (8,0)     D(0,0)                   The argument 2013-04-18 cannot be interpreted as a number

Edm.DateTime (11,0)     D(0,0)                 The argument 2013-04-18 cannot be interpreted as a number

In the first case where the ABAP type is defined as P(8,0) the Service Builder is changing it to P(7,0) after saving.

Again the errors are not always consistent for each case even though I clear the cache Gateway system (/IWFND/CACHE_CLEANUP) before testing each call. However these are historically the errors I got.

Sometimes there is an XML conversion error and sometimes overflow error and for ABAP types DATE the date string is not being converted as a number.

Hope this gives some clue.

Thanks,

Avishek

kammaje_cis
Active Contributor
0 Kudos

Hi Avishek,

Try this.

Only give EDM Date time as the EDM Core type and do not give precision and scale.

After doing this clear the cache so that metadata gets refreshed. Check that the changes you performed are reflecting.

Then try the runtime and let me know the error.

Thanks

Krishna

avishek_gorai2
Participant
0 Kudos

Hi Krishna,

After using Edm.DateTime without precision and scale the error is always 'When converting the value 0.0 the values after the decimal place were lost' irrespective of the ABAP Type uesd (I checked with Date, Packed (8,0) and Packed (11, 0) .

Also did the cache cleanup and regenerated runtime objects everytime after changing. The change to the Edm.DateTime field was reflected in the MPC class.

Regards,

Avishek.

former_member184867
Active Contributor
0 Kudos

Hi Avishek.,

why would you have 0.0 value in the date field? Is it not possible to stop this kind of values getting populated?

Regards,

Atanu

Answers (9)

Answers (9)

grabz
Employee
Employee
0 Kudos

If anyone else would face similar issue, then I suggest to proceed with this KBA:

2819936 - Check Project Consistency button in SEGW results in numerous warnings and/or error messages

mike_reader3
Active Participant
0 Kudos

Hey Guys,

Came across this post and it helped me out with a service I was building, long story short, I had to rebuild the service due to a system refresh and now I am having the same issue but cannot resolve it with the tips above, here is my setup (I have tried clearing the cache with /iwfnd/cache_cleanup) :

mike_reader3
Active Participant
0 Kudos

same thing happens with internal type:

former_member182874
Active Contributor
0 Kudos

Internal type :

Date of Length 8.. why 0 ?

And make sure data type of BAPI and Model is same i.e ; DATS

Regards,

Tejas

mike_reader3
Active Participant
0 Kudos

Thanks for the reply Tejas ... I am not sure what was wrong with the service I built but it would not let me change the length of the DATE field from 0 and as for the BAPI - that data element is typed as DATS.

Long story short, I rebuilt the service and everything seemed to fall into place.  Very odd.

Former Member
0 Kudos

The length of the DATE type is implied as 8, so you cannot set it (it's greyed out)

Former Member
0 Kudos

Serves you right for mapping to BAPI

mike_reader3
Active Participant
0 Kudos

Ron,

Maybe you can answer this, I am attaching two screen shots, the first from when the mapping "worked" and the second when it didn't - as you can see the boxes have different options - not sure what caused the ABAP type editor to be different in the 2nd case (the broken one).

Worked

Broken

Former Member
0 Kudos

This probably isn't where the issue is. The project isn't the service it's a representation of what should be generated and can be 'off'. There have been issues with MPC generation and the types that have been declared. I recall that I found that my dates had been generated with type P(8) instead of D (or even N(8) / C(8) ). Any of those would have worked but P(8) is very wrong. When I manually corrected it the service came back to life... until regenerating.

But seriously, do yourself a favour and stay away from FM mapping. If you are a developer at heart you'd probably appreciate code based implementation and the amount of control it gives you (and actually less work in real terms).

Cheers

Ron.

mike_reader3
Active Participant
0 Kudos

Thanks Ron,

The example I sent was my first crack at it, I am going to give the Code Based implementation a shot as I have been playing around with it a bit.

-Mike

Former Member
0 Kudos

Hi, can you tell my why i cent set the data type DATS in the ABAP EDITOR. See pic below:

Everything is uneditable:/

Former Member
0 Kudos

Some pointers about dates posted here.

http://scn.sap.com/thread/3441583

Former Member
0 Kudos

Avi, you are a rock star!

I have been battling with this the whole day and after reading your post and making the suggested changes my dates are working fine.

Thank you for actually coming back and posting the solution you found.

Rodney

avishek_gorai2
Participant
0 Kudos

Hi Krishna, Atanu, Abhishek and Alexandre thank you for your help.

I was able to resolver this by using the ABAP Type for the Date fields as DATS in the GW service definintion. However I had to create a new scenario and it worked and magically even some of the older scenarios also started working (which it was not earlier). Earlier, irrespective of whatever I did the data cache in GW was not clearing (and same error thrown again and again), I tried ICM cache clear, REST clint history deletion, GW metadata cache but no respite, but all of a sudden after I created this new scenario things started working.

Anyways all is good now for DATE and TIME fields. Thanks once again for your help.

Solution used in Brief:

Define ABAP Type for DateTime fields as DATS (or TIME) in Gateway Service builder.

Thanks and Regards,

Avishek.

Former Member
0 Kudos

Dear Avishek

You have saved me hours of investigation!

Many thanks for sharing your solution.

Mike

Former Member
0 Kudos

Avishek Gorai wrote:

.....
Define ABAP Type for DateTime fields as DATS (or TIME) in Gateway Service builder
......

Sorry for my question, but where do you define the ABAP type in SEGW?

I can't find it.


Regards
Aikon

Former Member
0 Kudos

Hi Aikon.

Click on your Entity Type.

Open the Properties Folder and select the Property that you want to change.

In the displayed table there is a "Abap type" button second column from the right.

There you can select the abap type.

Good luck.

Rod

avishek_gorai2
Participant
0 Kudos
avishek_gorai2
Participant
0 Kudos

Former Member
0 Kudos

thanks for the feedback

In the binding I still got an error, that says "Data source attribute ERDAT and model porperty Erdat have different types".

My dataproperty has the datatype DATS (type is ERDAT)

My model property has datatype DATS

Any idea, whats wrong?


Thanks


Aikon

avishek_gorai2
Participant
0 Kudos

Hi Aikon,

i think in this case you have to use Internal Type and Date. Try the following...

Former Member
0 Kudos

Hi Avishek

I have tried, but still error - please see my screendumps

And the error (and erdat definition):

avishek_gorai2
Participant
0 Kudos

Hi Aikon,

Please define Gateway service field 'Erdat' as Edm.DateTime (without any presion, scale or length) instead of Edm.String as currrently done.

Regards,

Avishek.

Former Member
0 Kudos

Thanks, that did it

Abhijit
Explorer
0 Kudos

Thanks for taking efforts to put detailed information with screenshots 🙂

Former Member
0 Kudos

Hi Avi,

i just followed the same steps u mentioned. I have my gateway type as Edm.Datetime and in abap it is Dats and maintained the ABAP Type internal type to D ( and tried with data element to Dats). I am able to generate the runtime artifacts without issues.. but in run time getting error saying in Error Log.

any other changes required while populating the data? Please suggest.

..ERROR_INFOInvalid format (return table): Row Number 1,  Property Name 'EarlyStartDt',  Property Value '00000000'
former_member182874
Active Contributor
0 Kudos

Check this property as nullable in Entity type

Former Member
0 Kudos

HI Tejas,

thanks for the quick reply.. i checked to nullable it don't give the dump but it is not giving the value in the screen even though it has value. It shows as below.

<d:EarlyStartDt m:null="true"/>

former_member182874
Active Contributor
0 Kudos

yes, is that field required in the GET ? I hope you are posting it so POST will be updating . You can check in the backend if the date is updated.

Former Member
0 Kudos

My mistake.. it is working after making it to nullable. ( i dint check the right value before..sry )..

Thanks a lot Tejas.

Former Member
0 Kudos

Hi Avishek,

I suppose that you are in the Central hub deployment scenario, creating your model on the Gateway system ?

If you have installed IW_BEP on the backend system as well, can you try to create your model in the backend system ?

Regards,

Alexandre

Former Member
0 Kudos

look avishek in the backend you have to define it as DATS and while testing on Rest client pass it as (im_date=datetime'2013-06-12T00:00:00'), even while u r passing using xml pass it as

<d:im_date>2012-06-06T00:00:00</d:im_date>

avishek_gorai2
Participant
0 Kudos

Hi Experts,

I am still not able to solve this, any inputs will be highly appreciated. I went through this SAP help page and tried all the suggestions but no success.

I Tried to define the ABAP Type as Date, Packed (15,0), Packed(11,7), Packed(21,7) but none of them worked. Another strange issue I faced in SEGW; I could not define ABAP Type for the DateTime field as Packed(8,0) by default the editor changes it to Packed(7,0) after saving the Entity definition.

Really lost trying to resolve this now.

Thanks,

Avishek.

avishek_gorai2
Participant
0 Kudos

Any inputs on this, still could not solve this inspite of trying our various things.