Download ALV O/P to multiple XL files

Hi All,
            I have a report with subtotals at the vendor level, my requirement is when the user presses a button each vendor's information with the subtotals should  go to a different XL file. The user can have his own layout; how can I know in my program which fields he had picked up for his layout? Any pointers would be great. Thanks!
Regards,
Amit

Hi there -- the OO method for ALV GRID works from V4.6C so you should have NO problem in using ALV OO (CL_GUI_ALV_GRID).
What you could do is intercept the standard button for EXPORT
use the ON_USER_COMMAND method with the parameter e_ucomm.
The function code is &PC.
Then do your own download  to your relevant files and exit back to the grid or make a new button on the toolbar EXPORT for example with your own FCODE.
In the example below I've got a download to excel but change the method to your download for your users.
standard SAP class cl_gui_frontend_services has  methods gui_upload and gui_download for up / downloading files etc.
note that the layout used in any particular OO grid is normally to be found in some parameter  ls_layout so reading this table at your ON_USER_COMMAND event should give you the layout the user is using.
If you don't get it directly in the ON_USER_COMMAND method you can call a method from this method  like I have done .  The layout is available in this method (or any other after the Grid has been displayed).
when 'EXCEL'.
       call method me->download_to_excel.
method constructor .
create object grid_container1
        exporting
*           container_name = 'CCONTAINER1'.
    container_name = cfname.
    create object  grid1
       exporting
          i_parent = grid_container1.
    set handler z_object->on_user_command for grid1.
    set handler z_object->on_toolbar for grid1.
    set handler z_object->handle_data_changed for grid1.
    set handler z_object->handle_data_changed_finished for grid1.
    set handler z_object->on_dubbelklik for grid1.
    set handler z_object->on_hotspot for grid1.
    call method grid1->register_edit_event
        exporting
           i_event_id = cl_gui_alv_grid=>mc_evt_enter.
  endmethod.
method on_toolbar .
type-pools icon.
clear ls_toolbar.
     move  0 to ls_toolbar-butn_type.
     move 'EXCEL' to ls_toolbar-function.
     move  space to ls_toolbar-disabled.
     move  icon_xxl to ls_toolbar-icon.
     move 'Excel' to ls_toolbar-quickinfo.
     move  'EXCEL' to ls_toolbar-text.
     append ls_toolbar to e_object->mt_toolbar.
    perform   toolbar  in program (caller) if found
     using e_object.
endmethod.
method on_user_command .
*        FOR EVENT before_user_command OF cl_gui_alv_grid
*        IMPORTING
*          e_ucomm
*          sender
case e_ucomm.
      when 'EXIT'.
        leave program.
      when 'EXCEL'.
       call method me->download_to_excel.
      when 'SAVE'.
      when 'PROC'.
        call method me->process.
      when 'REFR'.
        call method me->refresh.
        when 'SWITCH'.
        call method me->switch.
       when 'TEST'.
        call method me->get_cell.
       endcase.
endmethod.
method download_to_excel.
field-symbols:
       <fs0> type standard table,
       <fs1> type standard table.
    assign g_outtab1->* to <fs0>.
    assign g_fldcat1->* to <fs1>.
       call function  'LVC_TRANSFER_TO_KKBLO'
      exporting
        it_fieldcat_lvc   = <fs1>
*     is_layout_lvc     = m_cl_variant->ms_layout
         is_tech_complete  = ' '
      importing
        es_layout_kkblo   = ls_layout
        et_fieldcat_kkblo = lt_fieldcat.
    loop at lt_fieldcat into lt_fieldcat_wa.
      clear lt_fieldcat_wa-tech_complete.
      if lt_fieldcat_wa-tabname is initial.
        lt_fieldcat_wa-tabname = '1'.
        modify lt_fieldcat from lt_fieldcat_wa.
      endif.
      l_tabname = lt_fieldcat_wa-tabname.
    endloop.
    call function 'ALV_XXL_CALL'
         exporting
              i_tabname           = l_tabname
              is_layout           = ls_layout
              it_fieldcat         = lt_fieldcat
              i_title             = sy-title
         tables
              it_outtab           = <fs0>
         exceptions
              fatal_error         = 1
              no_display_possible = 2
              others              = 3.
    if  sy-subrc <> 0.
      message id sy-msgid type 'S' number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
endmethod.
Cheers
jimbo

Similar Messages

  • How to download alv data in webdynpro to external file

    Hi,
      Can anyone guide me how to download alv data from webdynpro to an external file. i followed  the standard component WDR_TEST_EVENTS . FILE DOWNLOAD.
    method supply_file .
      data conv_out type ref to cl_abap_conv_out_ce.
      data struct type if_filedownload=>element_filecontent_node.
    fill the file content
      conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
      conv_out->convert(
        exporting
          data = 'Der Inhalt einer Textdatei'
        importing
          buffer = struct-filecontent ).
      node->bind_structure( struct ).
    endmethod.
    But how to pass our alv table data here instead of the  text  (Der Inhalt einer Textdatei) .
    Thanking you
    Archana.

    You are going to have to retrieve the data from the context into an internal table. You can use the node object method get_static_attributes_table.
    Then you need to transform the internal table into something that Excel understands.  In the ALV we use an XSLT to transform the data into the MHTML Excel format. However this relies on internal structures of the ALV component and isn't easily resuable from outside the ALV.  Consider transforming the data into XML with your own XSLT or iXML parser or going with a simplier text-tab delimited format.  Search the forums as the logic to conver the data (basically looping and concatenating in CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB and CR_LF) has been discussed just the other day.

  • How to set default file path while downloading alv output

    Hi,
    Can anyone tell me that how to set default file path while downloading the ALV output to system using Local file button on tool bar.
    Please look below screenshots:
    Kindly help me resolve it.
    Thanks in advance.
    Regards,
    Ashutosh Katara

    This information initial value is (maybe) stored in Windows Register (register.exe) at Software\SAP\SAPGUI Front\SAP Frontend Server\Filetransfer -> PathDownload, you can read it thru class CL_GUI_FRONTEND_SERVICES method GET_UPLOAD_DOWNLOAD_PATH and update it thru method REGISTRY_SET_VALUE. (Else there may be some parameter ID to force data, but I'm no longer sure)
    Regards,
    Raymond

  • How to download alv grid output(with field catalog) into excel file format

    Hi all,
    How to download alv grid output(with field catalogs) into excel file format and same file has to download to application server.
    Please help.
    Regards,
    Satya.

    Hi,
    On list where alv is displayed, select export icon( green color -> ),select spread sheet.
    This will display records in Excel sheet.

  • Downloading ALV to excel file

    Hi all,
       i am trying to download ALV to excel file.
       but as the alv contains many fields,
       the row in the excel is automatically wrapped to the
       next row ..
       what i want is the row in excel should come as it is
       in the ALV (whole thing in one line) and should not wrap to next row
      Regards,
      Tarang

    Hi Shah,
    <b>
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'</b>
        EXPORTING
          I_CALLBACK_PROGRAM      = V_REPID
          I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
          IS_LAYOUT               = WA_LAYOUT
          I_SAVE                  = 'A'
          IT_FIELDCAT             = I_FLDCAT_HEAD
          IT_SORT                 = IT_SORT
          IT_EVENTS               = I_EVENTS
        TABLES
          T_OUTTAB                = IT_FINAL
        EXCEPTIONS
          PROGRAM_ERROR           = 1
          OTHERS                  = 2.
      IF SY-SUBRC = 0.
    <b>     CALL FUNCTION 'GUI_DOWNLOAD'</b>
         EXPORTING
          BIN_FILESIZE                    =
            FILENAME                        = 'C:\Documents and Settings\vikranthk\Desktop\vikranth.xls'
           FILETYPE                        = 'ASC'
          APPEND                          = ' '
          WRITE_FIELD_SEPARATOR           = ' '
          HEADER                          = '00'
          TRUNC_TRAILING_BLANKS           = ' '
          WRITE_LF                        = 'X'
          COL_SELECT                      = ' '
          COL_SELECT_MASK                 = ' '
          DAT_MODE                        = ' '
          CONFIRM_OVERWRITE               = ' '
          NO_AUTH_CHECK                   = ' '
          CODEPAGE                        = ' '
          IGNORE_CERR                     = ABAP_TRUE
          REPLACEMENT                     = '#'
          WRITE_BOM                       = ' '
          TRUNC_TRAILING_BLANKS_EOL       = 'X'
          WK1_N_FORMAT                    = ' '
          WK1_N_SIZE                      = ' '
          WK1_T_FORMAT                    = ' '
          WK1_T_SIZE                      = ' '
        IMPORTING
          FILELENGTH                      =
          TABLES
            DATA_TAB                        = it_final.
          FIELDNAMES                      =
        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
    Thanks
    Vikranth Khimavath
    Message was edited by: Khimavath Vikranth

  • Multiple invoices(spool jobs) download to multiple PDF files or 1 PDF file

    Hello techies:
    Has anyone written a program that takes the spool jobs of multiple Invoices from table TSP01 and then download these multiple invoices to multiple PDF files or to
    One PDF file depending on selection screen?
    This is an urgent request from client for archiving.  Any help is highly appreciated !
    Thanks so much
    SilviaB

    Hi Chris
    Try printing from another browser, such as Firefox. There have been issues between eBay's coding practices and how Safari interprets them.

  • Download multiple Collaboration files

    We are using Collaboration 4.0.2.
    I am wondering whether the PRC can be used to download all the documents from a specific project?
    This is so we can cleanout the project while still retaining a knowledge base of learnings from old projects.
    Thanks.....

    Hi,
    I'm actually trying to generate multiple excel files at once,
    looping though a query and creating the files.
    However, when I launch the code, it is generating only the
    last file and not one by one.
    I unfortunately cannot use POI in this case because of heavy
    formatting of the excel files (tables, colspans, rowspans, colors,
    etc), unless you know of a way to do this with POI?
    Initially the files were generated 1 by 1. This works, no
    problem.
    But now, the users want the option to tick which files they
    want to generate and click on a Submit button to generate all the
    Excel files they have checked.
    Any idea on this issue?
    Pls also advise how you managed to delay the form submission
    by 10 seconds for each of the files you were creating.
    Thanks and regards,
    Yogesh Mahadnac

  • How to exreact multiple pdf files from a zip files from application server to presentation server

    Hello exprts,
    I am passing one pdf file and one text file to zip file in apllication server through my custom program and then downloading it using standard function module to my desktop. its working fine. Then I added  another pdf file to my zip file. But only single pdf file is getting download . So can you please help me regardiong this issue? 

    Dear Experts ,
    I finded out the way to extrcat pdf files in presentation server. But now my problem is that I am not able to add multiple pdf files in a zip file. When I am adding new pdf file then older one is not coming in read data set. So please kindly tell me how can I add multiple pdf file in my zip file and again I can get all the pdf files from here.

  • Multiple DomainSite files no longer open after Lion upgrade

    I have at least 6 separate Domain.Sites.2 files that use for domains that I maintain using iWeb. Since I upgraded to Lion last week, I've discovered that no matter which DomainSite file I've tried to open, it continues to open the last site that I worked on before my system upgrade.
    Have I lost the ability to use those files?
    I'm in big trouble if there's not a fix for this! Big trouble!!
    Thanks for any help,
    Bob

    Here's another solution to your issue:
    In Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    To open your domain file in Lion or to switch between multiple domain files Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an application.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    You can download an already compiled version with this link: iWeb Switch Domain.
    Just launch the application, find and select the domain file you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    WARNING: iWeb Switch Domain will overwrite an existing Domain.sites2 file if you select to create a new domain in the same folder.  So rename your domain files once they've been created to something other than the default name.
    OT

  • To download alv output to two excel sheets because of large data

    Hi all,
    I want to download alv output to excel sheet,I know how to do,but the no of record is very large and can not be accomodated in one sheet.
    can anyone please tell how to download it into two sheets or some other way.
    I want excel format only.
    Regards,
    sudha

    hi sudha yadav,
    right now i am working on the same issue.
    what right i am doing is that,
    i want to download an internal table it is containing more than 2 lakhs records but excel can accomidate 60000 records, so
    before call gui download i am sending first 60000 records into another internal table with same time, by using append statemen and indexs,
    that new internal table i am downloading
    again i am repeating the same thing by using sy-tabix,
    finally i am creating more than one excel file
    by using oops concepts we can also create in one excel file no of work sheets
    but its lengthy process so i am right now creating no of excel files only
    if it is useful , pls rewards points to this answer

  • Downloading ALV to EXCEL - in some fields the last character is missing ...

    Hi,
    I am experiencing this kind of problem when downloading ALV report into Excel :-
    "You are downloading an ALV result to an EXCEL file. In some fields the last character is missing."
    For example, if MATNR is 0000234567 in display but after downloading to excel it becomes only 23456.
    I found another related forum thread : Pronlem while downloading ALV grid to excel
    I tried the suggested method to apply OSS note 1075315. However, the note cannot be implemented in the system. I am working in a ECC6 environment (SAP version 700, 701).
    Kindly please help me if you came across the similar kind of issue. Thanks much.

    Hi gkGoh8     ,
    The link thread that you just gave already provided the answer, in your field catalog you need to activate field lzero.
    1. Check FM : REUSE_ALV_GRID_DISPLAY
    2. Import Parameter tab :IT_FIELDCAT
    3. Double click SLIS_T_FIELDCAT_ALV
    4. On type group SLIS, check line 93
    Regards,
    JQC

  • Hello.  May I ask:  I am using Acrobat 6.0.2, and having trouble formatting a PDF created from multiple (jpeg) files.  Each page is formatted to A4 size, portrait.  But when I create the PDF, each sheet appears as tiny, in the middle of a huge white page.

    Hello.  May I ask:  I am using Acrobat 6.0.2, and having trouble formatting a PDF created from multiple (jpeg) files.  Each page is formatted to A4 size, portrait.  But when I create the PDF, each sheet appears as tiny, in the middle of a huge white page.  I cannot seem to find any controls to adjust this.  Any advice appreciated.

    Thanks CtDave, for the further info.  Unfortunately, those suggestions are not working, which is strange.
    ....Until last week, I used to make multi-page PDFs straight from Photoshop: File > Automate > Make PDF.  One simply choses the files, orders them, and creates a PDF.  (Resolution doesn't matter; 300 DPI is no problem.)  However, my new Photoshop CS5 does not have the option in Automate.
    What I've done, seeing as Acrobat is letting me down, is use Bridge (new to me) to create the PDF.  It worked without a problem, but seems like more work than the old PS method.  I will download a newer version of Acrobat to see if that makes any difference.
    .....Also, thanks Test Screen Name:  I agree with you that jpeg is irrelevant, and that one can make a PDF from Photoshop (Print > Save As - pdf).  But that only works for SINGLE PAGE pdf, not multiple pages as far as I can tell.
    Kind regards,
    Prince Nuada

  • Concatenate multiple pdf files into one single file

    hi,
    Could any one help me with a code "combining or merging multiple pdf files selected from the browser into one single document" to send it as one single request to the printer?
    Thanks ,

    It is called the Big Faceless PDF library.
    they have a free trial download.
    in regards to doing it yourself, of course.
    but this is a pure java library that can do what you want without you having to re-invent the wheel (for a price of course).
    they have excellent technical support as well, usually solving your problem within a day or so.

  • Howto deal with multiple source files having the same filename...?

    Ahoi again.
    I'm currently trying to make a package for the recent version of subversive for Eclipse Ganymede and I'm almost finished.
    Some time ago the svn.connector components have been split from the official subversive distribution and have to be packed/packaged extra. And here is where my problem arises.
    The svn.connector consists (among other things) of two files which are named the same:
    http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/features/org.polarion.eclipse.team.svn.connector_2.0.3.I20080814-1500.jar
    http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/plugins/org.polarion.eclipse.team.svn.connector_2.0.3.I20080814-1500.jar
    At the moment makepkg downloads the first one, looks at its cache, and thinks that it already has the second file, too, because it has the same name. As a result, I can neither fetch both files nor use both of them in the build()-function...
    Are there currently any mechanisms in makepkg to deal with multiple source files having the same name?
    The only solution I see at the moment would be to only include the first file in the source array, install it in the build()-function and then manually download the second one via wget and install it after that (AKA Quick & Dirty).
    But of course I would prefer a nicer solution to this problem if possible. ^^
    TIA!
    G_Syme

    Allan wrote:I think you should file a bug report asking for a way to deal with this (but I'm not sure how to fix this at the moment...)
    OK, I've filed a bug report and have also included a suggestion how to solve this problem.

  • Download ALV report with layout to application server

    Hi Gurus,
    I have a problem as follows:
    I have one ALV Grid report. This report is very time consuming.
    That is why, user wants this to be run in background every night and in the morning when user comes to the office that ALV report should be on user's drive in excel format.
    However, it should run with one specific variant and that variant should be dynamically populated. (I have handled this part)
    It should also apply specific layout that has many filtering conditions.
    As I can not download ALV to excel in background, I decided to download it to the Application server.
    My problem is that when run in background, in spool ALV report shows o/p with proper filter conditions that is 5 out of 20 records.
    But, when I write this report o/p to Application server, it writes all the records in there, i.e., all 20 records. It does not take into account all the filters. [:(]
    I also tried downloading spool to excel, but o/p is not neatly formatted. All columns are fying here and there.
    Any suggestion, how can I write ALV o/p to Application server with layout into consideration?
    P.S. I have searched forum for this type of query, but no apt responses.
    Thanks

    did u downloaded the report with standard option provided in the alv and checked the data? that is populating all 20 records?. if so then use coding for achieving the standard one
    at the end of selection do like this ..
    SET USER-COMMAND ' %PC' .
    and in the user-command use like this..
    case sy-ucomm.
    when '  %PC'.
    give the file name ..
    do processing ..
    endcase.

Maybe you are looking for