Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

date format

Former Member
0 Likes
509

Hi experts, is it possible to display the date in word format..

i mean 01-08-2007 as 1st Aug 2007.

is this possible if so please guide me how can i achieve that.

4 REPLIES 4
Read only

Former Member
0 Likes
450

Hi,

take help from this code :

data : date(10),

text1(26),

num1(10),

test_day(15),

o_date(20),

idate type sy-datum.

data : Day(2), month(2), Year(4).

data : ODay(2), Omonth(2), OYear(4).

data : Ltext Type T247-LTX.

date = '01-08-2007'.

day = date+0(2).

month = date+3(2).

year = date+6(4).

concatenate year month day into idate.

CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'

EXPORTING

idate = idate

IMPORTING

DAY = oday

MONTH = omonth

YEAR = oyear

LTEXT = ltext.

concatenate oday '-' ltext '-' oyear into o_date.

write : O_date.

Reward points, if helpful,

Sandeep Kaushik

Read only

Former Member
0 Likes
450

Hi,

check the below code

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-031.

PARAMETERS: date1 RADIOBUTTON GROUP rad1 DEFAULT 'X', "SAP date format YYYYDDMM

date2 RADIOBUTTON GROUP rad1, "Date format like aprial31, 2006

date3 RADIOBUTTON GROUP rad1, "Date format like 31 apr,2006

date4 RADIOBUTTON GROUP rad1, "Date format like DD/MM/YYYY

date5 RADIOBUTTON GROUP rad1. "Date format like DD.MM.YYYY

SELECTION-SCREEN END OF BLOCK b2

FORM getmonth .

SELECT mnr

ktx

ltx

INTO TABLE T_month

FROM t247

WHERE spras = 'EN'.

IF sy-subrc NE '0'.

MESSAGE I "Message - Not able to get month values from the table T247

ENDIF.

ENDFORM.

DATA : temp_date(16) TYPE c,

temp1_date(60) TYPE c,

year(4) TYPE c,

daymonth(11) TYPE c,

daymonth1(11) TYPE c,

month(9) TYPE c,

day(2) TYPE c,

mon LIKE t247-ktx,

len TYPE i .

MOVE date TO temp1_date .

CONDENSE temp1_date NO-GAPS.

MOVE temp1_date TO temp_date .

IF date2 EQ 'X'. "The date format is like Aprial 31, 2007

CONDENSE temp_date NO-GAPS.

SPLIT date AT ',' INTO daymonth year.

IF STRLEN( year ) NE '4'.

error = 'X'.

WRITE : 'Invalid date format.'.

ELSE.

daymonth1 = daymonth.

CONDENSE daymonth1 NO-GAPS.

_len = STRLEN( _daymonth1 ).

l_len = 13 - len.

SHIFT daymonth1 RIGHT BY len PLACES.

CONDENSE daymonth1 NO-GAPS.

month = daymonth1.

CONDENSE month NO-GAPS.

SORT t_month BY monthltx.

READ TABLE t_month WITH KEY monthltx = month.

IF sy-subrc <> 0.

error = 'X'.

WRITE : 'Invalid date format.' .

ELSE.

len = STRLEN( month ).

CONDENSE daymonth NO-GAPS.

SHIFT daymonth LEFT BY len PLACES.

day = daymonth.

CONDENSE day NO-GAPS.

CONCATENATE year t_month-monthnumber day INTO o_date.

ENDIF.

ENDIF.

ELSEIF p_date3 EQ 'X'. "The date format is like 31 apr, 2007

CONDENSE temp_date NO-GAPS.

SPLIT i_date AT ',' INTO daymonth year.

IF STRLEN( year ) NE '4'.

error = 'X'.

WRITE : 'Invalid date format.'.

ELSE.

daymonth1 = daymonth.

CONDENSE daymonth1 NO-GAPS.

SHIFT daymonth1 LEFT BY 2 PLACES.

CONDENSE daymonth1 NO-GAPS.

month = daymonth1.

CONDENSE month NO-GAPS.

TRANSLATE month TO UPPER CASE.

SORT t_month BY monthstx.

MOVE month to mon.

READ TABLE t_month WITH KEY monthstx = mon.

IF sy-subrc <> 0.

error = 'X'.

WRITE : 'Invalid date format.' .

ELSE.

CONDENSE daymonth NO-GAPS.

day = daymonth+0(2).

CONDENSE day NO-GAPS.

CONCATENATE year t_month-monthnumber day INTO o_date.

ENDIF.

ENDIF.

ELSEIF p_date4 EQ 'X' OR p_date5 EQ 'X'. "Date format is like DD.MM.YYYY or DD/MM/YYYY

CONDENSE temp_date NO-GAPS.

IF STRLEN( temp_date ) EQ 10.

o_date0(4) = temp_date6(4).

o_date4(2) = temp_date3(2).

o_date6(2) = temp_date0(2).

ELSE.

error = 'X'.

WRITE : 'Invalid date format.' .

ENDIF.

ENDIF.

IF STRLEN( o_date ) NE '8'.

error = 'X'.

WRITE : 'Invalid date format.'.

ENDIf.

ENDFORM. " f0100_conv_date

Regards

Read only

Former Member
0 Likes
450

Hi vamsi,

1. 01-08-2007 -


> <b>01.AUG.2007</b>

2. use the FM - <b>CONVERSION_EXIT_SDATE_OUTPUT</b>

regards,

amit m.

Read only

Former Member
0 Likes
450

hi

check with this code.

this converts the month number to month name and displays.its fetched from table T247.

TYPES: BEGIN OF ty_month,

mnr TYPE fcmnr,

ktx TYPE fcltx,

END OF ty_month.

DATA : w_ltx(10) TYPE c,

w_mnr(2) TYPE c,

w_date TYPE string.

PARAMETERS : pr_date TYPE sy-datum.

              • Month Text for AI letter

SELECT SINGLE ltx

FROM t247

INTO w_ltx

WHERE spras = sy-langu

AND mnr = w_mnr.

CONCATENATE pr_date+6(2) w_ltx pr_date(4) INTO w_date separated by space.

regards

dinesh