2008 Feb 26 10:20 AM
Hello abaper,
Please tell me how xxlftest works.
I have to create a report that will download data from a table in a excel file like xxlftest report.
But i m not able to learn how xxlftest is working if any of u know then plz tell me.
Also tell me abt the parameters of xxl_full_api
means which parameter is optional n which is required n what is the purpose of each parameter.
Hello abaper,
Please tell me how xxlftest works.
I have to create a report that will download data from a table in a excel file like xxlftest report.
But i m not able to learn how xxlftest is working if any of u know then plz tell me.
Also tell me abt the parameters of xxl_full_api
means which parameter is optional n which is required n what is the purpose of each parameter.
2008 Feb 26 10:33 AM
hi
Please refer sample sap program
RSDEMO01 To display list output in Excel
Also
Please use FM XXL_FULL_API.
You can refer report program XXLFTEST or XXLTTEST.
Try the following code
This program demonstrates how to send abap data to excel sheet
using OLE automation
include ole2incl.
*handles for OLE object
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
data: h type i.
types: begin of t_bkpf,
bukrs type bkpf-bukrs,
belnr type bkpf-belnr,
gjahr type bkpf-gjahr,
blart type bkpf-blart,
budat type bkpf-budat,
end of t_bkpf.
data: it_bkpf type standard table of t_bkpf,
wa_bkpf type t_bkpf.
********start-of-selection*******************
start-of-selection.
select bukrs
belnr
gjahr
blart
budat into table it_bkpf
from bkpf
up to 10 rows.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-001
exceptions
others = 1.
Start excel
create object h_excel 'EXCEL.APPLICATION'.
perform err_hdl.
set property of h_excel 'Visible' = 1.
perform err_hdl.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-002
exceptions
others = 1.
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.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-003
exceptions
others = 1.
Output Column Headings to active excel sheet
perform fill_cell using 1 1 1 text-004.
perform fill_cell using 1 2 1 text-005.
perform fill_cell using 1 3 1 text-006.
perform fill_cell using 1 4 1 text-007.
perform fill_cell using 1 5 1 text-008.
Copy internal table to excel sheet
loop at it_bkpf into wa_bkpf.
h = sy-tabix + 1.
perform fill_cell1 using h 1 0 wa_bkpf-bukrs.
perform fill_cell2 using h 2 0 wa_bkpf-belnr.
perform fill_cell1 using h 3 0 wa_bkpf-gjahr.
perform fill_cell1 using h 4 0 wa_bkpf-blart.
perform fill_cell1 using h 5 0 wa_bkpf-budat.
endloop.
disconnect from Excel
free object h_excel.
perform err_hdl.
&----
*& Form err_hdl
&----
text
-
--> p1 text
<-- p2 text
-
form err_hdl .
if sy-subrc <> 0.
write: / 'Error in OLE Automation'.
stop.
endif.
endform. " err_hdl
&----
*& Form fill_cell
&----
text
-
-->P_1 text
-->P_1 text
-->P_1 text
-->P_TEXT_004 text
-
form fill_cell using i j bold 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 'colorindex' = 10.
endform. " fill_cell
&----
*& Form fill_cell1
&----
text
-
-->P_H text
-->P_1 text
-->P_0 text
-->P_WA_BKPF_BUKRS text
-
form fill_cell1 using i j bold 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.
endform. " fill_cell1
&----
*& Form fill_cell2
&----
text
-
-->P_H text
-->P_2 text
-->P_0 text
-->P_WA_BKPF_BELNR text
-
form fill_cell2 using i j bold 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 'colorindex' = 13.
endform. " fill_cell2
check the following link
http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
Best regards,
sreelatha gullapalli
2008 Feb 26 10:41 AM
but there is no report named rsdem001 n also i m refering to xxlftest but i m able to learn how it is working n also i want to know abt the parameters of xxl_full_api
2008 Mar 26 1:49 PM
parameters for XXL_FULL_API
N_VRT_KEYS ---> No. of Key Columns
N_ATT_COLS ---> No. of non Key Columns
N_HRZ_KEYS ---> No. of rows to be used in Excel to display column names of non
key columns.
DATA_STARTING_AT ---> From which line actual data start in DATA table.
The data which is displayed in excel is not the complete
DATA table. It's only from DATA_STARTING_AT to the
DATA_ENDING_AT.
DATA_ENDING_AT ---> See above DATA_STARTING_AT.
SEMA_TYPE ---> This is used for special processing of date field as key column
NO_DIALOG ---> Not used, and it's obsolete
TABLES parameter:
VKEY ---> Defines KEY Columns
HKEY ---> Defines column name for Non key columns
DATA ---> Actual data which is exported
SEMA ---> Defines Semantic and source information of data.
Important fields of SEMA Table are
COL_NO- column number of excel
COL_TYP - defines the type of data and format of data to be set in excel
COL_SRC - the source column of data in DATA table
COL_OPS - used with Pivot Table
COL_CUR - used to define a coulmn in excel of type currency
ONLINE_TEXT ---> used with Pivot Table option
PRINT_TEXT ---> used with Pivot Table option
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |