cancel
Showing results for 
Search instead for 
Did you mean: 

Check Date-Timestamp in Mapping

Former Member
0 Kudos

Hi,

I have a source message like:

<CustomerData>
<CustomerName>XYZCorp</CustomerName>
<Date>20110302153055</Date>
</CustomerData>

I need to validate the format of the Date field in mapping for:

1) Date format should be YYYYMMDD

2) Time format should be HHMMSS

3) The Date should be future Date (any valid date greater than current date).

If validation is success then Target NodeA should be created. If validation fails then target NodeB should be created.

How should this be coded in mapping? I assume that UDF would be required but which one?

Thanks

Pankaj.

Edited by: Pankaj Sharma XI on Mar 2, 2011 11:26 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I think this can be handled using the standard date function "Date Trans" (do remember to use HHMMSS

in the input and output selections) followed by one of the following "Date Before/ Date After/ Compare Date" with the "currentDate".

Just check one thing...what do you want to do if the date is not greater then current date !!

Former Member
0 Kudos

Hi,

what do you want to do if the date is not greater then current date !!

If date-time is greater than current date-time then NodeA should be populated

If the date-time is not greater than current date-time then NodeB should be populated in the target message.

<Target>

<NodeA/>

<NodeB/>

<Target/>

Thanks

Pankaj.

Former Member
0 Kudos

In addition to what i said in my previous message, you can use a boolen function "If" to achieve your requirement in point no. 3.

Please go ahead with the mapping and let us know if you face any problem while implementing the solution...

anupam_ghosh2
Active Contributor
0 Kudos

Hi Pankaj,

In your first post you made a remark as follows

"If validation is success then Target NodeA should be created. If validation fails then target NodeB should be created. "

In your second post you wrote

"If date-time is greater than current date-time then NodeA should be populated

If the date-time is not greater than current date-time then NodeB should be populated in the target message."

My question is are you creating NODE A and NODE B in target (in case their min occurence is zero)

or

The nodes NODE A and B will be always present in target but will be populated based on what is arriving in source?

The design of this mapping will depend a lot on your answer.

Secondly with what value you want to populate the node A and B. Is it the date itself? or some other error message in case of validation failure?

regards

Anupam

Edited by: anupamsap on Mar 2, 2011 1:22 PM

Edited by: anupamsap on Mar 2, 2011 1:25 PM

naveen_chichili
Active Contributor
0 Kudos

Hi Pankaj,

In date transformation only we have one option to get time stamp with mili seconds...you can choose manually to HH:mm:ss:SSS in your source format and transform to your target format .

we have one more option you can subtract the time and pass the date directly to the target.

Cheers!!!!

Naveen.

Edited by: chichilin on Mar 3, 2011 3:53 AM

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

First of all thanks for the support!

We have decided to go ahead with a JAVA logic (JAVA mapping/ UDF). The actual requirement is bit more complex. The sender can even send value like SAPCOMUSA123456 (any length - any format - any value) in the Date field (wierd but true). Accordingly PI has to decide which target node to generate. If a proper Date format with valid Date value (20110304235040 is a valid value as it is a future date) then generate NodeA. Otherwise NodeB.

So in my opinion (may be I am wrong) it is helpful to implement in JAVA. Let me check how will this work.

Thanks

Pankaj.

Former Member
0 Kudos

May be this blog can provide some help... have a look in case 3 & 5 in this blog.

/people/sarvesh.singh3/blog/2009/02/13/yes-it-is-possible-with-datetrans-function

Former Member
0 Kudos

Thanks Sarvesh but I dont think output of point 5 will be correct in your example...just run it with input (1999/03/01) and the reason being you can operate arithmatic functions on date as it has to follow calender .

Actually, we will have to use GregorianCalendar java class to achieve that kind of requirement.

Edited by: Puneet Singhal on Mar 2, 2011 12:33 PM

Former Member
0 Kudos

Ok.. thanks! I will test it and update the same if required.

samiullah_qureshi
Active Contributor
0 Kudos

Ask your sender system to send the date and time in required format.

For

3) The Date should be future Date (any valid date greater than current date).

You can easily achieve this using the CurrentDate and DateAfter standard function. You can fetch the date from input and then using DateAfter function u can compare whether it is in future.