Hi everyone,
I have 1) calday- some date
2)Fiscal variant fiscvarnt = Z6 ,Z6 means year starts from July1st- June 30th).
it is like July1st must be the 1stWeek or week1(not january1st as first week).
I want to get the week number for the date calday taking in to consideration my fiscal variant.
I have written code for this as below. We have to pass this lv_caldy to function module to get the week number from lv_calday.
result:-
ZFISCWEEK = Week Number.
My code works fine but after calculating lv_calday
to pass to the function module 'DATE_GET_WEEK'..it fails in few caseslike
1)if calday =31.5.2009 , then lv_calday becomes 31.11.2008
2)if caldy = 30.8.2009 , then lv_calday becomes 30.2.2010
it fails in first case as november month will not 31.
it fails in second case as febrauary will not have day 30 0r 31.even some times february might have 28 or 29.
Could any one modify my code to get this correct?
DATA : it_respkg TYPE tyt_TG_1.
DATA : lv_calday TYPE /bi0/oicalday,
lv_/bic/zfiscweek TYPE /bic/oizfiscweek .
it_respkg] = result_package[.
SORT it_respkg BY /bic/zdeh_num.
LOOP AT it_respkg ASSIGNING <result_fields>.
IF <result_fields>-fiscvarnt EQ u2018Z6u2019.
lv_calday = <result_fields>-calday.
IF lv_calday+4(2) LT 6.
lv_calday4(2) = lv_calday4(2) + 6.
lv_calday(4) = lv_calday(4) - 1.
ELSEIF lv_calday+4(2) GT 6.
lv_calday4(2) = lv_calday4(2) - 6.
lv_calday(4) = lv_calday (4) + 1.
ELSEIF lv_calday+4(2) EQ 6.
lv_calday4(2) = lv_calday4(2) + 6.
ENDIF.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = lv_calday
IMPORTING
week = lv_/bic/zfiscweek.
<result_fields>-/bic/zfiscweek = lv_/bic/zfiscweek.
ENDIF.
CLEAR : lv_calday.
ENDLOOP.
REFRESH result_package.
result_package] = it_respkg[.
SORT it_respkg BY /bic/zdeh_num .
Regards,
Sonam