cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI: How can i store First day of previous month in Groovy script

0 Kudos
755

Hi Experts,

I have requirement to store the first day of previous month in property and utilise in query to filter out the terminated EE

from firstdayof previous month to till date.

Please help me to provide groovy scripts

Regards,

A Raheem

Accepted Solutions (1)

Accepted Solutions (1)

YuvrajKarwar
Explorer

Hello Abdul,

Use below groovy script.

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.*;
import java.text.SimpleDateFormat;  
    
def Message processData(Message message) {
     Calendar c = Calendar.getInstance();
     SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
     def todaysDate=formatter.format(c.getTime())
     c.add(Calendar.MONTH,-1);
     def startOfLastMonth="01"+formatter.format(c.getTime()).substring(2)
     message.setHeader("todaysDate", todaysDate");
     message.setHeader("startOfLastMonth", startOfLastMonth");


}

Hope this helps!

0 Kudos

Thanks Yuvraj, i just modified this and it works for me.

Regards,

Abdul.

Answers (0)