Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Date Field Mapping

Hi All,

I have requirement like below:

I have 2 date fields in sender and 2 date fields in receiver.

I need to populate last day of the previous month in first date field and last day of the current month in second date field.

Is it possible via graphical mapping? then any one suggest with screen shot.

or else we need to create UDF?

if it is UDF please paste the UDF Code...

Thanks & Regards,

Vishnu Pallamreddy.

replied

Hi Vishnu,

Try this:

public String lastDayPreviousMonth(Container container) throws StreamTransformationException{

Calendar aCalendar = Calendar.getInstance();

// add -1 month to current month

aCalendar.add(Calendar.MONTH, -1);

// set actual maximum date of previous month

aCalendar.set(Calendar.DATE,     aCalendar.getActualMaximum(Calendar.DAY_OF_MONTH));

String strdate = null;

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

if (aCalendar != null) {

strdate = sdf.format(aCalendar.getTime());

}

return strdate;

}

I get:

For the current month you can do a similar UDF without the line :

aCalendar.add(Calendar.MONTH, -1);

Regards.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question