Tuesday, August 31, 2010

Date formats in SAP and Inverted date format

People doing integrations with SAP R/3 system must be aware that SAP R/3 takes in/out date fields with format of YYYYMMDD (This is their internal date format). However there is a special date format called Inverted date which is used to store some date fields in SAP tables.

If you work on Currency Exchange Conversions (TCURR table) the Date Field (GDATU) stores date in Inverted date format. So what exactly is this Inverted date format and how can you convert it to normal date format of YYYYMMDD which can be later used in your integration.

Inverted date is nothing but the 9's complement of the real date. In other words the conversion logic will be something as shown below

99999999 – (GDATU) = actual date in yyyymmdd format
Example: 99999999 – 79899168 = 20100831

There are conversion exits in ABAP which does this date conversion like CONVERSION_EXIT_INVDT_OUTPUT -- Conversion exit routine for inverted date (OUTPUT)

However if your SAP BAPI gives you data in inverted date format you can use the logic mentioned above in your BPEL/XSL at Fusion layer to convert it into actual date format.

1 comment:

  1. Thank you! It seems so obvious (if archaic) in retrospect.

    ReplyDelete