Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

Tags:
Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question