Get Ficial year in sap abap
dear abapers we write code get ficial year and month name without using any funcation moudle
may be this code help you
FUNCTION ZRK_FM.
*"----------------------------------------------------------------------
*"*"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' or d_month = '02' or 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 d_day = '02' or d_day = '03' or d_day = '04'
or d_day = '05' or d_day = '06' or d_day = '07'
or d_day = '08' or d_day = '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.
ENDFUNCTION.
may be this code help you
FUNCTION ZRK_FM.
*"----------------------------------------------------------------------
*"*"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' or d_month = '02' or 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 d_day = '02' or d_day = '03' or d_day = '04'
or d_day = '05' or d_day = '06' or d_day = '07'
or d_day = '08' or d_day = '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.
ENDFUNCTION.
Comments
Post a Comment