cancel
Showing results for 
Search instead for 
Did you mean: 

Java udf for deliveryd date

former_member452321
Participant
0 Kudos

Hi

I need some help on the writing java udf in PI . or it an be done in graphical mapping .I need to map the latest line item schedule delivery date from idoc source field  to target expected completion date

for example here is the source and target 

Source                                                                      Target
E1EDP2          0.99999                                           Controldetails


EDATU      --------->-                                               completiondate 1.1

     

       EDATU 08/20/2013
       EDATU  09/20/2013
       EDATU  10/05-2013 ------>                              completiondate              

       EDATu  09/02/2013

Thanks for your help

MK

Accepted Solutions (1)

Accepted Solutions (1)

Muniyappan
Active Contributor
0 Kudos

Hi,

check this if it is helping you.

do the settings as shown below in sort parameters.

Regards,

Muniyappan.

former_member452321
Participant
0 Kudos

Thank you very much . Yes. It is working as expected

Answers (3)

Answers (3)

former_member184789
Active Contributor
0 Kudos

Hi,

If u wish to have a UDF for this then add import instructions as shown below & have a UDF with all values of queue:

See it is working:

Here is the code:

try

{

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");

Date Stt = dateFormat.parse("00/00/0000");

for(int i =0;i<var1.length;i++)

{

   

Date TaskDate = dateFormat.parse(var1[i]);

if(TaskDate.after(Stt))

    Stt = TaskDate;

   

}

DateFormat df3 = new SimpleDateFormat("dd/MM/yyyy");

result.addValue(df3.format(Stt));

}

catch(ParseException p)

{

result.addValue(p.toString()); 

}

Hope this helps.

former_member452321
Participant
0 Kudos

Thank you Adarsh . This one also I tried and it is working .

Thanks

ambrish_mishra
Active Contributor
0 Kudos

Adarsh has given a good solution. Adding to that, you should convert the date to format YYYYMMDD a and after sort and collapse context, convert it back to the date format you want.

Ambrish

former_member184789
Active Contributor
0 Kudos

Hi,

You need to have a trick over here. As you are having date which can be 09/20/2012 & say 01/04/2013. You should first transform this date format into YYYY/MM/dd. After that you need to do sorting as shown below, followed by another Date transformation to have the date in original format:

As you are now sorting after transforming into format yyyy/mm/dd, you will always get the latest date, even if the years are different.