Upload
lancelot630
View
6
Download
0
Embed Size (px)
Citation preview
Getting Started Newsletters Store
Search the Community
Welcome, Guest Login Register
Products Services & Support About SCN Downloads
Industries Training & Education Partnership Developer Center
Lines of Business University Alliances Events & Webinars Innovation
Added by Guest, last edited by Gurpreet Singh on Apr 15, 2009
ABAP Development / ABAP Development and Programming
Checking for a leap year.
Checking for a leap year.
To check for a leap year w e can w rite just w rite a very simple 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).
w rite 'Its a leap year'.
else.
w rite 'Its not a leap year'.
endif.
once w e add 1 to date w hich 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, w here the month
is changed.
Isn't it this simple.
2nd w ay 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.
w rite: ' leap year'.
else,
w rite: 'Not a leap year'.
ENDFORM.
No labels
Follow SCNContact Us SAP Help Portal
Privacy Terms of Use Legal Disclosure Copyright