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

current month

Former Member
0 Likes
1,077

Hi,

I want to display date based on the current month on the selection screen.if it is august the date range should be 1/7/2007 to 31/8/2007.like wise i have to display for each month how can i do it?

1 ACCEPTED SOLUTION
Read only

varma_narayana
Active Contributor
0 Likes
944

Hi Varsha

This is the code for u.

SELECT-OPTIONS : S_DATE FOR SY-DATUM .

INITIALIZATION.

S_DATE-SIGN = 'I'.

S_DATE-OPTION = 'BT'.

S_DATE-LOW = SY-DATUM.

S_DATE-LOW+6(2) = '01'.

S_DATE-HIGH = SY-DATUM.

S_DATE-HIGH+6(2) = '01'.

ADD 1 TO S_DATE-HIGH+4(2).

SUBTRACT 1 FROM S_DATE-HIGH.

APPEND S_DATE.

<b>Reward if Helpful</b>

6 REPLIES 6
Read only

varma_narayana
Active Contributor
0 Likes
945

Hi Varsha

This is the code for u.

SELECT-OPTIONS : S_DATE FOR SY-DATUM .

INITIALIZATION.

S_DATE-SIGN = 'I'.

S_DATE-OPTION = 'BT'.

S_DATE-LOW = SY-DATUM.

S_DATE-LOW+6(2) = '01'.

S_DATE-HIGH = SY-DATUM.

S_DATE-HIGH+6(2) = '01'.

ADD 1 TO S_DATE-HIGH+4(2).

SUBTRACT 1 FROM S_DATE-HIGH.

APPEND S_DATE.

<b>Reward if Helpful</b>

Read only

Former Member
0 Likes
944

Hi,

use this

fm

RP_LAST_DAY_OF_MONTHS

this will give the last date of the month

you will be giving the month

then current date is

01/month/year

and give it as export and get the last date and display it

eg:

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = R_FDATE-HIGH

IMPORTING

LAST_DAY_OF_MONTH = G_LTDT

EXCEPTIONS

DAY_IN_NO_DATE = 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.

thanks & regards,

Venkatesh

Read only

Former Member
0 Likes
944

report ztest.

data:

from_date like sy-datum,

to_date like sy-datum.

parameters: month(2).

concatenate sy-datum+0(4) month '01' to from_date.

CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'

EXPORTING

DAY_IN = FROM_DATE

IMPORTING

LAST_DAY_OF_MONTH = TO_DATE

EXCEPTIONS

DAY_IN_NOT_VALID = 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.

write:/ from_date, to_date.

Reward points if useful, get back in case of query.

Cheers!!!

Read only

Former Member
0 Likes
944

Hi,

Use the function module

HR_JP_MONTH_BEGIN_END_DATE

pass sy-datum and get begin and end dates of the month.

Read only

Former Member
0 Likes
944

Hi,

Try FM <b>RP_LAST_DAY_OF_MONTHS</b>

Reward points if useful.

Read only

Former Member
0 Likes
944

Hi,

below code will satisfy your requirement

REPORT ZKK_DATE.

SELECT-OPTIONS: S_DATE FOR SY-DATUM.

DATA: V_DATE1 LIKE SY-DATUM,

V_DATE2 LIKE SY-DATUM.

DATA: P_INTRANGE LIKE RSINTRANGE OCCURS 0 WITH HEADER LINE.

INITIALIZATION.

CALL FUNCTION 'RS_VARI_V_1_LAST_MONTH'

IMPORTING

P_DATE = V_DATE1

TABLES

P_INTRANGE = P_INTRANGE.

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = SY-DATUM

IMPORTING

LAST_DAY_OF_MONTH = V_DATE2

EXCEPTIONS

DAY_IN_NO_DATE = 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.

S_DATE-LOW = V_DATE1.

S_DATE-HIGH = V_DATE2.

APPEND S_DATE.