Leading zeroes dropped in Excel
Hello folks
I've got an issue with using downloading data onto an Excel file using the FM GUI_Download. The leading zeroes of the PERNR field get truncated when opening the file with MS Excel.
However the zeroes are in place when the downloaded file is opened with notepad or any other text editor.
Is there any solution to prevent Excel from dropping the leading zeroes.
I'm currently using tab as the field separator, and have defined the PERNR field as TYPE C at the internal table used for populating and displaying the data.
Hi,
data:matnr(20) type c.
concatenate text-001 g_t_ekpo-matnr into g_t_ekpo-matnr.
text-001 is having '.
I had declared the Matnr as type c so that it can accomodate that single quote.It is indeed downloading the matnr with preceeding zeroes into the excel but along with the single quote.Can't we get the preceeding zeroes into excel without the single quote into the excel.
Thanks,
Kiran.
Similar Messages
-
Need leading Zeros in the excel sheet which is sent from ABAP
Hi ,
I am downloading data from SAP to excel sheet using the WS_DOWNLOAD Function Module. The numeric data in not having leading zeros. if it is 0010 it is displaying 10 in the excel sheet . i need the leading zeros in the excel sheet. without manulally changing it to Text in the excel sheet .
Is there any way to do it .
Thanks,
ChetanHi Chetan,
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = w_file_path
filetype = 'DBF' "declare the File type as DBF then leading zeros will appear
write_field_separator = 'X'
confirm_overwrite = 'X'
TABLES
data_tab = Itab.
Regards,
Prabhudas -
Leading zeros in downloaded excel
Hi,
I'm facing a problem with truncated leading zeros in downloaded excel. Can anybody suggest me how to get those leading zeros in excel.
I tried Function modules XXL_FULL_API and WS_DOWNLOAD, both did not work.
Regards,
PraveenaHi Praveena,
check the following code.
data : begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
matnr2 like mara-matnr,
end of itab.
itab-matnr = '00000011111'.
itab-maktx = 'test1'.
itab-matnr2 = '00000011112'.
append itab.
itab-matnr = '00000033333'.
itab-maktx = 'test2'.
itab-matnr2 = '00000044444'.
append itab.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'D:\c.xls '
FILETYPE = 'WK1'
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 = itab
FIELDNAMES =
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
NO_AUTHORITY = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
nagaraj -
How to retain leading zeros in an excel sheet
Hi,
In my application I need to export the response from a struts action class to an excel sheet. I have done the coding but while exporting to the excel , the leading zeros are getting truncated. If the value is '01' it is displayed as '1' only.
response.setContentType("application/text");
response.setHeader("Content-disposition",
"Attachment;filename=\"export.xls\"");
response.getOutputStream().println(data);
response.getOutputStream().flush();This is the code which I am using to export all the data to the excel.Here the variable data is a String .
Kindly help on this issue.
Thanks in advance...
Edited by: 2569 on Jan 10, 2008 8:59 PM
Edited by: 2569 on Jan 10, 2008 9:51 PM2569 wrote:
I tried that way also, but its not working. I have defined all the values as strings only. Thanks for ur replyWhich API are you using to write excel files? You can try to surround the numeric string value with singlequotes (or escaped doublequotes)String numericString = "'01'";so that Excel interprets it as string. -
Hi all,
I need to create a cheque lot using FQP6A, however, the leading zeros are dropped. eg: 0123456, changed to 12345.
Is this standard? Or is there missing configuration.
Please advise.Hello,
It is the standard functionlaity of the system that Leading zeros are not displayed.
You could review note 10714 for more info....
Hope this helps.
Regards
Olivia -
Download records to EXCEL file with Leading Zero's for numbers
Hi All,
I am able to download the data to EXCEL file on the presentation server.
There are few fields (Plant,SalesOrder Number ..with Leading Zero's) in the record.
These values are downloaded with out Leading Zero's to excel( EX: 0000004122 as 4122).
Please help me to download the data to EXCEL file with leading zero's.
Thanks and Regards,
KC>
Krishna Chaitanya G wrote:
> The excel file which is to be downloaded..will be used by some other program..to upload the values to the sap.
> It matters there....
> KC
HI KC,
then no need to download the zeros,
after uploading, loop at that uploaded internal table and use CONVERSION_EXIT_APLHA_INPUT and pass the vbeln(without zeros) to this FM, it will return the value with added zeros.
hope this solves your query
a small example
Loop at itab into is.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = is-vbeln "( this is without zeros)
IMPORTING
OUTPUT = is-vbeln. "( this is with leading zeros)
modify itab from is.
endloop.
Edited by: Soumyaprakash Mishra on Oct 6, 2009 2:16 AM -
Leading zeroes are being suppressed in excel output
I have a template that prints our item number field. This field is alpha-numeric, but sometimes it is all numeric with leading zeroes. I have it defined as a text field in my template. It prints correctly (with the leading zeroes) in the PDF output, but it suppresses the leading zeros in the excel output. Is there any way to stop it from doing this - I want it to be a text field.
Thanks. That sort of works. In the excel output, it is truncating the field after the first 4 digits even though the length is defined as 'unlimited'. In the PDF output, it prints the double quotes around the field.
-
Leading zeros are removed when uploading excel
Hi All,
I have created a program to send an email with an excel attachment but the leading zero's in excel are removed. can anybody suggest what can be done other than replace since that exceeds 255chars so i cant concatenate.Hi
Try adding the character ' (single quote) before the actual value. Excel then treats the value as-is whithout conversion
character type for columns
data: h_columns TYPE ole2_object,
h_cell TYPE ole2_object.
CALL METHOD OF excel 'Columns' = h_columns
EXPORTING
#1 = 'F:K'.
set property of h_columns 'NumberFormat' = '@'.
CALL METHOD OF excel 'Cells' = h_cell
EXPORTING
#1 = 14
#2 = 7.
SET PROPERTY OF h_cell 'Value' = '0001'. -
How to keep leading zeros using SAP_CONVERT_TO_XLS_FORMAT
my leading zeros drop when download using FM-SAP_CONVERT_TO_XLS_FORMAT, how to fix it?
Hi,
You can try as below.
Let's for the 10 digit numeric field, using the function module CONVERSION_EXIT_ALPHA_INPUT, you can get the 10 digit number with leading zeroes.
Now if you declare the char of 10 in length field in the internal table will be replaced with the above value.
Now it will be downloaded as required.
Regards,
Nishant Malhotra -
Excel copy drops leading zeros
I have records with a part number that is a text field, but contains digits. When I export to excel, the excel spreadsheet drops leading zeros from the part number.
How do I get the export to treat this as a text field and retain the zeros.
No, I have no option to make this a number field.When the report is displayed on the screen initially for column "blah" the Conditional Display PL/SQL Expression "INSTR(NVL(:REQUEST,'YABBADABBADO'),'EXCEL') = 0" evaluates to TRUE because REQUEST does not have 'EXCEL' in it causing the value to display on the screen. For column "blah_excel" the Conditional Display PL/SQL Expression "INSTR(NVL(:REQUEST,'YABBADABBADO'),'EXCEL') != 0" evaluates to FALSE because REQUEST does not have 'EXCEL' in it causing "blah_excel" to not display.
When the user clicks to download to CSV the page's REQUEST has 'EXCEL' in it. I think actual request value is 'FLOW_EXCEL'. For column "blah" the Conditional Display PL/SQL Expression "INSTR(NVL(:REQUEST,'YABBADABBADO'),'EXCEL') = 0" evaluates to FALSE because REQUEST has 'EXCEL' in it causing the value to not appear in the CSV. For column "blah_excel" the Conditional Display PL/SQL Expression "INSTR(NVL(:REQUEST,'YABBADABBADO'),'EXCEL') != 0" evaluates to TRUE because REQUEST does have 'EXCEL' in it causing "blah_excel" to appear in the CSV.
http://mikerife.blogspot.com/2007/08/preserve-leading-zeros-in-apex-csv.html
Mike -
Export to Excel dropping leading zeroes
Hi,
I have used the 'Export' feature of the form and is working well except it drops the leading zeroes on some columns.
I have defined them as string so it should retain them. How can I keep the zeroes?
Thank you.When you say that is dropping the zeros only for a few columns, is it working fine for other columns having leading zeros? If yes, check the type of data defined for the placeholder bean and the data type of the corresponding VO column.
--Shiv -
Leading zeros are dropped when exporting as csv
I have a report that when I export as csv, leading zeros in text columns are dropped in excel. The text columns appear fine in the report, however, when I export the leading zero is gone in excel. For example, in the report my text column could have a value of 0101, when it is exported to excel it has a value of 101. The code behind the link to export to csv is f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:FLOW_EXCEL_OUTPUT_R#REGION_ID#
Is there a way to keep the leading zero in excel?
Regards
MarkThanks for your reply. In my query I wrapped the column with double quotes as you suggest, and added the same column for display:
select '"'||column1||'"' execl_col, column1 disp_col from table where ....
Using htmldb_application.g_excel_format as a conditional display I can control what is displayed on the screen and export to csv the double quoted text field. I have that part working fine. Using my previous data example, I am now seeing in excel 0101"".
Did I wrap the field incorrectly with double quotes? How can I exclude the
double quotes in the export to csv?
Regards
Mark -
Export to Excel - data with leading zeros
Does anyone have any tips or tricks for running a query then exporting to Excel without dropping leading zeros from the data?
Examples: numeric Item codes with leading zeros, telephone numbers that have been entered with no spaces.
Regards,
Douglas McDove< Font Color="RED" Size = 3 Face=Verdana>
I liked the challenge and therefore.......I got this for you
</Font>
SELECT CHAR(28) + T0.CardCode [BP Code\] FROM [dbo\].[OCRD\] T0
SELECT CHAR(29) + T0.CardCode [BP Code\] FROM [dbo\].[OCRD\] T0
SELECT CHAR(30) + T0.CardCode [BP Code\] FROM [dbo\].[OCRD\] T0
SELECT CHAR(31) + T0.CardCode [BP Code\] FROM [dbo\].[OCRD\] T0
Any of the above 4 should work. T0.CardCode is the database field I tested, you can substitute this with any database field and it should work.
Regards
Suda -
Truncation of leading Zeros when Down Loading into Excel - OLE Objects
Hi,
Can any one help me on this.
I am using <b>OLE Objects</b> to download Data into Excel Sheet. Data with leading Zeros is getting truncated in Excel.
Ex: Report Output is showing Plant Number as 0002. But when i am downloading to Excel Plant value will become 2 .
I would like to have it as 0002 in Excel.
I have declared Werks as CHAR of 4.I am using OLE Obects for Downloading into Excel Sheet.
I am using "OLE2_OBJECT" I can not use any other FMs to down load to Excel.As i am modifying this program not creating.
Thanks In Advance.
K.Nirmala
Message was edited by: Nirmala ReddyHi Nirmala,
While downloading to excel sheet, u need to change the number format of cell from General to Text, then leading zero's won't get deleted. For that u need to set the property of the cell. Please check this sample code,
INCLUDE OLE2INCL.
tables : zobrent.
data : it_kna1 type table of zobrent with header line.
handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
H_MAPL TYPE OLE2_OBJECT, " list of workbooks
H_MAP TYPE OLE2_OBJECT, " workbook
H_ZL TYPE OLE2_OBJECT, " cell
H_F TYPE OLE2_OBJECT. " font
DATA H TYPE I.
DATA: cell1 TYPE ole2_object.
*& Event START-OF-SELECTION
START-OF-SELECTION.
select * from zobrent into table it_kna1
where zopanid = '10001'
and zo_brent = '050'.
start Excel
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
SET PROPERTY OF H_EXCEL 'Visible' = 1.
get list of workbooks, initially empty
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP.
PERFORM ERR_HDL.
output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'EDate'.
PERFORM FILL_CELL USING 1 2 1 'Brent'.
PERFORM FILL_CELL USING 1 3 1 'Zopanid'.
PERFORM FILL_CELL USING 1 4 1 'Contract Type'.
PERFORM FILL_CELL USING 1 5 1 'Price Type'.
PERFORM FILL_CELL USING 1 6 1 'Installation Type'.
PERFORM FILL_CELL USING 1 7 1 'Volume'.
PERFORM FILL_CELL USING 1 8 1 'AQ'.
PERFORM FILL_CELL USING 1 9 1 '00000123'.
LOOP AT IT_KNA1.
copy values to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_KNA1-zo_effdat.
PERFORM FILL_CELL USING H 2 0 IT_KNA1-zo_brent.
PERFORM FILL_CELL USING H 3 0 IT_KNA1-zopanid.
ENDLOOP.
CALL METHOD OF h_excel 'Cells' = cell1
EXPORTING
#1 = 1
#2 = 1.
FREE OBJECT H_EXCEL.
PERFORM ERR_HDL.
if sy-subrc eq 0.
write : / 'year'(001).
endif.
FORM FILL_CELL
sets cell at coordinates i,j to value val boldtype bold
FORM FILL_CELL USING I J BOLD VAL.
CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
GET PROPERTY OF H_ZL 'Font' = H_F.
PERFORM ERR_HDL.
SET PROPERTY OF H_F 'Bold' = BOLD .
PERFORM ERR_HDL.
***Changing the format of the cell from General to Text
<b>SET PROPERTY OF H_ZL 'NumberFormat' = '@'.</b>
PERFORM ERR_HDL.
SET PROPERTY OF H_ZL 'Value' = VAL .
PERFORM ERR_HDL.
ENDFORM.
*& Form ERR_HDL
FORM ERR_HDL.
IF SY-SUBRC <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
U just paste this code in a sample program & see.
Please reward, if found helpful. -
Hello,
I am downloading few fields from HR infotypes into Excel sheet, I'm using cl_ABAP_char_utilities=>Horizontal_tab to separate the fields. I'm not getting leading zeros. I have tried with 'DAT', 'CSV' and 'WK1' file formats instead of 'ASC', but the flat file format is changing. I have tried ' ' ' symbol. I am getting leading zeros along with that symbol. Now, I need to remove the symbol. Any suggetions...
Thanks and regards,
PNM Rajudude,
it's just a regular concatenate statement using a non blank space like the old HTML  .
It doesn't show properly in the editor here on SDN. Just try it n see if it executes by putting a space there.
I think it would wind up looking something like CONCATENATE ' ' MEAN-EAN11 INTO Z_L_ITAB-EAN11.
If you're on a laptop or a keyboard without the 10key plus on the right, you'll probably have to hold the [[fn]] key down too.
So in ABAP type CONCATENATE '<-- right here put the [[fn]][[ALT]]0160 and you should see it place what looks like a space right there.
Try it
Maybe you are looking for
-
Accessing External Hard Drive on PC
I have my airport extreme connected to my PC via ethernet and connected wirelessly to my Mac Book. I cannot connect to the external hard drive through my PC. Whenever I enter my base station password I keep getting an error message that the user is n
-
Buttons do not appear correctly in Firefox
My company uses IE 7 as their standard browser within the company. I am developing an extranet application so that the public can access my company's information. Since APEX supports both IE and Firefox, the application needs to appear the same in bo
-
Load Error in WinForms Designer
Error 2 'MyForm.Form1' does not contain a definition for 'Form1_Load' and no extension method 'Form1_Load' accepting a first argument of type 'MyForm.Form1' could be found (are you missing a using directive or an assembly reference?) Interestingly en
-
General SYSVOL migration from FRS to DFSR
Hi all. I have a question regarding Sysvol Migration from FRS to DFSR. We have migrated all of our Domain Controllers from Server 2003 to Server 2008 R2 about 2 years ago. I know that if Server 2003 was in use initially and you upgrade to Server 2008
-
Ldmp2v prepare :could not parse manifest
Source OS: solaris 8 (sunfire v125) as the required, patchadd 109318-39 "ldmp2v collect -d /export/yy -a flash yy" generates "manifest"and "yy.flar",copy the two file to the target machine. then on the target machine "ldmp2v prepare -d /root/yy yy"