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

ALV tree question

Hi,

I run BCALV_TREE_SIMPLE_DEMO in order to know how it is working but I have one question: if I want to download the list to excel, how do I add a button and the functionality to do this?

Thanks in advance,

Cristian

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Aug 08, 2005 at 04:53 AM

    Hi,

    Add a button in the application tool bar,

    In PBO,

    MODULE status_9001 OUTPUT.

    IF o_dockingcontainer IS INITIAL.

    SET PF-STATUS 'ZSTATUS'.

    SET TITLEBAR 'ZTITLE'.

    Double click on the ZSTATUS and create status bar in that in the application tool bar give function code as BUT and give the same in the PAI.

    In PAI,

    Case sy-ucomm.

    WHEN 'BUT'. Function code for the button
    perform ...
    
    FORM f9008_f4_hlp_for_pc_file.
      DATA: li_filetable TYPE STANDARD TABLE OF file_table,
            lv_return TYPE i,
            lw_filetable TYPE file_table.
    
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
         EXPORTING
           window_title            = 'Select file for download'
           default_extension       = '.txt'
           initial_directory       =  'C:'
         CHANGING
           file_table              = li_filetable
           rc                      = lv_return
         EXCEPTIONS
           file_open_dialog_failed = 1
           cntl_error              = 2
           error_no_gui            = 3
           OTHERS                  = 4
               .
      IF sy-subrc <> 0.
        MESSAGE e006 WITH text-077.
      ELSE.
        READ TABLE li_filetable INTO lw_filetable INDEX 1.
        v_fnam = lw_filetable-filename.
      ENDIF.
    
     FORM f9007_download_file TABLES p_output.
      DATA:  lv_size   TYPE i.
    
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                filename                = v_fnam
                filetype                = 'DAT'
           IMPORTING
                filelength              = lv_size
           TABLES
                data_tab                = p_output
           EXCEPTIONS
                file_open_error         = 1
                file_write_error        = 2
                invalid_filesize        = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      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.                    " f9007_download_file

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 05, 2005 at 10:26 PM

    Hi

    In real time, for the ALV u need to manipulate the Tool bar buttons by using Toolbar interactive of the ALV...

    here u can choose option to which buttons..to be displayed..and which not...

    get to this method..you will get complete info..

    Thanks

    Balu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 06, 2005 at 02:21 AM

    Hi, you can reference the standard sample BCALV_TREE_05

    It added some menu on the toolbar of ALV Tree.

    Hope it will be helpful.

    In it, code like this:

    CALL METHOD G_TOOLBAR->ADD_BUTTON

    EXPORTING

    FCODE = 'INFO_MENU'

    ICON = '@8P@'

    BUTN_TYPE = CNTB_BTYPE_MENU

    TEXT = ''

    QUICKINFO = TEXT-901. "Information

    If you want to add a button, not menu, change the CNTB_BTYPE_MENU to be CNTB_BTYPE_BUTTON.

    Please aware that you also need event ON_FUNCTION_SELECTED

    About the download functionality, I think you can achieve it just by ws_download, and gui_download, or CL_GUI_FRONTEND_SERVICES.

    Hope my reply is helpful.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 07, 2005 at 01:23 PM

    Hi Cristian,

    or, more specific (still missing some details),

    • add Dropdown Button to toolbar (for Download)

    CALL METHOD lr_toolbar->add_button

    EXPORTING

    fcode = 'DOWNLOAD'

    icon = icon_export

    butn_type = cntb_btype_button

    text = ''

    quickinfo = 'Download file(s)'. "#EC NOTEXT

    and somewhere else

    ----


    • CLASS lcl_toolbar_event_receiver IMPLEMENTATION

    ----


    • ........ *

    ----


    CLASS lcl_toolbar_event_receiver IMPLEMENTATION.

    METHOD on_function_selected.

    CASE fcode.

    WHEN 'DOWNLOAD'. "#EC NOTEXT

    ...

    CALL METHOD cl_gui_frontend_services=>gui_download

    EXPORTING

    • BIN_FILESIZE =

    filename = l_pcfile

    • FILETYPE = 'ASC'

    • APPEND = SPACE

    • WRITE_FIELD_SEPARATOR = SPACE

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = SPACE

    • WRITE_LF = con_true

    • COL_SELECT = SPACE

    • COL_SELECT_MASK = SPACE

    • DAT_MODE = SPACE

    confirm_overwrite = con_true

    • NO_AUTH_CHECK = SPACE

    • CODEPAGE = SPACE

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = SPACE

    • TRUNC_TRAILING_BLANKS_EOL = con_true

    IMPORTING

    filelength = l_tsize

    CHANGING

    data_tab = lt_string

    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

    not_supported_by_gui = 22

    error_no_gui = 23

    OTHERS = 24

    .

    I think it's no use to post my full source here because it was very specific for my project. But I think at least you might get an idea from this and the tree example programs mentioned in this tread.

    Happy coding!

    Best regards,

    Clemens Li

    > Hi,

    >

    > I run BCALV_TREE_SIMPLE_DEMO in order to know how it

    > is working but I have one question: if I want to

    > download the list to excel, how do I add a button and

    > the functionality to do this?

    >

    > Thanks in advance,

    > Cristian

    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.