Skip to Content
avatar image
Former Member

Dowload itab into excel

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

10 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 02, 2008 at 06: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06:32 AM

    i think you cant do much about it.if you define field as string then its possible

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06:32 AM

    Hi Priti,

    The same topic has been discussed in this thread.

    Export to Excel - data with leading zeros

    Regards,

    Chandra Sekhar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06: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..

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • avatar image
    Former Member
    Sep 02, 2008 at 06:34 AM

    hi

    refer to this link an similar problem like u have is being solve here

    issue with data download to excel

    Cheers

    Snehi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 06: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 09: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 09:26 AM

    Hi,

    Use FM WS_EXCEL to download internal table data into excel.

    Regards,

    Rajneesh Gupta

    Add comment
    10|10000 characters needed characters exceeded