Application Development and Automation 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: 
Read only

move internal table to excel

Former Member
0 Likes
970

hi,

Maybe some now how i move(in program) internal table to excel?

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
945

Hi,

Use this function module.

ALSM_EXCEL_TO_INTERNAL_TABLE

<REMOVED BY MODERATOR>

Regards

Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:32 PM

hi,

Maybe some now how i move(in program) internal table to excel?

Regards

8 REPLIES 8
Read only

Former Member
0 Likes
946

Hi,

Use this function module.

ALSM_EXCEL_TO_INTERNAL_TABLE

<REMOVED BY MODERATOR>

Regards

Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:32 PM

Read only

Former Member
0 Likes
945

hi ,

look this..

REPORT ZTESTPROG003.

TYPES:

BEGIN OF ty_upload,

matnr like mara-matnr,

meins like mara-meins,

mtart like mara-mtart,

mbrsh like mara-mbrsh,

END OF ty_upload.

DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH header line.

DATA wa_upload TYPE ty_upload.

DATA: itab TYPE STANDARD TABLE OF alsmex_tabline WITH header line.

  • DATA itab TYPE STANDARD TABLE OF ty_upload WITH header line.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = 'C:\Documents and Settings\venkatapp\Desktop\venkat.xls'

i_begin_col = 1

i_begin_row = 1

i_end_col = 4

i_end_row = 65535

TABLES

intern = itab.

if not itab[] is initial.

loop at itab .

case itab-col.

when '0001'.

it_upload-matnr = itab-value.

when '0002'.

it_upload-meins = itab-value.

when '0003'.

it_upload-mtart = itab-value.

when '0004'.

it_upload-mbrsh = itab-value.

append it_upload.

clear it_upload.

clear itab.

endcase.

endloop.

endif.

loop at it_upload.

write:/ it_upload-matnr,it_upload-meins,it_upload-mtart,it_upload-mbrsh.

endloop.

regards,

venkat.

Read only

Former Member
0 Likes
945

Hi,

Check this out. This is a simple FM.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

EXPORTING

i_filename = gf_file

TABLES

i_tab_sap_data = gt_output

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc = 0.

gf_error = 1. "To check if the data is converted to excel format

ENDIF.

<REMOVED BY MODERATOR>

Regards,

Ramya

Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:32 PM

Read only

0 Likes
945

HI Ramya Bashyam

I use your fm but i have erorr when i open the excel

file format is not valid.

what can be the problem?

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
    EXPORTING
      i_filename        = 'C:\Documents and Settings\Desktop\Book1.xls'
    TABLES
      i_tab_sap_data    = it_p40
    EXCEPTIONS
      conversion_failed = 1
      OTHERS            = 2.

what can

Read only

0 Likes
945

Hi,

Change everything to CAPITALS here in the line mentioned below.

'C:\Documents and Settings\Desktop\Book1.xls'

<REMOVED BY MODERATOR>

REgards.

Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:32 PM

Read only

0 Likes
945

Hi

i try to change it to capitals but i have same erorr,

maybe its because of i use office 2007?

Regards

Read only

Former Member
0 Likes
945

hi,

use this FM

ALSM_EXCEL_TO_INTERNAL_TABLE

Read only

Former Member
0 Likes
945

Hi,

Use the FM 'SAP_CONVERT_TO_XLS_FORMAT'

OR

Using GUI_download u can download into excel format

OR

Use the following code:

types: begin of t_excel,

val1(20) type c,

val2(20) type c,

end of t_excel.

data: it_scarr type table of scarr.

data: wa_scarr type scarr.

data: it_excel type table of t_excel.

data: wa_excel type t_excel.

select * into table it_scarr from scarr.

wa_excel-val1 = 'Field 1'.

wa_excel-val2 = 'Field 2'.

append wa_excel to it_excel.

loop at it_scarr into wa_scarr.

wa_excel-val1 = wa_scarr-carrid.

wa_excel-val2 = wa_scarr-currcode.

append wa_excel to it_excel.

endloop.

call method cl_gui_frontend_services=>gui_download

exporting

filename = 'C:/test1.xls'

write_field_separator = 'X'

changing

data_tab = it_excel.

<REMOVED BY MODERATOR>

Thanks.

Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:33 PM