2022 Dec 02 11:28 AM
Hi All,
I have one requirement, where I have to add one restriction on Delivery date that the date should be in even week (i.e. 2nd & 4th Week of the month).
Is there any FM available in SAP where we can provide date as input & it will return week number of the month.
Thanks & Regards,
2022 Dec 05 5:56 AM
I Used below logic in my code, if anyone has better & short solution for this, please let me know.
DATA: week1 TYPE fti_disp_2,
week11(2) TYPE c,
week2 TYPE fti_disp_2,
week22(2) TYPE c.
DATA: present_week TYPE i,
date TYPE sy-datum.
PARAMETERS: p_date TYPE sy-datum.
START-OF-SELECTION.
date = p_date.
date+6(2) = '01'. "First day of this month
date = date - 1. "last day of last month
CALL FUNCTION 'DISP_WEEK_GET'
EXPORTING
i_datum = date
IMPORTING
e_week = week1. " Last Month's last Week no
week11 = week1+4(2)."Get Only Week from YYYYWW
CALL FUNCTION 'DISP_WEEK_GET'
EXPORTING
i_datum = p_date
IMPORTING
e_week = week2."Current Week No
week22 = week2+4(2). "Get Only Week from YYYYWW
present_week = (week22 - week11) + 1.
WRITE present_week.
2022 Dec 02 2:22 PM
2022 Dec 05 5:33 AM
2022 Dec 03 1:35 PM
Which week day should a week start? i.e. if month starts on Wednesday, should that day be part of the "first week", or should the first week start on next Sunday or Monday, or other rule?
2022 Dec 05 5:51 AM
2022 Dec 05 5:56 AM
I Used below logic in my code, if anyone has better & short solution for this, please let me know.
DATA: week1 TYPE fti_disp_2,
week11(2) TYPE c,
week2 TYPE fti_disp_2,
week22(2) TYPE c.
DATA: present_week TYPE i,
date TYPE sy-datum.
PARAMETERS: p_date TYPE sy-datum.
START-OF-SELECTION.
date = p_date.
date+6(2) = '01'. "First day of this month
date = date - 1. "last day of last month
CALL FUNCTION 'DISP_WEEK_GET'
EXPORTING
i_datum = date
IMPORTING
e_week = week1. " Last Month's last Week no
week11 = week1+4(2)."Get Only Week from YYYYWW
CALL FUNCTION 'DISP_WEEK_GET'
EXPORTING
i_datum = p_date
IMPORTING
e_week = week2."Current Week No
week22 = week2+4(2). "Get Only Week from YYYYWW
present_week = (week22 - week11) + 1.
WRITE present_week.
2022 Dec 05 7:18 AM
What do you consider to be the first day of 2nd week in December 2022 ?
What do you consider to be the first day of 4th week in December 2022 ?