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: 

Excel sheet need to display

former_member623843
Participant
0 Kudos
321

Dear all,

I Have down loaded some data into application server. Now my requirement is I need to show those data in excel sheet. Nothing but when I hit F8 an excel sheet need to display (open) automatically.

Thanks & regards

mahaboob

1 ACCEPTED SOLUTION

Former Member
0 Kudos
81

Hi;

1. You have 2 option to use SAP Fm "XXL_FULL_API" OR

2. Code using OLE automation

3. If you have you report output in ALV then you have the option to dowload?

Regards,

Prabhu Rajesh

5 REPLIES 5

Former Member
0 Kudos
82

Hi;

1. You have 2 option to use SAP Fm "XXL_FULL_API" OR

2. Code using OLE automation

3. If you have you report output in ALV then you have the option to dowload?

Regards,

Prabhu Rajesh

0 Kudos
81

use FM 'XXL_FULL_API' only

ole has lot of performens issues.

&----


*& Report ZTEST_ECXEL

*&

&----


*&

*&

&----


REPORT ZTEST_ECXEL.

TABLES:

sflight.

DATA :

header1 LIKE gxxlt_p-text VALUE 'Pavan',

header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.

DATA BEGIN OF t_sflight OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA END OF t_sflight.

DATA BEGIN OF t_hkey OCCURS 0.

INCLUDE STRUCTURE gxxlt_h.

DATA END OF t_hkey .

DATA BEGIN OF t_vkey OCCURS 0.

INCLUDE STRUCTURE gxxlt_v.

DATA END OF t_vkey .

DATA BEGIN OF t_online OCCURS 0.

INCLUDE STRUCTURE gxxlt_o.

DATA END OF t_online.

DATA BEGIN OF t_print OCCURS 0.

INCLUDE STRUCTURE gxxlt_p.

DATA END OF t_print.

DATA BEGIN OF t_sema OCCURS 0.

INCLUDE STRUCTURE gxxlt_s.

DATA END OF t_sema.

SELECT * FROM sflight

INTO TABLE t_sflight.

t_online-line_no = '1'.

t_online-info_name = 'Created by'.

t_online-info_value = 'RK'.

APPEND t_online.

t_print-hf = 'H'.

t_print-lcr = 'L'.

t_print-line_no = '1'.

t_print-text = 'This is the header'.

APPEND t_print.

t_print-hf = 'F'.

t_print-lcr = 'C'.

t_print-line_no = '1'.

t_print-text = 'This is the footer'.

APPEND t_print.

t_vkey-col_no = '1'.

t_vkey-col_name = 'MANDT'.

APPEND t_vkey.

t_vkey-col_no = '2'.

t_vkey-col_name = 'CARRID'.

APPEND t_vkey.

t_vkey-col_no = '3'.

t_vkey-col_name = 'CONNID'.

APPEND t_vkey.

t_vkey-col_no = '4'.

t_vkey-col_name = 'FLDATE'.

APPEND t_vkey.

t_hkey-row_no = '1'.

t_hkey-col_no = 1.

t_hkey-col_name = 'PRICE'.

APPEND t_hkey.

t_hkey-col_no = 2.

t_hkey-col_name = 'CURRENCY'.

APPEND t_hkey.

t_hkey-col_no = 3.

t_hkey-col_name = 'PLANETYPE'.

APPEND t_hkey.

t_hkey-col_no = 4.

t_hkey-col_name = 'SEATSMAX'.

APPEND t_hkey.

t_hkey-col_no = 5.

t_hkey-col_name = 'SEATSOCC'.

APPEND t_hkey.

t_hkey-col_no = 6.

t_hkey-col_name = 'PAYMENTSUM'.

APPEND t_hkey.

t_sema-col_no = 1.

t_sema-col_typ = 'STR'.

t_sema-col_ops = 'DFT'.

APPEND t_sema.

t_sema-col_no = 2.

APPEND t_sema.

t_sema-col_no = 3.

APPEND t_sema.

t_sema-col_no = 4.

APPEND t_sema.

t_sema-col_no = 5.

APPEND t_sema.

t_sema-col_no = 6.

APPEND t_sema.

t_sema-col_no = 7.

APPEND t_sema.

t_sema-col_no = 8.

APPEND t_sema.

t_sema-col_no = 9.

APPEND t_sema.

t_sema-col_no = 10.

t_sema-col_typ = 'NUM'.

t_sema-col_ops = 'ADD'.

APPEND t_sema.

CALL FUNCTION 'XXL_FULL_API'

EXPORTING

filename = 'TESTFILE'

header_1 = header1

header_2 = header2

no_dialog = 'X'

no_start = ' '

n_att_cols = 6

n_hrz_keys = 1

n_vrt_keys = 4

sema_type = 'X'

TABLES

data = t_sflight

hkey = t_hkey

online_text = t_online

print_text = t_print

sema = t_sema

vkey = t_vkey

EXCEPTIONS

cancelled_by_user = 1

data_too_big = 2

dim_mismatch_data = 3

dim_mismatch_sema = 4

dim_mismatch_vkey = 5

error_in_hkey = 6

error_in_sema = 7

file_open_error = 8

file_write_error = 9

inv_data_range = 10

inv_winsys = 11

inv_xxl = 12

OTHERS = 13

.

IF sy-subrc eq 0.

ENDIF.

0 Kudos
81

Hi kumar,

Thanks for your reply.

But in my code iam getting dump.

Can you please check it once and let me know.

REPORT Z_READFILE.

DATA: BEGIN OF I_MARA OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

ERNAM LIKE MARA-ERNAM,

END OF I_MARA.

SELECT MATNR

ERSDA

ERNAM

FROM MARA

INTO TABLE I_MARA.

CALL FUNCTION 'XXL_FULL_API'

EXPORTING

  • DATA_ENDING_AT = -1

  • DATA_STARTING_AT = 1

FILENAME = 'testfile'

  • HEADER_1 = ' '

  • HEADER_2 = ' '

NO_DIALOG = 'X'

NO_START = ' '

n_att_cols = 6

n_hrz_keys = 1

n_vrt_keys = 4

SEMA_TYPE = 'X'

  • SO_TITLE = ' '

tables

data = i_mara

  • hkey =

  • online_text =

  • print_text =

  • sema =

  • vkey =

EXCEPTIONS

CANCELLED_BY_USER = 1

DATA_TOO_BIG = 2

DIM_MISMATCH_DATA = 3

DIM_MISMATCH_SEMA = 4

DIM_MISMATCH_VKEY = 5

ERROR_IN_HKEY = 6

ERROR_IN_SEMA = 7

FILE_OPEN_ERROR = 8

FILE_WRITE_ERROR = 9

INV_DATA_RANGE = 10

INV_WINSYS = 11

INV_XXL = 12

OTHERS = 13

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Waiting for your reply..

Former Member
0 Kudos
81

do like this..

Report ZMULTICOLOR_TEST no standard page heading.

  • this report demonstrates how to send some ABAP data to an

  • EXCEL sheet using OLE automation.

include ole2incl.

  • 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

h_c type ole2_object. " color

DATA: FILENAME LIKE RLGRAP-FILENAME.

tables: spfli.

data h type i.

  • table of flights

data: it_spfli like spfli occurs 10 with header line.

&----


*& Event START-OF-SELECTION

&----


start-of-selection.

  • read flights

select * from spfli into table it_spfli.

  • display header

uline (61).

write: / sy-vline no-gap,

(3) 'Flg'(001) color col_heading no-gap, sy-vline no-gap,

(4) 'Nr'(002) color col_heading no-gap, sy-vline no-gap,

(20) 'Von'(003) color col_heading no-gap, sy-vline no-gap,

(20) 'Nach'(004) color col_heading no-gap, sy-vline no-gap,

(8) 'Zeit'(005) color col_heading no-gap, sy-vline no-gap.

uline /(61).

  • display flights

loop at it_spfli.

write: / sy-vline no-gap,

it_spfli-carrid color col_key no-gap, sy-vline no-gap,

it_spfli-connid color col_normal no-gap, sy-vline no-gap,

it_spfli-cityfrom color col_normal no-gap, sy-vline no-gap,

it_spfli-cityto color col_normal no-gap, sy-vline no-gap,

it_spfli-deptime color col_normal no-gap, sy-vline no-gap.

endloop.

uline /(61).

  • tell user what is going on

call function 'SAPGUI_PROGRESS_INDICATOR'

exporting

  • PERCENTAGE = 0

text = text-007

exceptions

others = 1.

  • start Excel

create object h_excel 'EXCEL.APPLICATION'.

  • PERFORM ERR_HDL.

set property of h_excel 'Visible' = 1.

  • CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls' .

  • PERFORM ERR_HDL.

  • tell user what is going on

call function 'SAPGUI_PROGRESS_INDICATOR'

exporting

  • PERCENTAGE = 0

text = text-008

exceptions

others = 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.

  • tell user what is going on

call function 'SAPGUI_PROGRESS_INDICATOR'

exporting

  • PERCENTAGE = 0

text = text-009

exceptions

others = 1.

  • output column headings to active Excel sheet

perform fill_cell using 1 1 1 200 'Carrier id'(001).

perform fill_cell using 1 2 1 200 'Connection id'(002).

perform fill_cell using 1 3 1 200 'City from'(003).

perform fill_cell using 1 4 1 200 'City to'(004).

perform fill_cell using 1 5 1 200 'Dep. Time'(005).

loop at it_spfli.

  • copy flights to active EXCEL sheet

h = sy-tabix + 1.

if it_spfli-carrid cs 'AA'.

perform fill_cell using h 1 0 000255000 it_spfli-carrid.

elseif it_spfli-carrid cs 'AZ'.

perform fill_cell using h 1 0 168000000 it_spfli-carrid.

elseif it_spfli-carrid cs 'JL'.

perform fill_cell using h 1 0 168168000 it_spfli-carrid.

elseif it_spfli-carrid cs 'LH'.

perform fill_cell using h 1 0 111111111 it_spfli-carrid.

elseif it_spfli-carrid cs 'SQ'.

perform fill_cell using h 1 0 100100100 it_spfli-carrid.

else.

perform fill_cell using h 1 0 000145000 it_spfli-carrid.

endif.

if it_spfli-connid lt 400.

perform fill_cell using h 2 0 255000255 it_spfli-connid.

elseif it_spfli-connid lt 800.

perform fill_cell using h 2 0 077099088 it_spfli-connid.

else.

perform fill_cell using h 2 0 246156138 it_spfli-connid.

endif.

if it_spfli-cityfrom cp 'S*'.

perform fill_cell using h 3 0 155155155 it_spfli-cityfrom.

elseif it_spfli-cityfrom cp 'N*'.

perform fill_cell using h 3 0 189111222 it_spfli-cityfrom.

else.

perform fill_cell using h 3 0 111230222 it_spfli-cityfrom.

endif.

if it_spfli-cityto cp 'S*'.

perform fill_cell using h 4 0 200200200 it_spfli-cityto.

elseif it_spfli-cityto cp 'N*'.

perform fill_cell using h 4 0 000111222 it_spfli-cityto.

else.

perform fill_cell using h 4 0 130230230 it_spfli-cityto.

endif.

if it_spfli-deptime lt '020000'.

perform fill_cell using h 5 0 145145145 it_spfli-deptime.

elseif it_spfli-deptime lt '120000' .

perform fill_cell using h 5 0 015215205 it_spfli-deptime.

elseif it_spfli-deptime lt '180000' .

perform fill_cell using h 5 0 000215205 it_spfli-deptime.

else.

perform fill_cell using h 5 0 115115105 it_spfli-deptime.

endif.

endloop.

  • EXCEL FILENAME

CONCATENATE SY-REPID '_' SY-DATUM6(2) '_' SY-DATUM4(2) '_'

SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.

CALL METHOD OF H_MAP 'SAVEAS' EXPORTING #1 = FILENAME.

free object h_excel.

perform err_hdl.

----


  • FORM FILL_CELL *

----


  • sets cell at coordinates i,j to value val boldtype bold *

----


form fill_cell using i j bold col val.

call method of h_excel 'Cells' = h_zl

exporting

#1 = i

#2 = j.

perform err_hdl.

set property of h_zl 'Value' = val .

perform err_hdl.

get property of h_zl 'Font' = h_f.

perform err_hdl.

set property of h_f 'Bold' = bold .

perform err_hdl.

set property of h_f 'Color' = col.

perform err_hdl.

endform. "FILL_CELL

&----


*& Form ERR_HDL

&----


  • outputs OLE error if any *

----


  • --> p1 text

  • <-- p2 text

----


form err_hdl.

if sy-subrc <> 0.

write: / 'OLE-Automation Error:'(010), sy-subrc.

stop.

endif.

endform. " ERR_HDL

sachin_mathapati
Contributor
0 Kudos
81

Hi ,

You can create a report to download data from application server into an internal table and then download it into Presentation server.

Step 1. Download data from application server to internal table

Wf_filename = file path on application server

OPEN DATASET wf_filename FOR INPUT IN BINARY(TEXT) MODE.

DO.

CLEAR : wf_row.

READ DATASET wf_filename INTO wf_row.

  • Tab delimited File

SPLIT wf_row AT delimiter INTO TABLE tb_data.

Enddo.

Step 2. _ Download itab to Excel_

'ALSM_EXCEL_TO_INTERNAL_TABLE'

You can use this FM to Download internal table to excel sheet.

Reward Points if helpful

Regards,

Sachin M M