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

sy-datum problem

Former Member
0 Likes
550

hello friends,

i have a scenario, where , when the entered period as parameter is

YYYYMM the last date for that particular month MM

should be calculated ( i dont know how), and should be attached to this period

like

YYYYMMDD

how do i calculate this DD (ie. last day of the moth) for the

given month and year.

like yyyymm is 200404 then i should output 20040431

if 200510 then output sould be 20051031

if 200302 then output should be 20030228.

can some one help.

thank you.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
515

Try this.



report zrich_0001.


data: yyyymm(6) type c value '200704'.
data: datum type sy-datum.
data: last_datum type sy-datum.

datum = yyyymm.
datum+6(2) = '01'.

call function 'LAST_DAY_OF_MONTHS'
     exporting
          day_in            = datum
     importing
          last_day_of_month = last_datum.


write:/ last_datum.

Regards,

RIch Heilman

3 REPLIES 3
Read only

learnsap
Active Participant
0 Likes
515

Hi Saritha,

Check this function module "BKK_GET_MONTH_LASTDAY" or "FKK_LAST_DAY_OF_MONTH"

Pass the date to the function module and it will give the last day of the month.

Search in SE37 with lastday* and you will get lots of function modules for your requirement.

Regards,

Ramesh Babu

*Award points if reply found useful

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
516

Try this.



report zrich_0001.


data: yyyymm(6) type c value '200704'.
data: datum type sy-datum.
data: last_datum type sy-datum.

datum = yyyymm.
datum+6(2) = '01'.

call function 'LAST_DAY_OF_MONTHS'
     exporting
          day_in            = datum
     importing
          last_day_of_month = last_datum.


write:/ last_datum.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
515

thanks friends.

i tried rich's code its working , thanks.