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: 

Date conversion from YYYYMMDD to DD.MM.YYYY

Former Member
0 Kudos

Hi,

I'm trying to load some data from a flat file into BW. I have a date column in the CSV file that has the date in YYYYMMDD format. when I load it into Bw, I want to change the format to DD.MM.YYYY .

I have written a small routine that should do this, but it doesn't seem to work.


data:v_date like sy-datum,

v_date1(10) type c.

Concatenate v_date+6(2) '.' v_date+4(2) '.' v_date+0(4) into v_date1.

RESULT = V_DATE1.

The result of this routine is YY.YYMM.DD instead of DD.MM.YYYY.

Can anyone tell me where I'm going wrong?

Thanks

Sam

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use Write statement using EDIT MASK .you can achieve the result.

WRITE .... EDIT MASK .....

ex:

data : ldate type sy-datum,

wdate type char10.

ldate = sy-datum.

write ldate TO wdate USING EDIT MASK '____.__.__'.

WRITE : / wdate.

Edited by: Ramesh Hirial on Jan 31, 2008 3:45 PM

15 REPLIES 15

Former Member
0 Kudos

Hi,

Use Write statement using EDIT MASK .you can achieve the result.

WRITE .... EDIT MASK .....

ex:

data : ldate type sy-datum,

wdate type char10.

ldate = sy-datum.

write ldate TO wdate USING EDIT MASK '____.__.__'.

WRITE : / wdate.

Edited by: Ramesh Hirial on Jan 31, 2008 3:45 PM

0 Kudos

Thanks to all of you for your help. All of your codes work, but the result is still the same. It display the values as YY.YYMM.DD instead of DD.MM.YYYY.

The CSV file is been created by a program in a different system. The date field is a general number. when i try to change the format of the column to 'date', the ouput of the column is '###########' . Could this be one of the reason as to why the code is not inverting the values and keeping it the same?

Regards,

Sam

0 Kudos

Your code is right only. It is working perfectly. Problem may be because of the type of result field.

Can you try to write the value of v_date1.

0 Kudos

Hi,

Thanks again for the help. the problem was with the setting of my system date. I had them as DD.MM.YYYY. When I changed it to YYYY.MM.DD and ran the routine, it worked great.

Now I'm still getting a error for the rows where there is no date present. How can I have the system disregard the blank date column and still take the rest of the record?

I'm assigning points for all you that helped.

Regards

Sam

0 Kudos

only fetch the record whete date is not initial.

ex: loop at itab where date ne space.

endloop.

0 Kudos

sorry its like this

loop at itab where date is not initial.

endloop.

0 Kudos

Hi Keshu,

When I add the loop to my code, it doesn't seem to work. It gives me the following error:

does not match the user-dependent date format --> long text

Diagnosis

does not correspond to the date format that is assigned to the current user ASDSAD.

System Response

The date cannot be converted; the process was terminated.

Procedure

Enter the conversion exit RSDAT for automatic date format detection.

Any suggestions?

0 Kudos

This is new to me...may be probs in some system format specs..

try this.

data:v_dat(10) type c.

loop at itab.

v_dat = itab.-date.

if v_dat is not initial.

process u r code.

endif.

endloop.

revert is any probs occurs....:-)

Former Member

Hi,

Use FM CONVERSION_EXIT_PDATE_OUTPUT.

Thanks,

Sriram Ponna.

Former Member
0 Kudos

Hi,

Try like this..


data:v_date like sy-datum,
 
v_date1(12) type c.
 
Concatenate v_date+6(2) '.' v_date+4(2) '.' v_date+0(4) into v_date1.
 
RESULT = V_DATE1.

regards,

Omkar.

Former Member
0 Kudos

use fm CONVERT_DATE_TO_EXTERNAL /CONVERT_DATE_TO_INTERNAL

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = lv_date1

dtype = 'DATS'

IMPORTING

idate = lv_date2.

write lv_date2.

Former Member
0 Kudos

data v_date type sydatum.

v_date = '20081225'.

data v_date1 type string.

concatenate v_date6(2) '.' v_date4(2) '.' v_date+0(4) into v_date1.

write v_date1.

Just try this...

The coding which u have written is correct only...

Reward if helpfull.

Former Member
0 Kudos

Hi,

Try this

concatenate lv_date6(2) lv_date4(2) lv_date+0(4) into lv_date_temp separated by '.'.

Some of the FM used are:

CONVERT_DATE_TO_INTERN_FORMAT

CONVERT_DATE_FORMAT

CONVERSION_EXIT_PDATE_OUTPUT

Regards,

Satish

kesavadas_thekkillath
Active Contributor
0 Kudos

data:date(10) type c.

write sy-datum to date.

write date.

this will be sufficient...date holds value like 31.01.2008

Former Member
0 Kudos

Hi

use

convert_date_to_external or

convert_field_to_extern_format

in SAP date is tored as YYYYMMDD

so use sy-datum and pass the value to it

Reward if useful.