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: 

alv report to excel

Former Member
0 Kudos

How can i convert an alv report to excel using abap code?

2 REPLIES 2

Former Member
0 Kudos

Hi ,

there are many threads available in this forum for ur question just have a look,

You can use the FM - ALV_XXL_CALL.

It is the same function module invoked when you click on the export to excel button of the ALV.

You can pass teh field catalog of the ALV here along with the name of ur internal table and the internal table itself. It will download everything to Excel alongwith the Column headers ( depending on ur field catalog definition). Just make sure ur field catalog has the COL_Heading correctly populated.

Sample Code - CALL FUNCTION 'ALV_XXL_CALL'

EXPORTING

i_tabname = 'T_GRID' " Name of the Internal table

it_fieldcat = t_fcatk[] " Field catalog

TABLES

it_outtab = t_grid " Interbnal table with data

EXCEPTIONS

fatal_error = 1

no_display_possible = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e806(bk).

ENDIF.

Thanks

naveen khan

Former Member
0 Kudos

Thank you very much, but how can i convert the alv list into internal table?

I am using this code but dont work


REPORT Z_SAMPLE.

TYPES tipoLinea(1024) TYPE c.

DATA: begin of TablaLinea occurs 0,
      linea type tipoLinea,
END OF TablaLinea.

DATA lista LIKE abaplist OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'LIST_FREE_MEMORY'
TABLES
listobject = lista.

SUBMIT  rhrhaz00
       AND RETURN
       EXPORTING LIST TO MEMORY.

CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lista
EXCEPTIONS
OTHERS = 1.

WRITE: / 'C:', SY-SUBRC.

perform save_ascii_list.

LOOP AT TablaLinea.
   WRITE: / TablaLinea-linea.
ENDLOOP.

WRITE: / 'C:', SY-SUBRC.

*#####################################-
* FUNCTION: save_ascii_list
*#####################################-
form save_ascii_list.

CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES listasci = TablaLinea
listobject = lista
EXCEPTIONS empty_list = 1
list_index_invalid = 2
OTHERS = 3.

IF sy-subrc <> 0. ENDIF.

endform.

Another question, this code is showing the alv list in the screen and i dont want to appear, just convert directly into internal table. How to do that?