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: 

issue with data download to excel

Former Member
0 Kudos

Hi all,

iam downloading data from table to excel sheet.

when i see in the excel sheet i don't see the leading zero's

say if i have value in table as 0001234 but in excel when i download i see as 1234

instead i want it exactly it is in my table

this is the code

data : begin of it_heading occurs 0,

line(30) type c,

end of it_heading.

it_heading-line = 'ABC'.

append it_headING.

it_headING-line = 'XYZ'.

append it_headING.

call function 'WS_DOWNLOAD'

exporting

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

filename = p_file

filetype = 'DAT'

mode = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

tables

data_tab = it_data

fieldnames = it_heading

exceptions

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

others = 10

.

if sy-subrc eq 0.

endif.

Thanks

Kajol

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

in that FM there is parameter called 'FILE TYPE'

pass the value for it as 'DBF'

it will work.

data : begin of it_heading occurs 0,
line(30) type c,
end of it_heading.

it_heading-line = 'ABC'.
append it_headING.
it_headING-line = 'XYZ'.
append it_headING.

call function 'WS_DOWNLOAD'
exporting
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
filename = p_file
<b>filetype = 'DBF'</b>
mode = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = it_data
fieldnames = it_heading
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
.
if sy-subrc eq 0.



endif.

Change all the fields not to be truncated, into character type in the internal table and then download it.

Also use Function Module: CONVERSION_EXIT_ALPHA_INPUT

Regards

Naresh

10 REPLIES 10

former_member583013
Active Contributor
0 Kudos

Use GUI_DOWNLOAD instead of WS_DOWNLOAD.

Greetings,

Blag.

0 Kudos

the declaration of the field has to be in numeric to see the zeros but check if the FM allows you with numc type. also use the latest FM GUI_download instead of ws_download.

0 Kudos

Hi ,

I am trying to pullout material number and its a char and its SAP standard.

Iam using ws_download because i want the heading to the excel sheet too.

do gui_down load have this facility if yes please send the sample code

Thanks

kajol

Former Member
0 Kudos

Hi

in that FM there is parameter called 'FILE TYPE'

pass the value for it as 'DBF'

it will work.

data : begin of it_heading occurs 0,
line(30) type c,
end of it_heading.

it_heading-line = 'ABC'.
append it_headING.
it_headING-line = 'XYZ'.
append it_headING.

call function 'WS_DOWNLOAD'
exporting
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
filename = p_file
<b>filetype = 'DBF'</b>
mode = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = it_data
fieldnames = it_heading
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
.
if sy-subrc eq 0.



endif.

Change all the fields not to be truncated, into character type in the internal table and then download it.

Also use Function Module: CONVERSION_EXIT_ALPHA_INPUT

Regards

Naresh

0 Kudos

Hi Naresh,

its working fine except for the date field i am seeing ##### but when i increase the column width in the downloaded excel sheet i can see the date like02/02/2006 any particular reason for that .

does gui_download have the same functionality

let me know

thanks

kajol

0 Kudos

Hi,

I tried the following option and it doesnt work.

<b>filetype = 'DBF'</b>

Former Member
0 Kudos

Hi Kajol,

It has nothing to do with ALV functionality..

The problem is with excel..

One possible solution is increase the output len in field catalog.

<b> X_FIELDCATALOG-OUTPUTLEN = '10'.</b>

Reward points for helpful entries.

Revert back for more help

Regards

Naresh

0 Kudos

Hi naresh,

sorry i didnot get you ,ALV WE ARE NOT USING ALV

WHAT AboUT MY SECOND QUESTION DOES gui_download have the same functionality

Thanks

kajol

0 Kudos

The date field has nothing to do with the progarm, only with excel sheet. you can try increasing the length in the progam for the date field before pushing to excel and check it.

gui_download has got some extra features when compared to ws_download.

You can check this for some info

http://help.sap.com/saphelp_erp2005/helpdata/en/79/c554a3b3dc11d5993800508b6b8b11/frameset.htm

http://www.sapdevelopment.co.uk/file/file_otherpc.htm

WS_UPLOAD and WS_DOWNLOAD, the function modules used until now are not part of the standard set of ABAP commands. They are used to display the file interface on the presentation server. WS_UPLOAD and WS_DOWNLOAD are not compatible with USs and have been replaced by GUI_UPLOAD and GUI_DOWNLOAD.

The new function modules, GUI_UPLOAD and GUI_DOWNLOAD, have an interface that also allows you to write Unicode format to the local hard drive. For a description of these interfaces, refer to the documentation for each function module, available under SAP Easy Access " Development " Function Builder " Goto " Documentation.

Instead of using the function modules, you can use the static methods GUI_UPLOAD and GUI_DOWNLOAD of the global class CL_GUI_FRONTEND_SERVICES.

award points if it helps.

0 Kudos

Hi all,

Thanks all for the time .

awarded points to all

Thanks

kajol