Application Development 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: 

Convert date!

former_member329522
Participant
0 Kudos

I´ve a date like this: 08.05.2006

I wanna show it like 08 de Mayo de 2006 (it´s spanish)

Thanks !

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi julio,

1. 08 de Mayo de 2006.

2. I have made in INDEPENDENT FORM Subroutine,

where we pass the date, and it returns in spanish,

eg. 08 de Mayo de 2006.

3. just copy paste in new program.

REPORT abc.

DATA : mname(25) TYPE c.

PARAMETER : d TYPE sy-datum default sy-datum.

PERFORM getmonth USING d mname.

WRITE 😕 mname.

*----


*

*----


FORM getmonth USING d mname.

DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.

DATA : m(2) TYPE c.

m = d+4(2).

CALL FUNCTION 'MONTH_NAMES_GET'

EXPORTING

  • LANGUAGE = SY-LANGU

LANGUAGE = 'S'

  • IMPORTING

  • RETURN_CODE =

TABLES

month_names = month_names

EXCEPTIONS

month_names_not_found = 1

OTHERS = 2

.

READ TABLE month_names INDEX m.

IF sy-subrc = 0.

mname = month_names-ltx.

ENDIF.

concatenate d+6(2) 'de' mname 'de' d(4) into mname separated by space.

ENDFORM. "getmonth

regards,

amit m.

10 REPLIES 10

Former Member
0 Kudos

Hii

use fm <b>'HR_IN_GET_DATE_COMPONENTS '</b>then use can make that using <b>OFFSET</b>

In your program, have a logic to get the User's country. You shd be able to get this from the user master Tx: SU01.

Then use the statement as below, where <country> is the user's country.

SET COUNTRY <COUNTRY>.

write lv_date to lv_date_usr_format.

Now lv_date_usr_format will have the date in the country format set using the "SET CouNTRY" statement.

thanks&Regards

Naresh

Former Member
0 Kudos

use table t247 with elect logic...

parameters: date like sy-datum.

data: begin of itab occurs 0,

SPRAS type SPRAS,

MNR LIKE T247-MNR,

KTX LIKE T247-KTX,

LTX LIKE T247-LTX,

end of itab.

DATA : month LIKE T247-MNR.

DATA: YEAR(4).

DATA: FINAL(18).

DATA: DAY(2).

DAY = DATE+6(2).

MONTH = DATE+4(2).

YEAR = DATE+0(4).

select SINGLE * from t247 into itab where mnr = month

AND SPRAS = 'ES'.

APPEND ITAB.

CONCATENATE DAY ITAB-LTX YEAR INTO FINAL SEPARATED BY '-'.

WRITE: FINAL.

Message was edited by: kishan negi

Former Member
0 Kudos

Hi julio,

Please check the below code,


* Call func to get date components
    CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
      EXPORTING
        IDATE                         = GD_DATE
      IMPORTING
        DAY                           = GD_DAYS
        MONTH                         = GD_MONTH
        YEAR                          = GD_YEAR
        LTEXT                         = GD_TEXT
      EXCEPTIONS
        INPUT_DATE_IS_INITIAL         = 1
        TEXT_FOR_MONTH_NOT_MAINTAINED = 2
        OTHERS                        = 3.

  

Then you can concatenate them as you need.

cancatenate gd_day gd_text gd_year into gd_var

separated by space.

for 05/08/2006 , It will give you output 8 May 2006.

Or you cna also get month description from table <b>T247</b>, you can pass SPRAS = 'ES'.

Thanks&Regards,

Siri.

Message was edited by: Srilatha T

hymavathi_oruganti
Active Contributor
0 Kudos

data: date(10),date1(20).

date = '08.05.2006'.

concatenate date0(2) ' de Mayo de ' date6(4) into date1 separated by space.

write date1.

sbhutani1
Contributor
0 Kudos

Hi

You can split the date like this

In sap date is stored like this YYYYMMDD

You can store first 4 characters in a variable

then next 2 character in another

data: yyyy(4) type c,

mm(2) type c,

dd(2) type c,

date1 like sy-datum,

sdate(15) type c.

yyyy = date1+0(4).

mm = date1+4(2).

dd = date1+6(2).

concatenate dd, 'de', mm, 'de', yyyy into sdate.

Hope this will help

Regards

Sumit Bhutani

Ps reward points if helpful

guillaume-hrc
Active Contributor
0 Kudos

Hi Julio,

Check out the FM <b>'CONV_EXIT_LDATE_OUTPUT_LANGU'</b>.

Provide the date in internal format and the target language.

Best regards,

Guillaume

former_member416164
Participant
0 Kudos

Hi,

You can do it by writing your date using :

Day : date_field(2)

Year : date_field+6(4)

Month : use funciotn module MONTH_NAMES_GET to get a list of month in text and then use date_field+3(2) to search the correct month

Hope this help

Former Member
0 Kudos

Hi julio,

1. 08 de Mayo de 2006.

2. I have made in INDEPENDENT FORM Subroutine,

where we pass the date, and it returns in spanish,

eg. 08 de Mayo de 2006.

3. just copy paste in new program.

REPORT abc.

DATA : mname(25) TYPE c.

PARAMETER : d TYPE sy-datum default sy-datum.

PERFORM getmonth USING d mname.

WRITE 😕 mname.

*----


*

*----


FORM getmonth USING d mname.

DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.

DATA : m(2) TYPE c.

m = d+4(2).

CALL FUNCTION 'MONTH_NAMES_GET'

EXPORTING

  • LANGUAGE = SY-LANGU

LANGUAGE = 'S'

  • IMPORTING

  • RETURN_CODE =

TABLES

month_names = month_names

EXCEPTIONS

month_names_not_found = 1

OTHERS = 2

.

READ TABLE month_names INDEX m.

IF sy-subrc = 0.

mname = month_names-ltx.

ENDIF.

concatenate d+6(2) 'de' mname 'de' d(4) into mname separated by space.

ENDFORM. "getmonth

regards,

amit m.

Former Member
0 Kudos
REPORT ychatest.

DATA:it_months TYPE TABLE OF t247,
       wa_months TYPE t247.

data : p_date like sy-datum,
       year(4),
       month(2),
       date(2),
       mon_desc(10),
       date1(25).

p_date = sy-datum.

CALL FUNCTION 'MONTH_NAMES_GET'
 EXPORTING
   LANGUAGE             = 'S'
  TABLES
    month_names         = it_months.

year = p_date+0(4).
month = p_date+4(2).
date = p_date+6(2).

read table it_months into wa_months with key mnr = month.

mon_desc = wa_months-ltx.

concatenate date 'de' mon_desc 'de' year into date1 separated by space.

write : date1.

Message was edited by: Chandrasekhar Jagarlamudi

0 Kudos

JUST COPY AND PASTE IT IS WORKIN.....

REPORT ZNEGI3 .

parameters: date like sy-datum.

data: begin of itab occurs 0,

SPRAS type SPRAS,

MNR LIKE T247-MNR,

KTX LIKE T247-KTX,

LTX LIKE T247-LTX,

end of itab.

DATA : month LIKE T247-MNR.

DATA: YEAR(4).

DATA: FINAL(18).

DATA: DAY(2).

DAY = DATE+6(2).

MONTH = DATE+4(2).

YEAR = DATE+0(4).

select SINGLE * from t247 into itab where mnr = month

AND SPRAS = 'S'.

APPEND ITAB.

CONCATENATE DAY ITAB-LTX YEAR INTO FINAL SEPARATED BY '-'.

WRITE: FINAL.