Leading zeros in XLS sheet
Hello Experts,
I have one report in ALV format. It is displayed perfect.
When we download it into XLS format it appends leading zeros in 'NETWORK no' Field.
Can you all please help me how to remove it?
Remember, ALV is showing perfect o/p. So
CONVERSION_EXIT_ALFA_OUTPUT or any other FM in that category is of no use.
Also there is no code to download in XLS. User selects Standord procedure to download from ALV.
But he is getting Leading zeros.
I would be thankful for the help.
Best Regards,
Harish
HI Joshia,
Lets consider you are downloading MATNR which comes with leading Zero.
We solve this by below case .
you can download the value in character format with preceding single quote .
if you are downloading 000010 means, assign that value as '000010.
So that, excel can treat it as character & the zeros will be retained.
While uploading the data to internal table it_material
CONCATENATE '"' it_material-matnr into it_material-matnr.
append it_material.
Similar Messages
-
Excel file attachment withiout losing leading zeros
Hi Expert,
Can anybody tell me how to create the Excel file attachment for email generation without losing the leading zeros.
Regards,
JyotsnaHi,
If you want to pass a variable with leading zeros to excel sheet, please use the following:
CONCATENATE '=TEXT(' l_variable ',"000")' INTO g_errcode1.
It will display the leading zeros in excel sheet. I have done the same way in one of my program and it is working fine..
Thanks & Regards
Rocky Agarwal -
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. -
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 deleted while downloading to excel sheet
Hi ,
i am downloading data to excel sheet from internal table, iam using gui_download but its deletin leading zeros can any one tell me as to how i go about this
for ex i ahve a mterial no : 00123
i see 123 i want it to be 00123
Thanks
kajolHi,
try to explain to excel, that this field is character field (I think that it will be done by adding single quote as first character of string).
Pointing to my previous answer try:
Constants: c_single_quote(1) type c value ''''. " I _hope_ it works
loop at itab.
concatenate c_single_quote itab-matnr to texttab-c_matnr.
endloop. -
Facing problem with the code for sending an .xls attachment via email, a field value contains leading zeros but excel automatically removes these from display i.e. (00444 with be displayed as 444).kindly guide .
Hi Chhayank,
the problem is not the exported xls. If you have a look inside with Notepad or something like that, you will see that your leading zeros are exported correct.Excel-settings occurs this problem, it is all about how to open the document. If you use the import-assistant you will have no problems because there are options available how to handle the different columns.
Another solution might be to get familiar with ABAP2XLS-Project. I got in my mind, that there is a method implemented, that will help you solving this problem. But that is not a five minute job
~Florian -
Downloading data from internal table to xls file leading zeros are not disp
Hai abap gurus,
when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
Ex:
<b>ECC Code.</b>
045234
88567
098456
but output is giving like this:
45234
88567
98456
how to get the actual values.....
plz help me in this matter.Dear Kiran,
Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
Then use the function module to download the content of the internal table to the excel file.
Regards,
Abir
Don't forget to Reward Points * -
IR - Column with leading Zeros issue
Hello,
I've got an IR report which includes as "default report settings" 1 column with leading 0s. In order to export to Excel that column as text rather than as a numeric I followed a workaround proposed before in this forum (excel copy drops leading zeros
In essence this workaround is to create an identifical column but in "excel text format" and display the columns depending on the request value: INSTR(NVL(:REQUEST,'YABBADABBADO'),'CSV') <> 0 for example.
This works just fine for the default report.
The problem arise when a user creates his own customise report that includes the mentioned column and saves it as a named report. Here, when the results are exported to excel the "excel" column does not appear.
In fact, just hiding one of the displayed columns produces the same undesired result.
I would appreciate any comments or suggestions.
Many thanks
Edited by: Javier Gil on Jul 20, 2010 7:52 AMI have found a better method. In your IR query:
SELECT LPAD(v.vendor, 7, ' ') vendor,
/*Just LPAD to a length of the column defined in the database table or to 7, whichever is greater. */
FROM v, r
WHERE v.VENDOR = r.VENDOR
AND date_rcv <= to_date(:P150_CUTOFF,'yyyy/mm/dd')
AND inv_nbr = ' '
AND to_stores <> 'T'
AND (V.VENDOR = RPAD(:P150_VENDOR,10,' ') OR :P150_VENDOR = 'ALL')
When you download to Excel by Download/XLS (Request=XLS), it preserves the leading zeros.
In the case of dates, you should LPAD 10 minimum in this format.
LPAD(to_char(date_rcv,'MM/DD/YY'), 10, ' ') date_rcv,
I haven’t tried it yet but I think in the case of ‘MM/DD/YYYY’, you should LPAD 12 minimum in this format.
LPAD(to_char(date_rcv,'MM/DD/YYYY'), 12, ' ') date_rcv,
Drawbacks of this method:
Since the string has leading white spaces, you cannot use the filter for the ‘=’ comparison operator. Even filtering using leading white spaces will not return anything. You must use the LIKE and NOT LIKE operator instead.
Advantages of this method over the original one I posted yesterday:
1) You do not have to create another column for download, just one column will suffice.
2) Even though the query has leading white spaces, they will not display in the IR region.
Edited by: richardlee on Aug 5, 2010 11:10 AM
Edited by: richardlee on Aug 5, 2010 11:16 AM -
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. -
Leading zeros from data downloads
Hello!
While downloading data from the ABAP tables, Excel removes the leading zeros automatically but in some SAP tables (NAST for example), those leading zeros are necessary to find the required associated data. Is there any way to prevent Excel from removing these zeros?
Thanks a lot!Hi,
There are two ways to solve it.
1) select complete columns in the Excel sheet and then assign the number format as ' TEXT ' in the sheet.Then u ll be able to see the leading zero's
2) If u donot want to wrk in Excel the way i have mentioned,then in the abap program just use the FM
"CONVERSION_EXIT_ALPHA_INPUT" over that field before uploading in a table.
By mistake i have told u the wrong way.the first way is for copying the data from text file to excel file and preserving the leading zeros.
regards
kanishak
Edited by: Kanishak Gupta on May 6, 2009 5:36 AM -
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 -
Export to Excel - leading zeros problem
Hello,
I wrote an application, which exports the data from an internal table into an excel file.
I defined a variable as char20. The variable contains the value '000256'.
When I generate the excel file, the leading zeros are cut and so only the value 256 is stored into the cell.
Is it possible to prevent the cut of the zeros?
Best regards & Thanks in advance
Here is a part of may code:
conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = gv_content
IMPORTING
buffer = gv_xtext.
attach the first file
conv_out->convert( exporting data = gv_xtext ).
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'file1.XLS'
i_content = gv_xtext
i_mime_type = 'application/msexcel'
i_in_new_window = abap_true
i_inplace = abap_true ).you could add an apostrophe ' in front of all fields that you want exported as a text.
this will ensure no truncating is done.
it's excel that does the shifting, so you can't really interfere from the SAP side -
Grid Download to Excel truncates leading zeros
We are on tools 8.51. The download feature for a Grid now removes the leading zeros when the grid is downloaded to excel. Has anyone found a way to fix this issue ? Thanks in advance
When you download from PS query, the output is created as a true binary xls file, but when you download from a grid in PT 8.51 the output file is html, even though the filename is ps.xls. You can open this file in a text editor.
If you have all numeric data in a column, it will be stored as <td>nnnnnn</td> in the html file. if the column has mixed numeric and text data, it will be stored as <td>=&quot;nnnnnn&quot;</td>. The leading zeroes are still there in both cases, but when excel imports the first form it will convert the result to numeric, the second it will treat as text.
Other than logging a case with Oracle, the only workaround I could think of would be to save the file to disk and run the macro directly against the html. Of course, this would likely be a major redesign.
Regards,
Bob -
Leading Zeros Missing - When exporting data from ALV grid display to Excel
Hi,
Am exporting the data from ALV GRID DISPLAY to Excel sheet using standard toolbar icon 'Local file'
the leading zeros displayed in the ALV output is missing in the EXCEL sheet.
(eg) in ALV o/p - 0029.
in Excel - Only 29 is appearing.
As per the requiement i have to show the leading zeros in excel also.
Pls help on this issue.
Thanks in advance..Hi ,
Please set the property :
wa_fieldcat-lzero = 'X' .
when you are creating field catalog for display alv data .
your prob will solved .
Regards ,
Nilesh Jain -
Leading zeros are not displaying in the excel
Hi Experts,
Leading zeros are not displaying in the excel
Here is the situation:
I have developed one report, which will create the file in Application server with TAB deleimeted. After that I am sending that file via email in the excel format using Email functionality FM.
Normally our material numbers will start with zeros.
But when I check the email excel file , leading zeros are not displaying.
Even I checked the application server (AL11) file, zeros are there.
I thought program FM was wrong and I tried it manually by downloading the file into excel. Eventhough it is suppressing zeros.
Could you please advise, how to display leading zeros to the material number in excel file.
Thanks in advance
RaghuApplication server file showing zeros infront of the material number.
1200# 0012401387# XXXXXXXX
Once file created in app server, I am using one custom FM to send that output in excel format / txt format via email.
when I send txt file via email, I am getting leading zeros. But when I send xls file via email, I am not getting zeros.
I checked custom FUNCTION MODULE . No mistakes in that.
===
Sudhir,
As you said, I passed ( ' ) single quote infront of the material number. When I check the excel file, single quote also displaying like this '0000100.
Application server file showing like below
1200# '0012401387# XXXXXXXX
===
Could you please advise anyone how can we acheive this.
Thanks
Maybe you are looking for
-
I'm going on a hike tomorrow with my dad and I'd been reluctant to download iTunes on my new laptop but finally decided to install it so I could have new music for the trip. I bought nearly ninety new songs, all of which appeared in my library, and
-
Icloud no longer syncs to PC after ios7 upgrade
what can I do? I tried repairing the install of icloud, the "My Photo Stream" folder is empty, no new pictures and no old ones are in the folder any longer. I have both an iPad 2 and iphone 4 both used to sync instantly before upgrade
-
HELP! GENERIC Host Process For Win32 SERVI
I updated my drivers the other day now I can't keep my sound working. A few minuts after I reboot I get this message "GENERIC Host Process For Win32 SERVICES". So I tried to uninstall all previous installed drivers and reinstall the newest ones. This
-
Watching Netflix movies via cable to TV
I bought an AV cable to watch movies on my TV which are streamed to my iPhone 4 using the Netflix App. I can watch movies just fine on the iphone, but not so on the TV. The audio gets to the TV, but not the video. What setting do I need to change or
-
Check ztable in ME21N create purchase order
Hi, I maintain one ztable for price comparision ( comparative statement) is completed or not for particular RFQ Collective. if price comparision completed when Flag 'C' is updated in ztable for that particular Collective No. So, my requirement is :