Get ficial year in sap abap using funcation modules
hello abpers we writing code get ficial year
FUNCTION zdate_formates.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(P_DATE) TYPE DATS OPTIONAL
*" EXPORTING
*" VALUE(P_YEAR1) TYPE ARKTX
*" VALUE(P_YEAR2) TYPE ARKTX
*" VALUE(P_YEAR3) TYPE ARKTX
*" VALUE(F_YEAR) TYPE PSTYV
*"----------------------------------------------------------------------
DATA: d_month TYPE dats,
d_month1(10) TYPE c,
d_day(4) TYPE c,
d_year(15) TYPE c,
d_year1(15) TYPE c,
d_year2(15) TYPE c,
d_year3(15) TYPE c.
d_month = p_date+4(2). " month name.
d_day = p_date+6(2). " day
d_year = p_date+0(4).
* IF d_month = 01 and d_month = 02 and d_month = 03.
* f_year = p_date+0(4) - 1.
* ELSE.
*
* f_year = d_year.
* ENDIF.
CASE d_month.
WHEN '01' .
d_month = 'JAN'.
WHEN '02'.
d_month = 'FEB'.
WHEN '03' .
d_month = 'MARCH'.
WHEN '04'.
d_month = 'APRIL'.
WHEN '05' .
d_month = 'MAY'.
WHEN '06'.
d_month = 'JUN'.
WHEN '07' .
d_month = 'JULY'.
WHEN '08'.
d_month = 'AUG'.
WHEN '09' .
d_month = 'SET'.
WHEN '10'.
d_month = 'OCT'.
WHEN '11' .
d_month = 'NUM'.
WHEN '12'.
d_month = 'DEC'.
WHEN OTHERS.
ENDCASE.
* IF d_day = '01' or '02' or '03' or '04' or '05' or '06'
* or '07' or '08' or '09'.
* d_day = p_date+7(1). " day
* CONCATENATE d_day 'Th' INTO d_day.
*
* else.
CONCATENATE d_day 'Th' INTO d_day.
* endif.
CONCATENATE d_day d_month d_year INTO d_year1 SEPARATED BY space.
CONCATENATE d_day ',' d_month ',' d_year INTO d_year2." separated by space.
CONCATENATE d_day '/' d_month '/' d_year INTO d_year3." separated by space.
p_year1 = d_year1.
p_year2 = d_year2.
p_year3 = d_year3.
CALL FUNCTION 'GM_GET_FISCAL_YEAR'
EXPORTING
I_DATE = p_date
i_fyv = 'V3'
IMPORTING
E_FY = F_YEAR
* EXCEPTIONS
* FISCAL_YEAR_DOES_NOT_EXIST = 1
* NOT_DEFINED_FOR_DATE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFUNCTION.
FUNCTION zdate_formates.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(P_DATE) TYPE DATS OPTIONAL
*" EXPORTING
*" VALUE(P_YEAR1) TYPE ARKTX
*" VALUE(P_YEAR2) TYPE ARKTX
*" VALUE(P_YEAR3) TYPE ARKTX
*" VALUE(F_YEAR) TYPE PSTYV
*"----------------------------------------------------------------------
DATA: d_month TYPE dats,
d_month1(10) TYPE c,
d_day(4) TYPE c,
d_year(15) TYPE c,
d_year1(15) TYPE c,
d_year2(15) TYPE c,
d_year3(15) TYPE c.
d_month = p_date+4(2). " month name.
d_day = p_date+6(2). " day
d_year = p_date+0(4).
* IF d_month = 01 and d_month = 02 and d_month = 03.
* f_year = p_date+0(4) - 1.
* ELSE.
*
* f_year = d_year.
* ENDIF.
CASE d_month.
WHEN '01' .
d_month = 'JAN'.
WHEN '02'.
d_month = 'FEB'.
WHEN '03' .
d_month = 'MARCH'.
WHEN '04'.
d_month = 'APRIL'.
WHEN '05' .
d_month = 'MAY'.
WHEN '06'.
d_month = 'JUN'.
WHEN '07' .
d_month = 'JULY'.
WHEN '08'.
d_month = 'AUG'.
WHEN '09' .
d_month = 'SET'.
WHEN '10'.
d_month = 'OCT'.
WHEN '11' .
d_month = 'NUM'.
WHEN '12'.
d_month = 'DEC'.
WHEN OTHERS.
ENDCASE.
* IF d_day = '01' or '02' or '03' or '04' or '05' or '06'
* or '07' or '08' or '09'.
* d_day = p_date+7(1). " day
* CONCATENATE d_day 'Th' INTO d_day.
*
* else.
CONCATENATE d_day 'Th' INTO d_day.
* endif.
CONCATENATE d_day d_month d_year INTO d_year1 SEPARATED BY space.
CONCATENATE d_day ',' d_month ',' d_year INTO d_year2." separated by space.
CONCATENATE d_day '/' d_month '/' d_year INTO d_year3." separated by space.
p_year1 = d_year1.
p_year2 = d_year2.
p_year3 = d_year3.
CALL FUNCTION 'GM_GET_FISCAL_YEAR'
EXPORTING
I_DATE = p_date
i_fyv = 'V3'
IMPORTING
E_FY = F_YEAR
* EXCEPTIONS
* FISCAL_YEAR_DOES_NOT_EXIST = 1
* NOT_DEFINED_FOR_DATE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFUNCTION.
Comments
Post a Comment