2006 Jul 05 11:20 AM
Hi,everybody,
now I have a question,Do you know how to get week number in a month.Is there a FM which can get the information in sap.
for example, In July 2006,there are include 27,28,29,30 weeks.
Best Regards
samuel
Hi,everybody,
now I have a question,Do you know how to get week number in a month.Is there a FM which can get the information in sap.
for example, In July 2006,there are include 27,28,29,30 weeks.
Best Regards
samuel
2006 Jul 05 11:23 AM
Make use of the FM DATE_GET_WEEK
Reward the point and close the thread.
2006 Jul 05 11:23 AM
2006 Jul 05 11:23 AM
i think there is not such type of fm..
but u can get no of week per month and now u can make logic for ur requirment...
The function module <b>DATE_GET_WEEK</b> gives the week no in that year in 2 digits. By using this function module twice , you can find out the Week in the month.(i.e use FM to calculate week no for month starting date, and use it second time to calculate the week no of the date,and then findout the difference).
2006 Jul 05 11:25 AM
2006 Jul 05 11:25 AM
Hi Liu,
U can use this FM : DATE_GET_WEEK
If it helps, please do reward.
2006 Jul 05 11:28 AM
Hai
Check the following Code
Data : datum like prowf-ertag,
DATA: week LIKE scal-week.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = datum
IMPORTING
week = week
EXCEPTIONS
date_invalid = 1
OTHERS = 2.
write : week.
Thanks & regards
Sreeni
2006 Jul 05 11:35 AM
Hi Liu,
Use FM GET_WEEK_INFO_BASED_ON_DATE
or FM HR_GBSSP_GET_WEEK_DATES
Copy the below code:-
DATA: lv_date TYPE datum,
lv_week_no TYPE p08_weekno,
lv_week1 TYPE char2 ,
lv_week2 TYPE char2 ,
lv_week3 TYPE char2 ,
lv_week4 TYPE char2 .
lv_date = '20060701'.
CALL FUNCTION 'HR_GBSSP_GET_WEEK_DATES'
EXPORTING
p_pdate = lv_date
IMPORTING
P_SUNDAY =
P_SATURDAY =
P_DAY_IN_WEEK =
p_week_no = lv_week_no.
lv_week1 = lv_week_no+4(2).
lv_week2 = lv_week1 + 1.
lv_week3 = lv_week2 + 1.
lv_week4 = lv_week3 + 1.
WRITE:/ 'Week 1 = ', lv_week1.
WRITE:/ 'Week 2 = ', lv_week2.
WRITE:/ 'Week 3 = ', lv_week3.
WRITE:/ 'Week 4 = ', lv_week4.
Regards,
Sameena
2006 Jul 05 12:14 PM
Hi jxlmh,
1. 01-July-2006 To 31-July-2006
Output will be :
26
27
28
29
30
31
(26th week bcos 1st july - sunday also there)
2. Just copy paste this program,
and it will
DISPLAY THE WEEK NUMBERS
(from the DATE input)
3.
report abc.
type-pools : TSTR.
*----
DATA
*----
data : weeks type TSTR_GENSEGYEARTAB.
data : weekswa type line of TSTR_GENSEGYEARTAB.
data : TTSTR like TTSTR .
data : year type TSTR_YEARTAB.
data : yearwa type line of TSTR_YEARTAB.
data : GENSEGTAB TYPE TSTR_GENSEGTAB.
data : GENwa TYPE line of TSTR_GENSEGTAB.
data : tabix type i.
.
*----
SELECTION SCREEN
*----
select-options : mydate for sy-datum DEFAULT '20060701' TO '20060731'.
*----
START-OF-SELECTION
*----
START-OF-SELECTION.
yearwa = mydate-low(4).
append yearwa to year.
CALL FUNCTION 'TSTR_PERIODS_WEEKS'
EXPORTING
IT_YEARTAB = year
IS_TTSTR = TTSTR
IMPORTING
ET_GENSEGTAB = weeks
EXCEPTIONS
ERROR = 1
OTHERS = 2
.
read table weeks into weekswa index 1.
GENSEGTAB = weekswa-GENSEGTAB.
loop at gensegtab into genwa.
tabix = sy-tabix.
if ( genwa-begin_date >= MYDATE-LOW and genwa-begin_date <= MYDATE-HIGH
)
or
( genwa-end_date >= MYDATE-LOW and genwa-end_date <= MYDATE-HIGH )
.
write 😕 sy-tabix.
endif.
endloop.
break-point.
regards,
amit m.
2006 Jul 06 3:02 AM
Hi,amit,
1. 01-July-2006 To 31-July-2006
Output will be :
26
27
28
29
30
31
but actually, the '31' does not belong to JULY, It belongs to August.Do you find the problem?
thanks your reply
Best Regards
Samuel Liu
2006 Jul 06 6:15 AM
Hi again,
1. 31st july belongs to august !
(i did not fully understand that)
2. 31st july, comes on monday,
and that week number is 31.
(for that matter, 1st-aug-2006 till 5th-aug-2006,
will also fall in 31st week
)
regards,
amit m.