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: 

Intialization of Date

Former Member
0 Kudos

HI Abapers.

I have a select option on my selection screen.

I want the low value to be populated with the first day of the month and the High value to be populated with the last day of the month depending on my current date.

I should also take care of leap years and others issues while checking this in the initialization event.

Cheers

1 ACCEPTED SOLUTION

Former Member
0 Kudos

simple..

for first day u declare constent 1.

for last day of month u use fm..

<b>LAST_DAY_OF_MONTHS</b>

for finding month,,,

month = sy-datum+4(2).

and now in intialisation event u declare it.

7 REPLIES 7

Former Member
0 Kudos

simple..

for first day u declare constent 1.

for last day of month u use fm..

<b>LAST_DAY_OF_MONTHS</b>

for finding month,,,

month = sy-datum+4(2).

and now in intialisation event u declare it.

0 Kudos

hi,

Use FM <b>LAST_DAY_OF_MONTHS</b> and assign the values to s_option-low and s_option-high...

Regards,

Santosh

0 Kudos

hi,

Check this thread out

Regards,

santosh

0 Kudos

hi,

FM <b>DATE_TO_DAY</b> will get the first day of the current month

Check this out

Regards,

Santosh

Former Member
0 Kudos

Hi,

Find out first and last day of that month.

<b>First day</b>

lv_yr = '2006'

lv_month = 'Current month'.

CONCATENATE lv_yr lv_month '01' INTO lv_first_dt.

<b>last day</b>

for the above date add one month

lv_month = lv_month + 1.

Get last day of this month

lv_end_dt = lv_end_dt - 1.

the above one automatically handles leap year.

And assign in select-options for LOW and HIGH values.

Regards,

Rajesh

Former Member
0 Kudos

Hi,

Please check this piece of code,

select-options : s_date for sy-datum.

data : st_date type sy-datum,

end_date type sy-datum.

  • Initialization of selection screen.

INITIALIZATION.

CONCATENATE sy-datum(6) '01' INTO st_date.

CALL FUNCTION 'SG_PS_GET_LAST_DAY_OF_MONTH'

EXPORTING

day_in = sy-datum

IMPORTING

last_day_of_month = end_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.

s_date-high = end_date.

s_date-low = st_date.

append s_date.

Please mark helpful answers.

0 Kudos

just copy and paste and check....

select-options: date for sy-datum.

data:day(2).

data:month(2),

year(4).

data:day1(2).

data: date1 like sy-datum.

data: date2 like sy-datum.

initialzation.

month = sy-datum+4(2).

day = 01.

year = sy-datum+0(4).

concatenate year month '0' day into date1.

CALL FUNCTION 'LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = sy-datum

IMPORTING

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

  • concatenate day1 month year into date2.

date-LOW = date1.

date-HIGH = date2.

append date.