ALV ( How to save the output as Excel file whenever we runs the Report )

Hi,
      Can any one please let me know , how we can automatically save a ALV Grid Display report in Excel Format in presentation server whenever we execute the Report.
Regards
Avi.

Hi,
This report demonstrates how to send some ABAP data to an
EXCEL sheet using OLE automation.
INCLUDE OLE2INCL.
handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
      H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
      H_MAP TYPE OLE2_OBJECT,          " workbook
      H_ZL TYPE OLE2_OBJECT,           " cell
      H_F TYPE OLE2_OBJECT.            " font
TABLES: SPFLI.
DATA  H TYPE I.
table of flights
DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
*&   Event START-OF-SELECTION
START-OF-SELECTION.
read flights
  SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
display header
  ULINE (61).
  WRITE: /     SY-VLINE NO-GAP,
          (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
          (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
          (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
          (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
          (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
  ULINE /(61).
display flights
  LOOP AT IT_SPFLI.
  WRITE: / SY-VLINE NO-GAP,
           IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
           IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
           IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
           IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
           IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
  ENDLOOP.
  ULINE /(61).
tell user what is going on
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
     EXPORTING
          PERCENTAGE = 0
           TEXT       = TEXT-007
       EXCEPTIONS
            OTHERS     = 1.
start Excel
  CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
  SET PROPERTY OF H_EXCEL  'Visible' = 1.
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
PERFORM ERR_HDL.
tell user what is going on
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
     EXPORTING
          PERCENTAGE = 0
           TEXT       = TEXT-008
       EXCEPTIONS
            OTHERS     = 1.
get list of workbooks, initially empty
  CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
  PERFORM ERR_HDL.
add a new workbook
  CALL METHOD OF H_MAPL 'Add' = H_MAP.
  PERFORM ERR_HDL.
tell user what is going on
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
     EXPORTING
          PERCENTAGE = 0
           TEXT       = TEXT-009
       EXCEPTIONS
            OTHERS     = 1.
output column headings to active Excel sheet
  PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
  PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
  PERFORM FILL_CELL USING 1 3 1 'Von'(003).
  PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
  PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
  LOOP AT IT_SPFLI.
copy flights to active EXCEL sheet
    H = SY-TABIX + 1.
    PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
    PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
    PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
    PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
    PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
  ENDLOOP.
changes by Kishore  - start
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
  CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
  PERFORM ERR_HDL.
add a new workbook
  CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
  PERFORM ERR_HDL.
tell user what is going on
  SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
     EXPORTING
          PERCENTAGE = 0
           TEXT       = TEXT-009
       EXCEPTIONS
            OTHERS     = 1.
output column headings to active Excel sheet
  PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
  PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
  PERFORM FILL_CELL USING 1 3 1 'Von'(003).
  PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
  PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
  LOOP AT IT_SPFLI.
copy flights to active EXCEL sheet
    H = SY-TABIX + 1.
    PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
    PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
    PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
    PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
    PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
  ENDLOOP.
changes by Kishore  - end
disconnect from Excel
     CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
  FREE OBJECT H_EXCEL.
  PERFORM ERR_HDL.
      FORM FILL_CELL                                                *
      sets cell at coordinates i,j to value val boldtype bold       *
FORM FILL_CELL USING I J BOLD VAL.
  CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
  PERFORM ERR_HDL.
  SET PROPERTY OF H_ZL 'Value' = VAL .
  PERFORM ERR_HDL.
  GET PROPERTY OF H_ZL 'Font' = H_F.
  PERFORM ERR_HDL.
  SET PROPERTY OF H_F 'Bold' = BOLD .
  PERFORM ERR_HDL.
ENDFORM.
*&      Form  ERR_HDL
      outputs OLE error if any                                       *
-->  p1        text
<--  p2        text
FORM ERR_HDL.
IF SY-SUBRC <> 0.
  WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
  STOP.
ENDIF.
ENDFORM.                    " ERR_HDL
Please note that this example maybe slow at filling the excel table
(perhaps four fields per second on a 900 MHz machine - almost 30 seconds
for a short example).
To get the data on properties and methods - there is a bit of smoke and mirrors
going on here; they are EXCEL properties and methods, not sap ones - so you need
to look at excel help to determine how a particular function is structured. then
build the block in sap, as shown in the example.
If you only want to transfer the data to Excel like when you transfer the data from
ALV to Excel simply use the Function Modules:
XXL_SIMPLE_API
If you want more modifications when you transfer it to Excel use:
XXL_FULL_API
Hope this helps.
Reward if helpful.
Regards,
Sipra

Similar Messages

  • How to run the report and show the output in excel file

    salam
    how to run the report and show the output in excel file,
    how to run the report and print the o/p via printer
    how to run the report and send the o/p via mail
    thank u all

    Hi,
    There are Parameters DESTTYPE, DESFORMAT and DESNAME. You can set these parameters to get as you want.
    1) Output in Excel File
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'FILE');
         ADD_PARAMETER(PL_ID, 'DESFORMAT', TEXT_PARAMETER, 'DELIMITED');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<file_name>.XLS');2) output to printer
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'PRINTER');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<printer_name>');3) Email - Have to configure SMTP and all. ( i didn't checked it)
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'MAIL');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<email_id>');Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • How to save Android contacts as Excel file on Mac computer?

    I want to manage and edit my contacts on my cell phone, my friend suggested me save them as Excel format! So now i am trying this way, but i can't find the right method to do this! Do you know how to save Android contacts as Excel file on Mac computer?

    If you want to save Android Phone contacts to Excel format, you can have a try the following method:
    Step 1. Connect Your Android Phone to Computer
    After downloading and installing the Coolmuster Android Assistant software on your computer, launch it and you will get the program interface prompts you to connect your phone to the computer. Just use a USB cable to connect your phone to the computer and the program will detect the connected phone automatically. If it is the first time to run this software, you may encounter the following picture and be required to enable USB debugging on your phone at first. If your device can be detected by the program, you can directly skip to the next step.
    Step 2: Go to the Contacts windows
    All your phone data are categorized on the top menu. To transfer Android phone's contacts, you can go to click the "Contacts" icon to enter the Contacts window. Navigate to the left panel and click on the "All Contacts" option, then, all the contacts in your phone will show in list on the right window. Mark the contacts you want to backup on your computer and click the button of "Backup".
    Step 3. Start to export contacts to computer at once
    Once you click on the "Backup" button, there will be a "Path" dialog appears, asking you to choose an output location where you want to save the exported contacts. Specify an output folder and then click the "Ok" button. Then, all your phone contacts will be exported to the output location immediately, with all the email address, company's name, home address, and more contacts info perfectly kept in the output CSV or XLS file.

  • HOW TO DOWNLOAD SAP OUTPUT TO EXCEL FILE

    Hi SAP Gurus,
        I would like to ask if you have any Function Module or codes on how to download SAP Output into Excel file. Thanks! Hope you could help me.

    You can transfer the contents of internal table to excel using this code..
    data: begin of itab occurs 0,
          vbeln like vbak-vbeln,
          posnr like vbap-posnr,
          end of itab.
    select vbeln
           posnr
           from vbap
           up to 20 rows
           into table itab.
    * EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    * handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_WORK  TYPE OLE2_OBJECT,
          H_SHEET TYPE OLE2_OBJECT,
          H_CELL  TYPE OLE2_OBJECT,
          V_COL   LIKE SY-TABIX.     " column number of the cell
    DATA:
      V_STEP(30),
      V_FILE LIKE RLGRAP-FILENAME.
    * tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = 'Creating Excel...'
           EXCEPTIONS
                OTHERS     = 1.
    * start Excel
      V_STEP = 'Starting Excel'.
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    *  CALL METHOD OF H_EXCEL 'OPEN' EXPORTING  #1 = 'C:DMC_REC.XLS'.
    *  PERFORM ERR_HDL.
    * tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = 'Adding Data to Excel...'
           EXCEPTIONS
                OTHERS     = 1.
    * Get the list of workbooks
      V_STEP = 'Preaparing Excel'.
      CALL METHOD OF H_EXCEL 'WORKBOOKS' = H_WORK.
      PERFORM ERR_HDL.
    ** Add new workbook (create a file)
      CALL METHOD OF H_WORK 'ADD'.
      PERFORM ERR_HDL.
    * Get the created worksheet
    ************************Sheet Number
      CALL METHOD OF H_EXCEL 'WORKSHEETS' = H_SHEET EXPORTING #1 = 3.
    ************************Sheet Number
      PERFORM ERR_HDL.
    * Activate (select) the first sheet
      CALL METHOD OF H_SHEET 'ACTIVATE'.
      PERFORM ERR_HDL.
    * tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
    *           PERCENTAGE = 0
               TEXT       = 'Adding Data to Excel...'
           EXCEPTIONS
                OTHERS     = 1.
    * output column headings to active Excel sheet
      V_STEP = 'Adding data to Excel'.
      LOOP AT ITAB.
        V_COL = SY-TABIX.
        PERFORM FILL_CELL USING 1 V_COL ITAB-vbeln.
        PERFORM FILL_CELL USING 2 V_COL ITAB-posnr.
      ENDLOOP.
      V_STEP = 'Releasing Excel'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
      H_EXCEL-HANDLE = -1.
    *&      Form  ERR_HDL
    *       text
    *  -->  p1        text
    FORM ERR_HDL.
      IF SY-SUBRC <> 0.
        WRITE: / 'Error in processing Excel File:', V_STEP.
        STOP.
      ENDIF.
    ENDFORM.                    " ERR_HDL
    *&      Form  FILL_CELL
    *       text
    *      -->P_1      text
    *      -->P_1      text
    *      -->P_1      text
    FORM FILL_CELL USING  ROW COL VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_CELL
                     EXPORTING #1 = ROW #2 = COL.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_CELL 'Value' = VAL .
      PERFORM ERR_HDL.
    ENDFORM.                    " FILL_CELL

  • How to save query result in excel file

    Hi all,
    How to save query result in excel file from sql*plus tool.
    thank you

    Do you really need an Excel file (binary) or a simple CSV?
    If you just need a CSV then search for DUMP_CSV at http://asktom.oracle.com or at this forum
    If you need formatting and/or multiple worksheets then you can use free tools like
    https://xml-spreadsheet.samplecode.oracle.com/ or https://exceldocumenttype.samplecode.oracle.com/
    Regards
    Marcus

  • How To Save JSP Page As Excel File.

    Dear Friends,
    I am working on a project which has oracle as backend. I have some reports in my project.(.jsp files)I want to save it in MsExcel format.
    How could i do it?
    Also is it possible to save jsp files (the output genrated by jsp) in MS Word,PDF format?
    Sameer.

    If you set the content type and are using IE then the HTML will be rendered in Excel in place. Other browsers open Excel, but not in place.
    If you need more info search google for 'java setcontenttype excel':
    <% response.setContentType("application/vnd.ms-excel"); %>Also a much easier and flexible way to create html from ResultSets is to use my free FormattedDataSet API. The following one line would replace all the lines you posted (and the ones you didn't such as opening the Connection, Statement and ResultSet).
    FormattedDataSet fds=FormattedDataSet.createInstance();
    String html=fds.getFormattedDataSet("select * from table", "htmlTable");steve - http://www.fdsapi.com - The easiest most flexible way of generating dynamic HTML and XML.
    The following would be replaced.
    <table>
    <tr> <th>Name</th> <th>Employee No</th></tr>
    <tr>
    <%
    while (rs.next())
    %>
    <td><%=rs.getString(1) %>
    </td>
    <td><%=rs.getString(2) %>
    </td>
    <%
    %>
    </tr>
    </table>
    **

  • How to save cluster in some excel file

    Hi,
    I have been using bundle function to draw XY graph from 2 one dimensional array. However, I need these values to be saved in some excel file so that I can look at the graph in future. However, I could not connect the "output" of "Bundle" function to "ClusterToArray" function and so, I am not able to save the date, please let me know how to do.
    Thanks,
    Dushyant

    One way of doing it would be to create a 2D array from you one dimensional arrays rather than the output of the bundle. Then you would need to transpose the 2D array and using the Write to spreadsheet VI to save the data in excel. See the attached picture.
    Andrew Alford
    Production Test Engineering Technologist
    Sustainable Energy Technologies
    www.sustainableenergy.com
    Attachments:
    array to excel.JPG ‏14 KB

  • How to save data into an excel file ?

    I am working on using computer to corol HP8510 Network Analyzer System. Firstlly, I save my data into a notepad.Now I want to save them directly into an excel file. Is there anybody can give me any clue?
    Thanks
    Attachments:
    S.vi ‏165 KB

    The attached zip file contains several VI's to read and write directly to Excel using ActiveX. There are several example VI showing how to use everything. This set is saved in LabVIEW 6.0.2.
    I suggest you unzip these to your user.lib directory so you'll be able to easily access them from the functions palette.
    I have not actually used these, but others that have say they have worked well for them.
    Good Luck
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    excel_lv6i.zip ‏898 KB

  • How to read the data from excel file and store into the table?

    Hi All,
    I have table with BLOB datatype contains a excel file. I have to read that data from excel and store into one table with all the fields in excel.
    All the excel fields and my table columns are same.
    Can you share with me how can acheive this using LOB's?
    Thanks

    Hi OraSuirya,
    you can try with external tables .
    syntax as follows
    create table ext_table_csv (
    i Number,
    n Varchar2(20),
    m Varchar2(20)
    organization external (
    type oracle_loader
    default directory ext_dir
    access parameters (
    records delimited by newline
    fields terminated by ','
    missing field values are null
    location ('file.csv')
    reject limit unlimited;
    For this you need to create directory
    Directory Creation syntax:
    create or replace directory ext_dir as 'D:\oracle\user_dir\ext_dir';
    grant read, write on directory ext_dir to <User>;
    please paste the excel file in the particular directory .
    I hope this will help you.
    Please correct me if I am wrong anywhere .
    Thanks,
    Tippu.

  • How to save and retrieve an excel file as an object into lob column?

    Hi ,
    I need to save and retrieve the whole excel file with 3 or more sheets as an object into the lob column of table.
    For example:
    t_docments
    (doc_id number,
    excel_data clob
    All excel files need to be saved to excel_data column.
    What should I do?
    Thanks

    Did you check the asktom thread posted by Jens?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P1
    1_QUESTION_ID:232814159006
    There's example of varies file types.Yes, I did try some examples.
    Those work for .doc/.pdf/.jpg files, BUT NOT for excel file.
    The following error happened when retrieving excel file(retrieving .doc/.pdf are OK)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 375
    ORA-06512: at "SYS.UTL_FILE", line 990

  • Save ALV report output as excel file in background

    Hi all,
    As the no. of records is huge and the running time is long, I'd like to modify my program to be able to run in background mode with excel as output..
    Is there any method to generate the result list in ALV format and save it as an excel file while running the program in background mode?
    And any limitation?
    Thanks!

    Try to create ALV output to spool in background then try to use any of the below mentioned fm
    SAP_CONVERT_TO_XLS_FORMAT
    MS_EXCEL_OLE_STANDARD_DAT
    RSPO_DOWNLOAD_SPOOLJOB
    RH_START_EXCEL_WITH_DATA
    or
    create CSV using OPEN DATASET & TRANSFER

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Execute in background but download the data into excel file

    I would like to know if it is possible to exceute the report in background but generate the output in excel file instead of to spool request.

    Hi
          It is possible.You can use Open_Dataset to do this.Also you can use
    "Set_Function_Code" also to do this. I think to download to excel the function code is "%EXCEL". Try this..
    Hope this willl solve your query.
    Reward All Helpfull Answers.......

  • Problem while downloading the alv output to excel file.

    Hii,
    While downloading the alv output to an excel file i am facing a problem. Either the output comes as 1.23456E+11 or the values get cut .
    Cant put in txt file  as the users require to calculate directy and i have even tried to increase the output length .But both doesnt help.
    So what are the other ways to do so.
    Edited by: mansi_v27 on Mar 24, 2010 12:35 PM

    Hi,
    Welcome to SCN!!!.
    Please go through the forum rules. This has been discussed many times. You can search in the forum for this.
    Infact there is no problem. Just expand that excel cell. You can see the full value. This is standard excel property.
    Thanks,
    Vinod.

  • How to download a smartform output as excel file WITH EXACT LAYOUT.

    Hi,
         I have searched the forum but could not found any satisfactory answer. I have a smartform with a table, some texts and a logo. I have to write a code which will save the smartform output as excel file in the system keeping the layout of the smartform output EXACT.
    i.e., the excel file will contain the output with EXACTLY THE SAME layout as would have been for a pdf file (if the smartform output is converted to a pdf file) and the client can then edit the fields of the table in the excel file.  How can I achieve this? Please give a suggestion.. Thanks in advance.

    Hi Anirban,
    Your Requirement is to download a smartform to  microsoft  Excel .
    Well unfortunately we can only download data into excel which is in a tabular format i.e stored in internal tables we have function modules to do the same even u can do that using OLE2.
    If u try to download a smartform to Excel only format supported will be ASCII, if u will continue with that the smartforms text's will get downloaded to excel but whole data would be downloaded in a single Cell.
    Code to do the same is -
    >>>>
    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
      EXPORTING
      i_language = v_language
      i_application = 'SAPDEFAULT'
      IMPORTING
      e_devtype = v_e_devtype.
       CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME                 = w_form
    *   VARIANT                  = ' '
    *   DIRECT_CALL              = ' '
       IMPORTING
         FM_NAME                  =  w_fmname
       EXCEPTIONS
         NO_FORM                  = 1
         NO_FUNCTION_MODULE       = 2
         OTHERS                   = 3
      IF sy-subrc <> 0.
        MESSAGE E002(zcpm) WITH 'Smartform call fails'.
      ENDIF.
    wa_outopt-tdprinter = v_e_devtype.
    wa_ctrlop-no_dialog = 'X'.
    wa_ctrlop-getotf    = 'X'.
      CALL FUNCTION w_fmname "'/1BCDWB/SF00000025'
        EXPORTING
    *   ARCHIVE_INDEX              =
    *   ARCHIVE_INDEX_TAB          =
    *   ARCHIVE_PARAMETERS         =
        CONTROL_PARAMETERS         = WA_CTRLOP
    *   MAIL_APPL_OBJ              =
    *   MAIL_RECIPIENT             =
    *   MAIL_SENDER                =
        OUTPUT_OPTIONS             = WA_OUTOPT
    *    USER_SETTINGS              = ' '
        IMPORTING
    *   DOCUMENT_OUTPUT_INFO       =
        JOB_OUTPUT_INFO            = T_OTFDATA
    *   JOB_OUTPUT_OPTIONS         =
    *    document_output_info       = st_document_output_info
    *    job_output_info            = st_job_output_info
    *    job_output_options         = st_job_output_options
        TABLES
          T_FINAL                    = T_FINAL
          T_ZSDT_WAGONS              = T_ZSDT_WAGONS_1
          T_QTY                      = T_QTY
          T_QTY1                     = T_QTY1
          T_CON1                     = T_CON1
          T_CON2                     = T_CON2
          "T_ZTMM_OUTWB_TXN           = T_ZTMM_OUTWB_TXN
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 4
       OTHERS                     = 5
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    T_OTF[] = T_OTFDATA-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
              format = 'ASCII'
              max_linewidth = 132
    * ARCHIVE_INDEX = ' '
    IMPORTING
              bin_filesize = w_bin_filesize
    TABLES
              otf   = t_otf
              lines = t_pdf_tab
    EXCEPTIONS
              err_max_linewidth = 1
              err_format = 2
           err_conv_not_possible = 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.
    if tabix_m = 1.
    *CALL METHOD cl_gui_frontend_services=>file_save_dialog
    *CHANGING
    *filename = w_FILE_NAME
    *path     = w_FILE_PATH
    *fullpath = w_FULL_PATH
    ** USER_ACTION =
    ** FILE_ENCODING =
    *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 function 'TMP_GUI_BROWSE_FOR_FOLDER'
    EXPORTING
    WINDOW_TITLE = 'Select A File Folder'
    INITIAL_FOLDER = 'C:\'
    IMPORTING
    SELECTED_FOLDER = W_PATH.
    endif.
    CONDENSE W_PATH.
    concatenate W_PATH '\' wa_final-vbeln '.XLS' into w_FULL_PATH.
    ****************************************************************************Saving the PDF file on to Application server************************
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       BIN_FILESIZE                     = w_bin_filesize
       FILENAME                         = w_FULL_PATH
       FILETYPE                         = 'BIN'
    *   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                      = w_filesize
      TABLES
        DATA_TAB                        = t_pdf_tab
    *   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
       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
    As u said ,u want to download a smartform to Excel it could be done but only if u r using a internal table and exactly printing line by line values in the smartform, But if u are performing calculation in between, using multiple internal table Work areas, structures, etc i.e if whole smartform is developed with many distributed windows , unfortunately it wont be possible to download a smartform to excel in such cases, because the whole output comes from multiple internal tables, calculations, etc all the data is not printed in a tabular manner so in such a case it would be just impossible to download the smartform  to excel.
    But we definitely have a workaround which could be done to download the data into excel.
    you can develop a ALV report with a header and footer u can define the header and footer of the alv according to the smartform and the middle portion would contain the tabular kind of data which u must be using as Smartform table to print the same.
    So if u have a similar kind of smartform with some header data, tabular data, and some footer data, then u can use ALV to do the same thing , advantage with ALV would be that u can easily download the same into excel.
    Other alternative is that u can Convert and download the smartform to PDF  and copy the same to an Excel wooksheet.
    These are all the possibilities with which u can do the same.
    Regards,
    Akash Rana

Maybe you are looking for

  • Does the HDMI port work on the Cisco set top box?

    I just bought a new tv (LG model 24MA31D) and the Verizon tech hooked up the FIOS set top box to it using the composite cables that came with it. The tv only has one set of ports for the 5 cables. To use my Wii I have to either trade out all the cabl

  • Beginner needs Java applet Help!!!

    I would be greatful if someone could answer any of the questions below following the description, thank you: Description: There are 3 textFields, 3buttons(add,delete,display), and 1 textArea on my applet. User types their "name" in the first textFiel

  • GRN and SRN report

    Dear SAP MM, Can you please tell me where can I extract the GRN and SRN in a certain period? Any report or table? please help. thanks zhie.

  • Setting defaults for link tool?

    Hi, I'm creating a mega-multimedia pdf with lots of little pdfs attached to it. The customer wants each link in the megaPDF to open a mini-pdf in its own window, and each one should be set to open in "fit to page" zoom mode. When I use the link tool,

  • Hyper-V is missing in features on off windows 10 preview

    Hello, I've installed windows 10 preview. My computer enables virtualization and slat and everything it needs but why  there is no Hyper-V enable in feature on-off?  I want to check the windows phone 8.1 emulator on visual studio but it says there is