cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate Fiscal Month

Former Member
0 Kudos

Hi Experts,

I have a requirement to calculate the Month and based on that Populate the target element.

Requirement Details:-

1)If the Store open date is Future Date or Blank date than it is a new Store.

2)If the Store Open Date  is falling in the first Monday or  other Monday than it is comp Store till 53 week it is Comp and next week it will change to non comp.

Ex 3rd Aug is Monday so if the store is open on 3rd Aug or any day on or before 31st Aug it will come in Aug Fiscal Month and Calculation of Fiscal Month will start from Aug.

If Store is 1st of Sept but Monday fall in Aug ie 31st Aug so this store will again fall in Aug Fiscal Month.For Sept Fiscal Month to start,it will start from

7th of Sept 2015.Any Store open before 7th Sept,it will fall in Aug Fiscal month.

I want to generate 54 Record from 1 record saying 1-53 week is comp and last Record will carry status as non comp.

Please suggest.

Regards,

Abhinav Verma

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Abhinav

1)If the Store open date is Future Date or Blank date than it is a new Store.

--> For this you can use the combination of AfterDate and Fixvalues to check if the Store is New Store or Old Store

2) For determining the Fiscal Month and COMP STORE you can use the below udf -

String month_from_date1 = "";

              try {

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

                     Calendar calendar = Calendar.getInstance();

                     calendar.setTime(format.parse(input));

                     String day_From_Date = Integer.toString(calendar.get(Calendar.DAY_OF_WEEK));

                    

                     if (day_From_Date.equals("2")){

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat(" COMP STORE");

                     }

                     else if (day_From_Date.equals("1")){

                           calendar.add(Calendar.DATE, -6);

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat("NON COMP STORE");

                           }

                     else if (day_From_Date.equals("3")){

                           calendar.add(Calendar.DATE, -1);

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat("NON COMP STORE");

                          

                     }

                     else if (day_From_Date.equals("4")){

                           calendar.add(Calendar.DATE, -2);

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat("NON COMP STORE");

                          

                     }

                     else if (day_From_Date.equals("5")){

                           calendar.add(Calendar.DATE, -3);

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat("NON COMP STORE");

                     }

                     else if (day_From_Date.equals("6")){

                           calendar.add(Calendar.DATE, -4);

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat("NON COMP STORE");

                           }

                    

                     else if(day_From_Date.equals("7")){

                           calendar.add(Calendar.DATE, -5);

                          String month_from_date2 = new SimpleDateFormat("MMM").format(calendar.getTime());

                                                            month_from_date1 = month_from_date2.concat("NON COMP STORE");

                     }

                    

                    

                                         }

             

              catch (ParseException e) {

                                                       e.printStackTrace();

                                                }

              return month_from_date1;

Former Member
0 Kudos

Kalyan,

It is thorowing Error.

can you please share the name of the class for this.

Former Member
0 Kudos

What is your  number Kalyan.

Former Member
0 Kudos

Hello Abhinav,

Import java.text* and try. Hope it works

Regards,

Kalyan

Answers (2)

Answers (2)

Former Member
0 Kudos

Urgent Requirement please help.

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Abhinav,

If possible, you can use RFC lookup to the custom FM in ECC system for this requirement, and get the required value from it. You can take the help of an ABAPer for writing a custom FM for this requirement, it will be easy to write this code in ABAP.

For RFC lookup:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40b64ca6-b1e3-2b10-4c9b-c48234cce...

If you don't want to go for the above one, then need to write a java udf for this.

Can you let us know which calendar,timezone etc parameters we need to use for validation purpose for the date coming in the source payload. Also, what should be the value of the udf, is it just month like AUG or 08 etc.

Former Member
0 Kudos

Hi Vishu,

Suppose date is coming in this format 2015-08-24.

Now this date which is coming it will have some value since this 25th is coming after 3rd Aug which is first Monday so that value will go in August Month calendar.If the date is coming as 2015-08-01 then which Saturday and Fisrt Monday is on 3rd Aug then this line item will go in July calendar.

Regards,

Abhinav

Harish
Active Contributor
0 Kudos

Hi Abhinav,

To get first monday of month, you need use the calander jar. Refer the below code to get the date for monday.

Calendar cal = Calendar.getInstance();
cal
.set(this.getYear(),getMonth(), 1);
int montag = cal.getFirstDayOfWeek();
for( int j = 0; j < 7; j++ ) {
  
int calc = j - montag;
  
if( calc < 0 ) {
  calc
+= 6;
  
}
  weekDays
[calc].setText(getDayString(calc));
}

iaki_vila
Active Contributor
0 Kudos

Hi Abhinav,

My few cents, normally a SAP ECC has configured the fiscal year inside and the calendar changes every year with the different holidays. Depending your scenario you can do a RFC lookup for example to take the day that you want. The RFC can have the logic that you want. To make all in PI you should have every year the calendar with the work days updated.

Regards.

Former Member
0 Kudos

Hi Inaki,

Scenario is File to file.We are not using any ECC here so all our calculation is in PI only.And we also don't knw what date user will input.

iaki_vila
Active Contributor
0 Kudos

Hi Abhinav,

In my opinion, the main problem is the store calendar, you need to know this information, is this information updated in any external system?,  if the answer is no, someone will need to update this calendar every year in PI or another system.

You can control easily via java UDF the control of the days that you have mentioned, but you need to know if the day is a holiday or not, and this can change every year.

Regards.

Former Member
0 Kudos

No Inaki,

Noone will maintain this calendar.We have to handle this in PI only.

Regards,