作用:输入年度+财务周,返回这个财务周的周一的日期。
如:输入200903 返回 20090413
假定:每年4月的第一个周六即为本年度第一财务周的周六
FUNCTION z_get_fiscal_week_info.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IN_WEEK) TYPE SCAL-WEEK
*" EXPORTING
*" REFERENCE(OUT_DATE) TYPE SY-DATUM
*" EXCEPTIONS
*" ERROR
*"----------------------------------------------------------------------
DATA: next_year_mon TYPE d.
PERFORM get_mon USING in_week+0(4) CHANGING out_date .
out_date = out_date + ( in_week+4(2) * 7 ) - 7 .
next_year_mon+0(4) = in_week+0(4) + 1 .
PERFORM get_mon USING next_year_mon+0(4) CHANGING next_year_mon .
IF out_date >= next_year_mon .
CLEAR out_date .
RAISE Error.
ENDIF.
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Form get_mon
*&---------------------------------------------------------------------*
FORM get_mon USING year CHANGING mon_date .
DATA: tmpdate TYPE d ,
tmpweek TYPE p .
tmpdate+0(4) = year .
tmpdate+4(4) = '0401'.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
datum = tmpdate
IMPORTING
wotnr = tmpweek.
IF tmpweek <= 6.
tmpdate = tmpdate + 6 - tmpweek .
ELSE.
tmpdate = tmpdate + 6 .
ENDIF.
mon_date = tmpdate - 5 .
ENDFORM. "get_mon
阅读(3108) | 评论(0) | 转发(0) |