DATE_GET_WEEK
The following function module gets the week of the year from the entered date.
REPORT ZEX_DATEGETWEEK .
Parameters: P_date like sy-datum.
Data: d_week like SCAL-WEEK,
d_week1(2).
* The following function module get the week of the entered date.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = P_date
IMPORTING
WEEK = d_week
EXCEPTIONS
DATE_INVALID = 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.
move: d_week+4(2) to d_week1.
Write:/ 'Week ', d_week1.
Parameters: P_date like sy-datum.
Data: d_week like SCAL-WEEK,
d_week1(2).
* The following function module get the week of the entered date.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = P_date
IMPORTING
WEEK = d_week
EXCEPTIONS
DATE_INVALID = 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.
move: d_week+4(2) to d_week1.
Write:/ 'Week ', d_week1.
Gets the week of the year
Week 18
Week 18