Skip to Content
0
Former Member
May 04, 2007 at 08:17 AM

Fisical date calculation

17 Views

Hi All,

To get the fisical date range is there any other routine simpler than the below mentioned routine to improve the performance.

form get_fiscal_period.

data: l_current_year like t009b-bdatj,

l_variant like t009-periv.

call function 'CCODE_GET_FISCAL_YEAR_VARIANT'

EXPORTING

company_code = p_bukrs

IMPORTING

fiscal_year_variant = l_variant

EXCEPTIONS

company_code_not_found = 1

others = 2.

if sy-subrc <> 0.

message i368(00) with 'Unable to get Fiscal year'.

endif.

l_current_year = sy-datum(4).

call function 'FIRST_AND_LAST_DAY_IN_YEAR_GET'

EXPORTING

i_gjahr = l_current_year

i_periv = l_variant

IMPORTING

e_first_day = p_fiscal-low

e_last_day = p_fiscal-high

EXCEPTIONS

input_false = 1

t009_notfound = 2

t009b_notfound = 3

others = 4.

if sy-subrc <> 0.

message i368(00) with 'Unable to get the first and last day'.

endif.

if sy-datum < p_fiscal-low.

p_fiscal-low = p_fiscal-low - 365.

p_fiscal-high = p_fiscal-high - 365.

endif.

append p_fiscal.

v_start_month = p_fiscal-low+4(2).

v_end_month = p_fiscal-high+4(2).

if v_start_month >= 01 and v_start_month <= 03.

move 01 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 02 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 03 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 04 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 05 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 06 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 07 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 08 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 09 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 10 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 11 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 12 to fiscal_quarter_4-month.

append fiscal_quarter_4.

elseif v_start_month >= 04 and v_start_month <= 06.

move 04 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 05 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 06 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 07 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 08 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 09 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 10 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 11 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 12 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 01 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 02 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 03 to fiscal_quarter_4-month.

append fiscal_quarter_4.

elseif v_start_month >= 07 and v_start_month <= 09.

move 07 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 08 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 09 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 10 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 11 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 12 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 01 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 02 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 03 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 04 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 05 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 06 to fiscal_quarter_4-month.

append fiscal_quarter_4.

else.

move 10 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 11 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 12 to fiscal_quarter_1-month.

append fiscal_quarter_1.

move 01 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 02 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 03 to fiscal_quarter_2-month.

append fiscal_quarter_2.

move 04 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 05 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 06 to fiscal_quarter_3-month.

append fiscal_quarter_3.

move 07 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 08 to fiscal_quarter_4-month.

append fiscal_quarter_4.

move 09 to fiscal_quarter_4-month.

append fiscal_quarter_4.

endif.

endform. " get_fiscal_period