cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Help - CompareDate UDF Function with True/False output.

Former Member
0 Kudos

Hi Gurus,

I have a scenario in MessageMapping where I want to compare 2 dates against 3rd date. Basically I am looking to input all three dates and compare two against the last one as shown below.

StartDate

InputDate

EndDate

I want to check,

StartDate = (or) < Inputdate

and

EndDate = (or) > Inputdate

I have used Standard CompareDates function with Fixvalue function to comeup with the solution. Since my Mapping is very complicated, I want to simplify this using UDF.

Appreciate any response. Thanks.

Regards,

Accepted Solutions (0)

Answers (2)

Answers (2)

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi,

before ussing a UDF, take in mind that SAP Best Practices recommend that first try to solve the mmaping ussing standard functiond and if not posible apply a UDF.

Thanks

Rodrigo P.

former_member192079
Participant
0 Kudos

Hi,

Use this code in ur UDF.

UdF input parameters are : StartDate ,InputDate ,EndDate .

code inside UDF

try {
                      
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            Date sd = df.parse(StartDate);
            Date id = df.parse(InputDate);
            Date ed = df.parse(EndDate);

            if ((sd.before(id) || (sd.equals(id))) && (ed.after(id)) || (ed.equals(id))) {
          return true;                
            }
else{
                return false;
            }
        }     catch (Exception e){
       e.printStackTrace();
	}

Regards

AR