‎2010 Oct 04 1:43 PM
Hi Gurus,
My 'IF' condition should execute in first saturday after 10th of every month. So can any one tell me the code for the below logic to put in 'IF':
"First saturday after 10th of every month"
Thanks & Regards,
Balaji.S
‎2010 Oct 04 1:45 PM
‎2010 Oct 04 1:57 PM
Hi,
Use this code:
IF sy-datum+6(2) GE 10.
Write your code here.
ENDIF.
Should work.
‎2010 Oct 04 2:01 PM
>
> Hi,
> Use this code:
>
> IF sy-datum+6(2) GE 10.
>
> Write your code here.
>
> ENDIF.
>
> Should work.
And what happens if we get to the second saturday of the month?
‎2010 Oct 04 2:11 PM
DATA: v_week TYPE P.
IF sy-datum+6(2) BETWEEN 10 AND 17. "first week after 10th
*--To find out day of the week
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
DATUM = sy-datum
IMPORTING
WOTNR = v_week.
IF v_week = 6. "day 6 of the week is Saturday
Write your code here. (whatever needs to be executed on the Saturday after 10th)
ENDIF.
ENDIF.
Edited by: abapfreak on Oct 4, 2010 3:12 PM
Edited by: abapfreak on Oct 4, 2010 3:15 PM
‎2010 Oct 04 2:00 PM
Well do you want to schedule your program/txn execution for 10th of every month ???
‎2010 Oct 04 2:02 PM
>
> Well do you want to schedule your program/txn execution for 10th of every month ???
I think only his IF...ENDIF should run on the first saturday after the 10th of a month.
‎2010 Oct 04 2:08 PM
you are right .. but my point was whether on first saturday after the 10th of a month the report should be executed or not ? If this is the question then this can be achieved easily via job scheduling .
Else, why such a condition is needed ??
‎2010 Oct 04 2:16 PM
Hi,
Here is a solution if ur report run every day,
First u create a table , lets say itab1 , in se11 withe 3 column 'year' , 'Month' and 'flag.
Then in the report,
data : l_year(4),
l_mont(2),
l-day(2).
data : ls_itab1 like itab.
DATA: ld_day TYPE c.
l-year = sy-datum(4).
l-month.................
.................
Select single flag from itab1 into ls_itab1 where year = l-year and month = l-month.
if sy-subrc eq 0 and ls_itab1-flag is initial.
if l-day ge 10 .
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
date = sy-datum
IMPORTING
weekday = ld_day.
if ld_day. eq 'SATURDAY'.
ur code here
update itab1 set flag = 'X' where month es lmonth...................'
endif.
endif.
endif.
Hope this helps.
‎2010 Oct 04 2:07 PM
Hi Gurus,
IF (first saturday after the 10th of a month)
..
..
..
..
..
ENDIF
Here in order to put in 'IF', i need the code for that logic.
Regards,
Balaji.S
‎2010 Oct 04 2:08 PM
Hi,
Use FM "/OSP/GETDATE_WEEKDAY".
Pass IV_DAY_OF_WEEK as 6 i.e. 6th day of week which is SATURDAY
Pass IV_START_DATE as 11.current month.currenty year for oct. it would be 11.10.2010
time default is ok...
with this you would get the date of "First saturday after 10th of every month"Try following values in SE37
IV_DAY_OF_WEEK = 6
IV_START_DATE = 11.10.2010
Time ... let it be default timeReturn value is : 16.10.2010 => which is a saturday
2nd Example
IV_DAY_OF_WEEK = 6
IV_START_DATE = 11.11.2010
Time ... let it be default timeReturn value is : 13.11.2010 => which is a saturday
CALL FUNCTION '/OSP/GETDATE_WEEKDAY'
EXPORTING
IV_DAY_OF_WEEK = 6
IV_START_DATE = lv_date
IV_TIME = '235959'
IMPORTING
EV_DATE_DAY_OF_WEEK = lv_final
EXCEPTIONS
INVALID_DAY = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
if lv_final = sy-datum. " Today is the 1st saturday after 10th of that month
then..... do this...
else.
do this...
endif.
lv_final will have the date of 1st saturday after 10th of that month.
Thanks,
Best regards,
Prashant
‎2010 Oct 04 2:10 PM
I have written the program... In my program for particular condition alone should execute 'first saturday after 10th of every month'.
No Jos shoul be scheduled.
‎2010 Oct 04 2:18 PM
Moderator message - Please do not ask or answer basic date questions - thread locked and all points unassigned Rob