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: 

GUI_DOWNLOAD with leading zeros

Former Member
0 Kudos

Dear All,

I have a requirement to download from table to excel file. I use FM GUI_DOWNLOAD.

I need the zero value in a columns is not truncated.

For example : column1 --> "112"

                      column2 --> "002"

After we call GUI_DOWNLOAD, we got the excel file, but unfortunately the value of column2 is "2". We need to get the column2 as "002".

I try to concatenate the column with single quotation " ' " before call FM GUI_DOWNLOAD and expect the excel file will consider these fields as string.

But the result is still not as expectation. The column is displayed as " '002' " (with quotation) instead of " 002 " (without quotation).

Also i try to use the datatype "DAT" or "ASC" but still not getting the zeros value.

Please kindly help.

Thanks in advance.

8 REPLIES 8

Kartik2
Contributor
0 Kudos

Hi,

In this case, it is property of excel to delete the leading zeroes, even if you type the number 002 on an unformatted excel sheet, then it will be converted to 2. To avoid this you have to set the formatting property of that column to text, and then write values to that column.

This can be achieved in abap by using OLE concepts. You have to do the following steps.

1. Open a new excel workbook using OLE

2. Change the formatting for cells where you want leading zeroes to text

3. Paste the data into excel sheet

4. Save the excel sheet at a desired location on presentation server.

To get an idea of the usage of OLE concepts in ABAP you can refer the following document:

The purpose of this document and your requirement are completely different but you can use the OLE concepts mentioned there, you can learn how to convert a VBA macro to abap code using OLE.

Hope it helps you. thank you.

Regards,

Kartik

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi ,

you can check my reply here

  1. IF ls_fcat-inttype = 'C'.     "Character 
  2. SET PROPERTY OF lo_column 'NumberFormat' = '@'
  3. ENDIF.

The above code will take care of that.

0 Kudos

Hi

Try to use fm conversion_exit_alpha_input which will add leading zeros to a field, as the data get populated in the internal table call the fm and modify it. your problem will get solved.

0 Kudos

It's not solve the problem, because actually the field in the itab itself is already has zero.

The problem is when converting from itab into file.

0 Kudos

Hi,

The removal of zero and addition of zero depends upon the excel column properties which can be controlled from using office integration only. Use OLE and download the data. Your problem will be solved.

0 Kudos

Hi There,

If you have defined it like numeric type this may happen , please define it like character type and I hope it will work.

Please let me know if I am wrong.

thanks

Rahul

0 Kudos

Hi

As keshav told removal and adding of zeros depends on excel column properties, try to change properties in excel as per the field.

engin_akdenizz
Explorer
0 Kudos

Hi Beta Yunaswati,

Use the function module to add leading zeros to field CONVERSION_EXIT_ALPHA_INPUT. After that add it in to table. This FM adds zero to left free spaces. I hope it will help.