0% found this document useful (0 votes)
208 views1 page

Checking For Leap Year

This document provides two methods to check if a year is a leap year using ABAP code. The first method adds one day to February 28th and checks if the month changes, indicating it is not a leap year. The second method subtracts the input date from March 1st of the same year, and if the difference is 29 days, then it is a leap year. Both methods provide simple code to programmatically determine if a given year is a leap year or not.

Uploaded by

lancelot630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
208 views1 page

Checking For Leap Year

This document provides two methods to check if a year is a leap year using ABAP code. The first method adds one day to February 28th and checks if the month changes, indicating it is not a leap year. The second method subtracts the input date from March 1st of the same year, and if the difference is 29 days, then it is a leap year. Both methods provide simple code to programmatically determine if a given year is a leap year or not.

Uploaded by

lancelot630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Checking for a leap year.

Checking for a leap year.


To check for a leap year we can write justwritea verysimple code.
parameters : p_date like sy-datum.
data w_date like p_date.
w_date = p_date.
w_date+4(2) = '02'.
w_date+6(2) = '28'.
add 1 to w_date.
if w_date+4(2) = p_date+4(2).
write 'Its a leap year'.
else.
write 'Its not a leap year'.
endif.
once we add 1 to date which is 28th feb of the year. if its a leap year then the month remains the same only the day changes from 28 to 29. if its
not a leap year then the date is 1st march, where the month is changed.
Isn't it this simple.
2nd way to achive the same result:
Paramters: W_date type sy-datum.
Perform Leap_Year_Check.
******** ********** **FORM ROUTINE
Form Leap_Year_Check.
Data: w_date1 type sy-datum,
w_int type i.
w_date+4(4) = '0201'.
w_date1 = w_date.
w_date1+4(2) = '03'.
w_i = w_date1 - w_date.
IF w_i = 29.
write: ' leap year'.
else,
write: 'Not a leap year'.
ENDFORM.

You might also like