09-02-2008 7:27 AM
I am using SAP_CONVERT_TO_XLS_FORMAT function module to download internal table into excel.
call function 'SAP_CONVERT_TO_XLS_FORMAT'
exporting
I_FIELD_SEPERATOR = SPACE
I_LINE_HEADER =
I_FILENAME = I_FILENAME
I_APPL_KEEP = ' '
tables
I_TAB_SAP_DATA = itab
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
if SY-SUBRC eq 0.
write 😕 'FILE DOWN LOAD SUCCESUFULLY' ,FULL_PATH.
endif.
The internal table "itab" has field vendor no. i.e. LIFNR having value say "0000000001" But when i download the file only "1" comes into the excel file , the leading zeroes do not come. I want those leading zeroes. how do i do it
09-02-2008 7:32 AM
Hi,
EXCEL generally supress the leading zeroes. If you still want the leading zeroes you can have a add a ' infront of the field. '001 will be displayed in excel as 001.
Hope this helps.
09-02-2008 7:31 AM
hii
it will come as 1 only as it is a problem of EXCEL sheet ...
Have not used this FM but if you have defined FILE TYPE there as ASC then change it to DBF file.it will work.and leading 0 will come.
regards
twinkal
09-02-2008 7:32 AM
i think you cant do much about it.if you define field as string then its possible
09-02-2008 7:32 AM
Hi,
EXCEL generally supress the leading zeroes. If you still want the leading zeroes you can have a add a ' infront of the field. '001 will be displayed in excel as 001.
Hope this helps.
09-02-2008 7:43 AM
But the internal table has many records i.e. many LIFNRs. How do i put ' in front of each record
09-02-2008 7:56 AM
Hi,
You have to loop through the table and put ' and then download it .
09-02-2008 8:12 AM
Yes i have already tried this. But ' is a special character. Then how do it add it.
e.g. begin of itab occurs 0,
lifnr like lfa1-lifnr,
end of itab.
suppose itab now has ten records. Now how do i put ' in front of the value.
09-02-2008 8:18 AM
09-02-2008 8:20 AM
Hi,
Use gui_download and pass file type DBF.
Sample code,
DATA:
BEGIN OF itab OCCURS 0,
lifnr LIKE lfa1-lifnr,
END OF itab.
SELECT lifnr
UP TO 5 ROWS
FROM lfa1
INTO TABLE itab.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\temp\test.xls'
filetype = 'DBF' "File type DBF
* write_field_separator = 'X'
* append = 'X'
TABLES
data_tab = itab[].
Regards
Adil
09-02-2008 9:07 AM
Hi,
Try using FM GUI_DOWNLOAD and pass the filetype as 'DBF'.
This will help.
Regards,
Prashant
09-02-2008 7:32 AM
09-02-2008 7:33 AM
in your internal table put ' (single qoute) before the vendor number, this will ensure when you pass this field to excel, excel wont remove leading zeros..
09-02-2008 7:58 AM
But how do i put a ' in front of the vendor code. The internal table has many records. I am passing the internal table to the function module.
09-02-2008 7:34 AM
09-02-2008 7:38 AM
Hello Priti,
Your problem is not with the SAP, but with Excel. Even though you write 0000000001 in Excel it will display only 1. Try to work on the Excel sheet. Change the cell format to text format instead of Numeric.
Regards,
Naresh Durki
09-02-2008 7:55 AM
hii
i had same problem before.it is possible to have data with leading zeros in excel .for that you need to convert your all integer type data in to character type and then first save one blank .xls file and there give save as type dbf .then check .you will get data with leading zeros in excel sheet.
regards
twinkal
09-02-2008 10:22 AM
Hi Priti,
This field will download as '1' only. You need to make some file settings. After downloading the data, Select that column --> Right Click and select Format Cells --> Choose Text. This will solve the issue.
Regards,
Swapna.
09-02-2008 10:26 AM
Hi,
Use FM WS_EXCEL to download internal table data into excel.
Regards,
Rajneesh Gupta