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: 

getting Char to Date field when i write to Excel

Former Member
0 Kudos

HI,

I am facing funny problem.

I have a varialble, please see below

I_LGTYP TYPE CHAR10

I_LGTYP = '01-01-01'.

when i write this value into XLS file using GUI_DOWNLOAD FM, It is converting as Date and writing in Excel as 1/1/2001

i tried different options by declaring I_LGTYP as NUM10 and then it is writing as 10101

String same as CHAR.

please tell me how can i reslove this problem as i would like to see in Excel as 01-01-01.

I tried typing 01-01-01 in excel it immediatley changed to date format 1/1/2001, then i tried '01-01-01 and this time it works.

Thanks

Sarath

1 ACCEPTED SOLUTION

Former Member
0 Kudos

so, put your leading single quote on the value and "fool" Excel. This is an Excel "feature" that we've all had to deal with....there are other fixes, I'm sure.

And, seriously, Microsoft products cause such severe problems....so, search the forums for these basic problems....it's been asked a few hundred times before....

Edited by: BreakPoint on Nov 10, 2011 5:36 PM

6 REPLIES 6

surajarafath
Contributor
0 Kudos

HI before you filling up your internal table fields,

just write statement like...

WRITE WA_FIELD TO I_LGTYP DD/MM/YYYY.

I_LGTYP will be containing in date format.

0 Kudos

hi suji thanks for replay

I am not sure if this statement is going to work as i would want to see output 01-01-01 in Excel not as Date format but as Text filed, and more over the value can be some times 01-01 or VS1-002 or 0180000026 or PACKING

thanks

sb

0 Kudos

You can enter a quote into a text field by typing 3 single quotes. The first quote is used to begin the string, the other two quotes used to indicate to SAP that a quote is to be escaped.

DATA: I_LGTYP TYPE CHAR10.

I_LGTYP = '''01-01-01'.

0 Kudos

Vishnu, thanks for reply

how can i send variable insted of value?

for example if i send like below

WA_RECORD-STO_BIN = '''WA_LQUA-LGPLA'.

Note : WA_LQUA-LGPLA variable has value 01-01-01

If i write above statement in program the output I am getting in excel as WA_LQUA-LG (since the variable is 10 long)

thanks

SB

Former Member
0 Kudos

so, put your leading single quote on the value and "fool" Excel. This is an Excel "feature" that we've all had to deal with....there are other fixes, I'm sure.

And, seriously, Microsoft products cause such severe problems....so, search the forums for these basic problems....it's been asked a few hundred times before....

Edited by: BreakPoint on Nov 10, 2011 5:36 PM

0 Kudos

Guys,

it worked if i write code like below

CONCATENATE '''' WA_LQUA-LGPLA INTO WA_LQUA-LGPLA.

WA_RECORD-STO_BIN = WA_LQUA-LGPLA.

thanks for all your comments