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: 

Problem with data format in the excel attachment

marisa_quaresma
Explorer
0 Kudos

Hi.

I am converting the date into a string with this I have "10/04/2010" that is in the date format (MM/DD/YYYY). After sending the email when I open the excel it converts it to a date and puts it like '10-04-2010'. But I really need that the format stays like it is sended because is the user format. I tried to put a simple quote before but it appear '10/04/2010, I don't want the simple quote I only want the date format. Can anyone help? Thanks'

7 REPLIES 7

p190355
Active Contributor
0 Kudos

Hello,

Have you checked the cell format of the Excel file?

This could be the case where date in your program output is correct, but the format for the cell/Column is not correct.

Hope this helps.

Cheers,

Remi

Former Member
0 Kudos

Hi,

Instead of converting it to string, convert it to type c (character) with length 10.

Hope this helps.

Regards

Former Member
0 Kudos

Hi,

DATA : LV_DATFM_KEY TYPE XUDATFM.

DATA : LV_DATE(12) TYPE C.

DATA: LV_YYYY TYPE CHAR4,

LV_YY TYPE CHAR2,

LV_MM TYPE CHAR2,

LV_DD TYPE CHAR2.

SELECT SINGLE

DATFM

INTO LV_DATFM_KEY

FROM USR01

WHERE BNAME = SY-UNAME.

LV_YYYY = SY-DATUM+0(4).

LV_YY = SY-DATUM+2(2).

LV_MM = SY-DATUM+4(2).

LV_DD = SY-DATUM+6(2).

CASE LV_DATFM_KEY.

WHEN '1'.

CONCATENATE LV_DD '.' LV_MM '.' LV_YYYY INTO LV_DATE.

WHEN '2'.

CONCATENATE LV_MM '/' LV_DD '/' LV_YYYY INTO LV_DATE.

WHEN '3'.

CONCATENATE LV_MM '-' LV_DD '-' LV_YYYY INTO LV_DATE.

WHEN '4'.

CONCATENATE LV_YYYY '.' LV_MM '.' LV_DD INTO LV_DATE.

WHEN '5'.

CONCATENATE LV_YYYY '/' LV_MM '/' LV_DD INTO LV_DATE.

WHEN '6'.

CONCATENATE LV_YYYY '-' LV_MM '-' LV_DD INTO LV_DATE.

ENDCASE.

WRITE : / LV_DATE.

Might help you,

Regards,

Thiru

Former Member
0 Kudos

HI marisaq,

This is how excel works and has nothing to do with ABAP...

What you will need to is change the format of the cell from General or Date to Text.

Regards,

Jovito

0 Kudos

OK, if nothing suggested here solves the problem, here is what you should try:

1. workbench->Menu->System->User Profile->Own Data: In the 'Defaults' tab page, choose the format that you want the date to be displayed.

2. In the source program, use 'WRITE TO' statement to a string (source = date) (destination = string variable ).

This makes sure that the file is output with the user setting chosen.

Regards,

-Bino.

marisa_quaresma
Explorer
0 Kudos

Hi.

The 'WRITE TO' gives an error when I try to pass it to a string variable. It only accepts char.

All the other answers didn't worked.

0 Kudos

Here is what i tried, and this works:

lv_char_format TYPE c LENGTH 10.

WRITE lv_pack TO lv_char_format NO-GROUPING DECIMALS 2.