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: 

using "XXL_SIMPLE_API" FM to export report to Excel.

Madhurivs23
Participant
0 Kudos

Hi All,

I am using the FM "XXL_SIMPLE_API" to export the alv report ( which is done using "reuse_alv_grid_display" FM ).

In that I want to send the data which we generally show using the "top_of_page" event of the ALV.

This data I passed to the table "XMPLT_O" . but no data is coming in the Excel file.

Please help me to sort out this problem.

thanks in advance.

Rgds,

MadhuriG

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

you don't pass correct parameters to XXL_SIMPLE_API. So could you show and explain us your code. Please do a preview before you post so that it appears well formatted. Thx

6 REPLIES 6

Sandra_Rossi
Active Contributor
0 Kudos

you don't pass correct parameters to XXL_SIMPLE_API. So could you show and explain us your code. Please do a preview before you post so that it appears well formatted. Thx

0 Kudos

I am using program "XXLSTEST" for reference.



XMPLT_O-LINE_NO    = 1.
XMPLT_O-INFO_NAME  = 'Plant'.
XMPLT_O-INFO_VALUE = T001W-NAME1..
append XMPLT_O.

XMPLT_O-LINE_NO    = 2.
XMPLT_O-INFO_NAME  = 'Year period'.
XMPLT_O-INFO_VALUE = S_YEAR-LOW.
append XMPLT_O.

XMPLT_P-HF         = 'H'.
XMPLT_P-LCR        = 'L'.
XMPLT_P-LINE_NO    = 1.
XMPLT_P-TEXT       = 'Periodical Report:'.
append XMPLT_P.

XMPLT_H-ROW_NO     = 1.
XMPLT_H-COL_NO     = 1.
XMPLT_H-COL_NAME   = 'Plant'.
append XMPLT_H.

XMPLT_H-COL_NO     = 3.
XMPLT_H-COL_NAME   = T001W-NAME1.
append XMPLT_H.

W_CNT              = W_CNT + 1.
XMPLT_V-COL_NO     = W_CNT.
XMPLT_V-COL_NAME   = 'Material'.
append XMPLT_V.

W_CNT              = W_CNT + 1.
XMPLT_V-COL_NO     = W_CNT.
XMPLT_V-COL_NAME   = 'Material Description'.
append XMPLT_V.

W_CNT              = W_CNT + 1.
XMPLT_V-COL_NO     = W_CNT.
XMPLT_V-COL_NAME   = 'Plant'.
append XMPLT_V.


call function 'XXL_SIMPLE_API'
  exporting
    N_KEY_COLS        = 4
    FILENAME          = 'XMPL0002'
    HEADER            = XMPL_HEADER
  tables
    DATA              = IT_GROSS_DATA_DTLS
    ONLINE_TEXT       = XMPLT_O
    PRINT_TEXT        = XMPLT_P
    COL_TEXT          = XMPLT_V
  exceptions
    DIM_MISMATCH_DATA = 71
    FILE_OPEN_ERROR   = 72
    FILE_WRITE_ERROR  = 73
    INV_WINSYS        = 74
    INV_XXL           = 75.

Edited by: madhuri sonawane on Sep 8, 2009 3:27 PM

0 Kudos

I couldn't succeed. I guess this is just not possible.

0 Kudos

Hi Sandra,

Can we do this using OLE objects,.

Hi,<br />

Please find the code below. My requirement is to convert the number field into "number" format from the "format cell" option,<br />

But its not working . Please help me.<br />

<br />

<pre class="jive-pre"><code class="jive-code jive-java">

REPORT YTESTMAD_002.

&nbsp;

&nbsp;

  • <font color="navy"><b>this</b></font> report demonstrates how to send some ABAP data to an

  • EXCEL sheet using OLE automation.

include ole2incl.

  • handles <font color="navy"><b>for</b></font> OLE objects

data: h_excel type ole2_object, <font color="red">&quot; Excel object</font>

h_mapl type ole2_object, <font color="red">&quot; list of workbooks</font>

h_map type ole2_object, <font color="red">&quot; workbook</font>

h_zl type ole2_object, <font color="red">&quot; cell</font>

h_f type ole2_object, <font color="red">&quot; font</font>

h_c type ole2_object, <font color="red">&quot; color</font>

h_n type ole2_object. <font color="red">&quot;numeric</font>

&nbsp;

DATA: FILENAME LIKE RLGRAP-FILENAME.

tables: spfli.

data h type i.

  • table of flights

data: it_spfli like spfli occurs 10 with header line.

&nbsp;

&----


&nbsp;

*& Event START-OF-SELECTION

&----


&nbsp;

start-of-selection.

  • read flights

  • tell user what is going on

call function <font color="navy">'SAPGUI_PROGRESS_INDICATOR'</font>

exporting

  • PERCENTAGE = 0

text = text-007

exceptions

others = 1.

  • start Excel

create object h_excel <font color="navy">'EXCEL.APPLICATION'</font>.

  • PERFORM ERR_HDL.

&nbsp;

set property of h_excel <font color="navy">'Visible'</font> = 1.

  • CALL METHOD OF H_EXCEL <font color="navy">'FILESAVEAS'</font> EXPORTING #1 = <font color="navy">'c:\kis_excel.xls'</font> .

&nbsp;

  • PERFORM ERR_HDL.

  • tell user what is going on

call function <font color="navy">'SAPGUI_PROGRESS_INDICATOR'</font>

exporting

  • PERCENTAGE = 0

text = text-008

exceptions

others = 1.

  • get list of workbooks, initially empty

call method of h_excel <font color="navy">'Workbooks'</font> = h_mapl.

perform err_hdl.

  • add a <font color="navy"><b>new</b></font> workbook

call method of h_mapl <font color="navy">'Add'</font> = h_map.

perform err_hdl.

  • tell user what is going on

call function <font color="navy">'SAPGUI_PROGRESS_INDICATOR'</font>

exporting

  • PERCENTAGE = 0

text = text-009

exceptions

others = 1.

  • output column headings to active Excel sheet

perform fill_cell using 1 1 1 200 <font color="navy">'35.89'</font>(001) <font color="navy">'Number'</font>.

&nbsp;

  • EXCEL FILENAME

CONCATENATE SY-REPID <font color="navy">'_'</font> SY-DATUM6(2) <font color="navy">'_'</font> SY-DATUM4(2) <font color="navy">'_'</font>

SY-DATUM(4) <font color="navy">'_'</font> SY-UZEIT <font color="navy">'.XLS'</font> 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 format.

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 'Italic' = bold .

perform err_hdl.

set property of h_f 'Color' = col.

perform err_hdl.

get property of h_zl 'font' = h_n.

perform err_hdl.

set property of h_n 'Number' = 1.

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

0 Kudos

>

> perform fill_cell using 1 1 1 200 <font color="navy">'35.89'</font>(001) <font color="navy">'Number'</font>.

...

> set property of h_n 'Number' = 1.

why do you need to translate 35.89 ? (you used text symbol 001)

you must use set property of h_zl 'NumberFormat' = '#.####0'.

0 Kudos

Thanks a lot. Solved.

Rgds,

Madhuri