04-03-2008 2:43 PM
Hi Guys,
i just need FM to get First Monday of the month .
Please help
Thanks in advance.
Prabhu
04-03-2008 2:48 PM
Hi,
There is a Fm which returns First and Last Monday of the year
HRVE_GET_FIRST_LAST_MONDAY
Regards
Sandipan
04-03-2008 2:50 PM
Have a look at FM HRVE_GET_FIRST_LAST_MONDAY, this basically gives first & Last Monday of the given year.
04-03-2008 2:53 PM
04-03-2008 2:54 PM
Hi Guys ,
I need FM to get First Monday of the month . not for that year's first monday.
Thanks
Prabhu
04-03-2008 3:06 PM
Hi,
I think there is no Inbuilt FM for That u have do it by writing Code
Regards
Sandipan
04-03-2008 2:59 PM
Hi,
try this short example:
DATA: DATE0 LIKE SY-DATUM VALUE '20080414'.
DATA: DATE1 LIKE SY-DATUM.
DATA: WOTNR TYPE P.
*
DATE1 = DATE0.
DATE1+6(2) = '01'.
*
do.
*
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
DATUM = DATE1
IMPORTING
WOTNR = WOTNR.
*
if wotnr = 1. exit. endif.
ADD 1 TO DATE1.
*
ENDdo.
*
WRITE: / DATE0, DATE1.
*
Hope it helps.
regards, dieter
04-03-2008 3:08 PM
Suppose your input is the following.
Year: p_year
Month: p_month
Then do this.
concatenate p_year p_month '07' into l_date_in.
Pass l_date_in to the FM BWSO_DATE_GET_FIRST_WEEKDAY .
This will give you the first Monday of the month you are inputting.
If you dont have the above mentioned FM, then try the below code.
concatenate p_year p_month '07' into l_date_in
call function 'DATE_GET_WEEK'
exporting
date = date_in
importing
week = week
exceptions
date_invalid = 1
others = 2.
call function 'WEEK_GET_FIRST_DAY'
exporting
week = week
importing
date = date_out
exceptions
week_invalid = 1
others = 2.
Now date_out will contain the first monday of the month.
Hope this helps. Reward points if helpful.
Thanks,
Balaji
04-03-2008 3:08 PM
HI,
There is in fact no existing FM
But do try the following
DATA: L_DAYNUMB TYPE P,
L_DATE TYPE SY-DATUM,
L_DATE_1 TYPE SY-DATUM.
L_DATE ='20080405'.
CONCATENATE L_DATE(6) '01' INTO L_DATE_1.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
DATUM = L_DATE_1
IMPORTING
WOTNR = L_DAYNUMB
EXCEPTIONS
OTHERS = 1.
L_DATE_1 = L_DATE_1 - ( L_DAYNUMB - 1 ).
IF L_DATE4(2) NE L_DATE_14(2).
L_DATE_1 = L_DATE_1 + 7.
ENDIF.
WRITE:/ L_DATE_1.
04-03-2008 3:24 PM
Hi prabhu..
Hi,
try this short example:
DATA: DATE0 LIKE SY-DATUM VALUE '20080414'.
DATA: DATE1 LIKE SY-DATUM.
DATA: WOTNR TYPE P.
*
DATE1 = DATE0.
DATE1+6(2) = '01'.
*
do.
*
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
DATUM = DATE1
IMPORTING
WOTNR = WOTNR.
*
if wotnr = 1. exit. endif.
ADD 1 TO DATE1.
*
ENDdo.
*
WRITE: / DATE0, DATE1.
*
04-03-2008 3:37 PM
Hi Jony,
you forget to copy these two lines?!:
Hope it helps.
regards, dieter
Regards, Dieter