Related questions

3 Answers

You could do this in the routine by checking on the last 2 characters of your date, in this case SY-DATUM+6(2). When "less or equal" than 5, take previous month, otherwise take this month.

A better solution (in my opinion) would be to work with a "decision step" in the process chain (which checks on the day) and have 2 DTPs ready. In this case when your "number of days" should change, you simply need to modify the process chain (instead of changing the routine) and it's "visually" more clear what happens.

Add comment

I used SY-DATUM+6(2) working with some "hard codes" according the situation (last month or current day) and it's working perfectly! I thought to use a decision step in my PCs, but as all of my process are automatics, with a lot of steps, jobs, etc (well I think I created a monster), I was afraid concerning the consequences in case of an error.

You're currently selecting everything between <the first day of this month > and <the last day of the previous month> which doesn't make sense. So your low value should be the first day of the previous month...

Also, when you need to change "dates" you could use function module RSARCH_DATE_SHIFT (instead of the string manipulation you're currently doing).

Alert Moderator

Add comment

I'm selecting everything between <the first day of the current month> and <the "day before today" (day-1) of the current month> during the current month. I've two problems in my routines:

- I never have data from the last day of the month. No matter if the month ends on 28/29, 30 or 31, I never load registers from this day because the next day is the first day of the new month, so my routine works in this new month.

- The first day of the month is a day without registers. As I'm selecting everything between <the first day of the current month> and <the "day before today" (day-1) of the current month>, in the day 1 what I'll select? Nothing.

These two routines are working for me, but I've to create another one to cover up these "gaps".

so your goal is to load "month to date" figures? but you have a "special" behaviour for the 1st day of the month... the question is: what do you want then? just 1 day? or the entire previous month? when you know the answer to this question, we can proceed.

Alert Moderator

Add comment

Hello Raf,I think I'm not clear enough.In a simple way:We're in November. From 1st until 5th November, I need to select October (full month).From 6th until 30th November, I need to select the current month following the rule day-1. For example, in 6th November select data from 1st until 5th. In 7th November, 1st until 6th, and so on until 30th November, where I'll have data from 1st until 29th. From 1st until 5th December, I'll have a full November including 30th.

A perfect solution would be include these two requisites in one routine.