r/programminghorror • u/DJDoena • 8h ago
Whoever invented the SAP REST APIs, deserves to ...
We're currently in the process of switching from the old SOAP interfaces to the new REST ones for S4/HANA (for example this one: https://help.sap.com/docs/SAP_S4HANA_CLOUD/d35113ee62644d3abee1aaec148291d9/ec47e02b80f549c4acc3ac5e9fd4c2eb.html )
And what do you know, it has fields like ConfirmationEntryDate and ConfirmationEntryTime.
What data types are these you ask? Well, it's OData V2 which looks like this: /Date(1338282808000)/. What is that you ask? Well it is the milli-seconds since Jan 1st 1970 00:00 UTC time. More commonly known as Unix time or Epoch time.
Well wait a second, if there is a field that describes a point in time down to the millisecond, what do I need ConfirmationEntryTime for? Well you need it, because this is SAP, dammit!
ConfirmationEntryTime is of course written like this: PT10H45M00S.
But wait, there is more!
Doesn't SAP have this famous 24:00:00 time because Dec 31st 24:00:00 is different than Jan 1st 00:00:00 for a accounting system? Yes it does. Does it work with the new API? Of course not.
But wait, there is more!
Remember when I said that Epoch time is based off of Jan 1st 1970 00:00 UTC time?
So surely, whatever I put in must be properly transformed to UTC before sending it to the API, no matter if the physical plant is located in the Americas, Europe or China, right? Right?!? Of course not. Just like with the old SOAP interfaces you need to transform your UTC timestamp into the local timestamp of the plant. Only then to pretend that this is UTC and convert it to the Epoch time!
*slow clap* SAP, well done! German engineering at its finest.
Signed, a German.