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