Application Development 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: 

FM to get First Monday of the month .

prabhu_rengaraju4
Participant
0 Kudos

Hi Guys,

i just need FM to get First Monday of the month .

Please help

Thanks in advance.

Prabhu

10 REPLIES 10

Former Member
0 Kudos

Hi,

There is a Fm which returns First and Last Monday of the year

HRVE_GET_FIRST_LAST_MONDAY

Regards

Sandipan

Former Member
0 Kudos

Have a look at FM HRVE_GET_FIRST_LAST_MONDAY, this basically gives first & Last Monday of the given year.

Former Member
0 Kudos

Hi,

Use FM HRVE_GET_FIRST_LAST_MONDAY.

Thanks,

Sriram Ponna.

prabhu_rengaraju4
Participant
0 Kudos

Hi Guys ,

I need FM to get First Monday of the month . not for that year's first monday.

Thanks

Prabhu

0 Kudos

Hi,

I think there is no Inbuilt FM for That u have do it by writing Code

Regards

Sandipan

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

former_member181995
Active Contributor
0 Kudos

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.

*

0 Kudos

Hi Jony,

you forget to copy these two lines?!:

Hope it helps.

regards, dieter

Regards, Dieter