on 12-15-2009 6:04 PM
Dear Friends,
I have to do one mapping for a element the requirement is as follows:
If the delivery date < system date + 1, then change the date to the system date + 1, else leave it as is.
Source : Delivery Date
Target : Shipping Date.
I need to Map Delivery date from Source to Shipping Date of Target element.
Kindly guide me how to do .
Renu
You can acheive your requirement by using DeliveryDate(src field), with Datefunctions(CurrentDate), Compare dates, & if-else conditions..
You need to use them appropriately as per ur requirement..
Regards,
Siva Maranani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Friemds,
How to write condition for my requirement. I am using standard functions Date.
In which i try to do the following:
Delivery Date -
>
Date Before -
> If Else condition---->
Current date -
>
How to add the logic now if Delivery date is less than Current date i need to increment the current date
Hi,
Write an UDF using the Calender class ... first compare the dates, and if it is not equal then increment the date as desired.
You can increment the date like this - CurrentDate.add(Calendar.DATE, 1)
I guess you need to use - import java.util.Calendar in your code.
Hope this helps.
Regards,
Neetesh
Hi Renu,
You have to write the UDF to compare the dates.
Java code for comparision of the dates
http://www.javafaq.nu/java-example-code-287.html
Java code to increment the date by one day
String dt = "2008-01-01";
dateSimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(sdf.parse(dt));
c.add(Calendar.DATE, 1);
By using this java code you can write the UDF.
Regards
Ramesh
Hi,
I think Comparing dates i can exeucte using standardr functions .
Delivery Date -
😆
Compare Dates -
> ur UDF ---> Target
Current Date -
>
Step 1:
I take sourece Dleivery date and Current date as input to Compare date and then o/p of compare date to UDF and then to Target.
Kindly tell me if i use your udf for increment the date will we get our requirement completed.
whne we use ur udf what are the step i need to do. Which cache i need to use : Value , Context or queue.
Kindly guide me step by step
Create UDF of type queue Cache (single value) with one argument 'a' ('a' is default argument in XI3.0)
(I am not v good in writing UDFs, but this I have tested, so it should work for you)
Note: The date format needs to be changed in UDF as per you current date format.
Imports: --java.util.Date;java.text.SimpleDateFormat;java.text.ParsePosition;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Date date = sdf.parse(a[0],new ParsePosition(0));
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, +1);
date = cal.getTime();
String output = sdf.format(date);
result.addValue( output );
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Date date = sdf.parse(a, new ParsePosition(0));
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, +1);
date = cal.getTime();
String output = sdf.format(date);
return output;
Now use this UDF in the above mapping which I suggested in my previous reply.. or you can see the exact mapping here..
http://www.flickr.com/photos/23639237@N02/4188605782/sizes/o/
UPDATE: I have modified the UDF code to increase it's performance. Now instead of using Queue, we are using Cache (Single Value). Rest verythis is as it is..
Regards,
Sarvesh
Edited by: Sarvesh Singh on Dec 16, 2009 2:15 AM
Hi Renu,
That is depend on the UDF type.
If we use the context or queue type UDF, here the output is result.addValue(" --output variable ---");
If you use the Value or simple UDF then the output is return "---- output value -
");
In this case Simple or Value UDF is enough, use the below code. I already checked its working fine.
Here dt is the input value. In your case If the date format is different then put that required format in the below code.
String output =null;
try
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(dt));
cal.add(Calendar.DATE, +1);
output = sdf.format(cal.getTime());
}catch(Exception e)
{
}
return output;
Regards
Ramesh
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.