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

Downloading ALV REport

HI.

i need to download the alv report to a file which i given (either Text or Excel file ) and proper colomns and i need colomn headings also is it possible give me some sample code .

NOTE : i used ws_download but the coloumns r not coming in proper order .

so can any one pls help me regarding this ..........

THX

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 Jan 28, 2008 at 07:09 AM

    The FM ws_download is not obsolute. use GUI_DOWNLOAD instead. Pass the output table to the alv to the FM.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 07:57 AM

    am sending a sample code for normal report.Plz check the below code that will solve ur problem.ok..

    code:

    &----


    *& Report YITAB_XLS *

    *& *

    &----


    *& DEVELOPER : KIRAN KUMAR.G.A *

    *& PURPOSE : DOWNLOAD INTERNAL TABLE DATA TO XLS FILE *

    *& CREATION DT : 31/12/2007 *

    *& REQUEST : ERPK900035 *

    &----


    REPORT YITAB_XLS.

    -


    Internal Table

    -


    data: begin of gt_data occurs 0,

    vbeln like vbap-vbeln,

    posnr like vbap-posnr,

    netpr like vbap-netpr,

    end of gt_data.

    -


    Global Variables

    -


    data: t_vbeln type vbeln.

    -


    Global Structures

    -


    data: gv_file type string.

    -


    Selection Screen

    -


    selection-screen: begin of block b1 with frame title text-001.

    parameters : p_file(90).

    selection-screen: end of block b1.

    selection-screen: begin of block b2 with frame title text-002.

    select-options : s_vbeln for t_vbeln.

    selection-screen: end of block b2.

    *For Path Selection

    at selection-screen on value-request for p_file.

    perform path_directory.

    *Initilization

    initialization.

    perform initial.

    start-of-selection.

    *Fetching data from the Database Table

    perform fetch_data.

    end-of-selection.

    *Download Data to XLS file

    perform download_data.

    &----


    *& Form initial

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    form initial .

    s_vbeln-sign = 'I'.

    s_vbeln-option = 'BT'.

    s_vbeln-low = '4969'.

    s_vbeln-high = '5000'.

    append s_vbeln.

    endform. " initial

    &----


    *& Form fetch_data

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    form fetch_data .

    select vbeln

    posnr

    netpr

    from vbap

    into table gt_data

    where vbeln in s_vbeln.

    endform. " fetch_data

    &----


    *& Form path_directory

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    form path_directory .

    CALL METHOD cl_gui_frontend_services=>directory_browse

    EXPORTING

    WINDOW_TITLE = 'SELECT THE PATH'

    INITIAL_FOLDER = 'C:/'

    CHANGING

    selected_folder = gv_file

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    NOT_SUPPORTED_BY_GUI = 3

    others = 4

    .

    IF sy-subrc 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL METHOD cl_gui_cfw=>flush

    EXCEPTIONS

    CNTL_SYSTEM_ERROR = 1

    CNTL_ERROR = 2

    others = 3

    .

    IF sy-subrc 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    p_file = gv_file.

    endform. " path_directory

    &----


    *& Form download_data

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    form download_data .

    gv_file = p_file.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE =

    filename = gv_file

    FILETYPE = 'ASC'

    APPEND = ' '

    WRITE_FIELD_SEPARATOR = '~'

    HEADER = '00'

    TRUNC_TRAILING_BLANKS = ' '

    WRITE_LF = 'X'

    COL_SELECT = ' '

    COL_SELECT_MASK = ' '

    DAT_MODE = ' '

    IMPORTING

    FILELENGTH =

    tables

    data_tab = gt_data

    EXCEPTIONS

    FILE_WRITE_ERROR = 1

    NO_BATCH = 2

    GUI_REFUSE_FILETRANSFER = 3

    INVALID_TYPE = 4

    NO_AUTHORITY = 5

    UNKNOWN_ERROR = 6

    HEADER_NOT_ALLOWED = 7

    SEPARATOR_NOT_ALLOWED = 8

    FILESIZE_NOT_ALLOWED = 9

    HEADER_TOO_LONG = 10

    DP_ERROR_CREATE = 11

    DP_ERROR_SEND = 12

    DP_ERROR_WRITE = 13

    UNKNOWN_DP_ERROR = 14

    ACCESS_DENIED = 15

    DP_OUT_OF_MEMORY = 16

    DISK_FULL = 17

    DP_TIMEOUT = 18

    FILE_NOT_FOUND = 19

    DATAPROVIDER_EXCEPTION = 20

    CONTROL_FLUSH_ERROR = 21

    OTHERS = 22

    .

    IF sy-subrc 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    endform. " download_data

    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.