DATE St Nd Th formates in sap abap
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 = 'MAR'.
WHEN '04'.
d_month = 'APR'.
WHEN '05' .
d_month = 'MAY'.
WHEN '06'.
d_month = 'JUNE'.
WHEN '07' .
d_month = 'JULY'.
WHEN '08'.
d_month = 'AUG'.
WHEN '09' .
d_month = 'SEPT'.
WHEN '10'.
d_month = 'OCT'.
WHEN '11' .
d_month = 'NOB'.
WHEN '12'.
d_month = 'DEC'.
WHEN OTHERS.
ENDCASE.
IF d_day = '01'.
d_day = p_date+7(1). " day
CONCATENATE d_day 'St' INTO d_day.
ELSEIF d_day = '02'.
d_day = p_date+7(1). " day
CONCATENATE d_day 'Nd' INTO d_day.
ELSEIF d_day = '03'.
d_day = p_date+7(1). " day
CONCATENATE d_day 'Rd' INTO d_day.
ELSEIF 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.
ELSEIF d_day = '21'.
CONCATENATE d_day 'St' INTO d_day.
ELSEIF d_day = '22'.
CONCATENATE d_day 'Nd' INTO d_day.
ELSEIF d_day = '23'.
CONCATENATE d_day 'Rd' INTO d_day.
ELSEIF d_day = '31'.
CONCATENATE d_day 'St' 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.
*"----------------------------------------------------------------------
*"*"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 = 'MAR'.
WHEN '04'.
d_month = 'APR'.
WHEN '05' .
d_month = 'MAY'.
WHEN '06'.
d_month = 'JUNE'.
WHEN '07' .
d_month = 'JULY'.
WHEN '08'.
d_month = 'AUG'.
WHEN '09' .
d_month = 'SEPT'.
WHEN '10'.
d_month = 'OCT'.
WHEN '11' .
d_month = 'NOB'.
WHEN '12'.
d_month = 'DEC'.
WHEN OTHERS.
ENDCASE.
IF d_day = '01'.
d_day = p_date+7(1). " day
CONCATENATE d_day 'St' INTO d_day.
ELSEIF d_day = '02'.
d_day = p_date+7(1). " day
CONCATENATE d_day 'Nd' INTO d_day.
ELSEIF d_day = '03'.
d_day = p_date+7(1). " day
CONCATENATE d_day 'Rd' INTO d_day.
ELSEIF 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.
ELSEIF d_day = '21'.
CONCATENATE d_day 'St' INTO d_day.
ELSEIF d_day = '22'.
CONCATENATE d_day 'Nd' INTO d_day.
ELSEIF d_day = '23'.
CONCATENATE d_day 'Rd' INTO d_day.
ELSEIF d_day = '31'.
CONCATENATE d_day 'St' 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