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: 

How to download output of program2 to excel from program1......

Former Member
0 Kudos

Hi,

i have program1 and program2. i am calling program2 from program1 through submit (PROGRAM2) and return to program1. program2 using REUSE_ALV_HIERSEQ_LIST_DISPLAY to display output. What my requirement is , i need output of program2 in excel format and saved in my PC by calling program1 having input paramete , programname that would be program2.

plz try to solve it.

thanks.....

saurin shah

7 REPLIES 7

Former Member
0 Kudos

Hi

i think you need the output of the program2 by calling program 1.

in that case try this way.

call function module

DOWNLOAD

in program 2 and pass the internal table that is tobe displayed

to the function module .Also specify the filetype as EXCEL.

Regards

Hareesh Menon

0 Kudos

Use Function Module

GUI_DOWNLOAD

Former Member
0 Kudos

Hello Saurin,

Try using either of these function modules

XXL_SIMPLE_API

XXL_FULL_API

Regards

Akmal

Former Member
0 Kudos

see the following example in PART - I, PART-II, AND PART -III.

PART - I

REPORT ZOLE_ABAP.

INCLUDE ole2incl.

TYPES: BEGIN OF ty_spfli,

kunnr TYPE kna1-kunnr,

land1 TYPE kna1-land1,

NAME1 TYPE KNA1-NAME1,

ORT01 TYPE KNA1-ORT01,

REGIO TYPE KNA1-REGIO,

ADRNR TYPE KNA1-ADRNR,

END OF ty_spfli.

TYPES: BEGIN OF ty_titles,

title(20) TYPE c,

field(20) TYPE c,

END OF ty_titles.

DATA: t_spfli TYPE STANDARD TABLE OF ty_spfli,

t_titles TYPE STANDARD TABLE OF ty_titles.

FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,

<fs_titles> LIKE LINE OF t_titles,

<fs> TYPE ANY.

DATA: w_tabix TYPE sy-tabix,

w_titles TYPE sy-tabix,

w_line TYPE sy-tabix,

w_field TYPE string,

filename TYPE string,

path TYPE string,

fullpath TYPE string.

DATA: data_titles TYPE REF TO data.

DATA: e_sheet TYPE ole2_object,

e_activesheet TYPE ole2_object,

e_newsheet TYPE ole2_object,

e_appl TYPE ole2_object,

e_work TYPE ole2_object,

e_cell TYPE ole2_object,

e_color TYPE ole2_object,

e_bold TYPE ole2_object.

SELECTION-SCREEN BEGIN OF BLOCK b1.

PARAMETERS: p_file TYPE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

PERFORM get_titles.

PERFORM get_data.

PERFORM create_excel.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = 'Select archivo'

default_extension = 'xls'

file_filter = '*.xls'

CHANGING

filename = filename

path = path

fullpath = fullpath.

IF sy-subrc EQ 0.

p_file = fullpath.

ENDIF.

Former Member
0 Kudos

PART -II

FORM get_titles.

CREATE DATA data_titles TYPE ty_titles.

ASSIGN data_titles->* TO <fs_titles>.

<fs_titles>-title = 'Customer Number 1'.

<fs_titles>-field = 'KUNNR'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Country Key'.

<fs_titles>-field = 'LAND1'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Name 1'.

<fs_titles>-field = 'NAME1'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'City'.

<fs_titles>-field = 'ORT01'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Region'.

<fs_titles>-field = 'REGIO'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Address'.

<fs_titles>-field = 'ADRNR'.

APPEND <fs_titles> TO t_titles.

ENDFORM. "get_titles

FORM get_data.

SELECT KUNNR LAND1 NAME1 ORT01 REGIO ADRNR

INTO TABLE t_spfli

FROM KNA1

WHERE LAND1 EQ 'IN'

and KUNNR EQ '0000700008'.

ENDFORM. " get_data

FORM create_excel.

w_line = 1.

CREATE OBJECT e_appl 'EXCEL.APPLICATION'.

SET PROPERTY OF e_appl 'VISIBLE' = 1.

CALL METHOD OF e_appl 'WORKBOOKS' = e_work.

CALL METHOD OF e_work 'Add' = e_work.

GET PROPERTY OF e_appl 'ActiveSheet' = e_activesheet.

SET PROPERTY OF e_activesheet 'Name' = 'Customer Details'.

LOOP AT t_spfli ASSIGNING <fs_spfli>.

w_tabix = sy-tabix.

w_line = w_line + 1.

LOOP AT t_titles ASSIGNING <fs_titles>.

w_titles = sy-tabix.

CALL METHOD OF e_appl 'Cells' = e_cell

EXPORTING

#1 = 1

#2 = w_titles.

SET PROPERTY OF e_cell 'Value' = <fs_titles>-title.

GET PROPERTY OF e_cell 'Interior' = e_color.

SET PROPERTY OF e_color 'ColorIndex' = 35.

GET PROPERTY OF e_cell 'Font' = e_bold.

SET PROPERTY OF e_bold 'Bold' = 1.

CALL METHOD OF e_appl 'Cells' = e_cell

EXPORTING

#1 = w_line

#2 = w_titles.

CONCATENATE '<fs_spfli>-' <fs_titles>-field

INTO w_field.

ASSIGN (w_field) TO <fs>.

SET PROPERTY OF e_cell 'Value' = <fs>.

GET PROPERTY OF e_cell 'Interior' = e_color.

SET PROPERTY OF e_cell 'ColumnWidth' = 20.

SET PROPERTY OF e_color 'ColorIndex' = 0.

GET PROPERTY OF e_cell 'Font' = e_bold.

SET PROPERTY OF e_bold 'Bold' = 0.

ENDLOOP.

ENDLOOP.

Former Member
0 Kudos

PART - III

CALL METHOD OF e_work 'SAVEAS'

EXPORTING

#1 = p_file.

CALL METHOD OF e_work 'close'.

CALL METHOD OF e_appl 'QUIT'.

FREE OBJECT e_appl.

ENDFORM. " create_excel

Former Member
0 Kudos

using open dataset concept download data when i call program2 from program1 and using that internal table (which i used for ALV ),in open dataset concept and save excel file in application server. Solved By Self.