Skip to Content
Author's profile photo Former Member

Dynamic Date Conversion in Message Mapping

To Convert Date Values in Message Mapping you can use the Standard DateTrans Function.
But what happens when the Date comes always in different format or the target date format depends on the Message Payload. Here is some Solution for this.

To handle such a Scenario we have to use a CustomerFunction. In this example we use a source structure with 3 fields.

image
DateType Source – The Source Structure of the Date (example: yyyy/MM/dd)
DateType Target – The Target Structure of the Date (example: dd.MM.yyyy)
Date – The Date Value

image
The CustomerFunction has 3 Arguments which we use in the function to convert the Date Value.
We have to import as well the java.text.* package for this function.
We use the SimpleDateFormat Class for the Transformation.

image

Customer Function:

With these basics it is possible to build complex Date Conversion scenarios.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Robin,

      It saves time for developers and beginners. Keep up the good work. Expecting more weblogs from you.

      ---Satish

      Author's profile photo Former Member
      Former Member
      hi,
      while i am executing it, following err is generated,
      followed as u depicted..

      C:/usr/sap/XI1/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mape13d2b607b8911dbcdd9001560a58e89/source/com/sap/xi/tmpl/_TEMPLATE_DATE_CONV_.java:51: ')' expected public void DATEFORMAT$(String[] DATETYPE SOURCE,String[] DATETYPE TARGET,String[] DATE VALUE,ResultList result,Container container){ ^ C:/usr/sap/XI1/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mape13d2b607b8911dbcdd9001560a58e89/source/com/sap/xi/tmpl/_TEMPLATE_DATE_CONV_.java:70: ';' expected } ^

      in the syntax of source code ';' and '}' is al done,

      pls help

      Author's profile photo Former Member
      Former Member
      hi,

      I am creating this as mapping template,
      is there any naming convention while creating the
      title of template,

      regards,
      Pratibha