Skip to Content
author's profile photo Former Member
Former Member

alv report to excel

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 03:03 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 05:40 PM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.