Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Getting last/previous billing date

Former Member
0 Likes
651

Hi,

My current program gets all data based on the default date (in my case, the previous day's date, such that if today is 7/2, the program would get all daily movement data based on 7/1.)

However, say the program is ran on a Monday. The program has to be smart enough to not get data for sunday, of which there would be none. It would have to get friday's daily movement data. How do we get the previous billing date?

Also, say a week has a holiday. In that case, we would needed data from Friday and Saturday, if the report was executed on monday.

Please help.

All responses will be appreciated and rewarded.

Thank You,

John

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
601

Well John, what you need to do is apply your date to a calendar. See transaction SCAL. This transaction holds the calendars which have been setup for your company, there can be many which is the case for me. the trick is to know which one will work for you. Usually, there is one that will define what are working days in a company, which will define the weekend and holidays, then you can use this calendar id to adjust your date.

So say it is 7/1 and you subtract one from this date, of course it would be 6/30, which is a Sunday and not a working day, you would pass this 6/30 date to this function module and set the adjustment indicator to '-' which means the adjustment would be to go back as opposed to forward, this function would read the calendar and pass you back the next date that is a working day, what ever that may be in your system, saturday or sunday. The function module is.

DATE_CONVERT_TO_FACTORYDATE

Regards,

Rich Heilman

Hi,

My current program gets all data based on the default date (in my case, the previous day's date, such that if today is 7/2, the program would get all daily movement data based on 7/1.)

However, say the program is ran on a Monday. The program has to be smart enough to not get data for sunday, of which there would be none. It would have to get friday's daily movement data. How do we get the previous billing date?

Also, say a week has a holiday. In that case, we would needed data from Friday and Saturday, if the report was executed on monday.

Please help.

All responses will be appreciated and rewarded.

Thank You,

John

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
602

Well John, what you need to do is apply your date to a calendar. See transaction SCAL. This transaction holds the calendars which have been setup for your company, there can be many which is the case for me. the trick is to know which one will work for you. Usually, there is one that will define what are working days in a company, which will define the weekend and holidays, then you can use this calendar id to adjust your date.

So say it is 7/1 and you subtract one from this date, of course it would be 6/30, which is a Sunday and not a working day, you would pass this 6/30 date to this function module and set the adjustment indicator to '-' which means the adjustment would be to go back as opposed to forward, this function would read the calendar and pass you back the next date that is a working day, what ever that may be in your system, saturday or sunday. The function module is.

DATE_CONVERT_TO_FACTORYDATE

Regards,

Rich Heilman

Read only

0 Likes
601

So here is an example of the function call.



  call function 'DATE_CONVERT_TO_FACTORYDATE'
       exporting
            correct_option      = '-'
            date                = the_date
            factory_calendar_id = 'YT'
       importing
            date                = adjusted_date.

Regards,

Rich Heilman