cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping to Target field

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Siva,

can you give me the mapping for this requirement

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

HI ,

Does UDF is only way to execute this requirement? If so kindly guide me how to write UDF for this requirement.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Renu,

simple UDF is enough, means Value UDF

Use this java code to add one day to the existing date

dateSimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Calendar c = Calendar.getInstance();

c.setTime(sdf.parse(sysdt));

c.add(Calendar.DATE, 1);

return c;

Regards

Ramesh

Former Member
0 Kudos

Use the UDF as mentioned above to increase the date by one day, then use the std func "DateAfter".

CurrentDate --UDF ---|
                      DateAfter--------equalS (true)---- If ---- Then (CurrentDate -->UDF ) 
   DeliverDate-------|

Else (Delivery Date) --- Target.

Former Member
0 Kudos

Hi ,

After comparing the dates with standard function how to pass the value to ur udf.

Kindly guide me.

Former Member
0 Kudos

Sravesh,

How can i pass current date value to that UDF.Kindly guide what are the arguments i need to add in UDF when i copy the code i am not able to pass the cuurent date input to UDF.

Kindly tell how to do it

Former Member
0 Kudos

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

Former Member
0 Kudos

if(delivery_date)

. ................................ DateAfter--


equalS (true)-- If -


Then UDF output else delivery_date output

sys_date input to UDF

Regards

Ramesh

Former Member
0 Kudos

Hi sarvesh,

Thank you so much for ur efforts it is working fine but i still i use Cache queue. Kindly tell me if i use cache value result list is not coming.

former_member200962
Active Contributor
0 Kudos
Kindly tell me if i use cache value result list is not coming.

resultList will be available when Execution Type of the UDF is selected as All values of a Context or All values of Queue i.e. for Advanced UDFs.

Regards,

Abhishek.

Former Member
0 Kudos

Exactly, as correctly said by Abhishek while creating your UDF if you choose the radio button Context or Queue then you will be able to use result list.

Regards,

Sarvesh

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Venkat,

I really thank you for ur efforts to make me to undertand. I like undertsatnd more on Resutllist and addvalue. I will search in forums first then i will disturb you guys.

Renu

Answers (0)