Download to excell

Hi All,
         I'm downloading o/p into excell file...
but for excell download i need to add header information how to add those....
my code as below..
METHOD onactiondownload .
  DATA lo_nd_it_prod_req_list_item TYPE REF TO if_wd_context_node.
  DATA lo_el_it_prod_req_list_item TYPE REF TO if_wd_context_element.
  DATA itab TYPE wd_this->elements_n_prod_req_list_item.
  DATA wa TYPE wd_this->element_n_prod_req_list_item.
  DATA : text TYPE string.
  DATA xtext  TYPE xstring.
navigate from <CONTEXT> to <SFLIGHT> via lead selection
  lo_nd_it_prod_req_list_item = wd_context->get_child_node( name = wd_this->wdctx_n_prod_req_list_item ).
get all declared attributes
  lo_nd_it_prod_req_list_item->get_static_attributes_table(
    IMPORTING
      table = itab ).
  TYPES : BEGIN OF ty_tab ,
            reqno       TYPE zmatreq-reqno,
            zitem       TYPE zmatreq-zitem,
            zreqtype    TYPE zmatreq-zreqtype,
            maktx       TYPE zmatreq-maktx,
            meins       TYPE zmatreq-meins,
            matkl       TYPE zmatreq-matkl,
            zbrand      TYPE zmatreq-zbrand,
            zvers       TYPE zmatreq-zvers,
            a_material  TYPE zmatreq-matnr,
            a_price     TYPE string,
            waers       TYPE zmatreq-waers,
            zmenge      TYPE string,
            name1       TYPE string,
            bill        TYPE string,
            zstatus     TYPE zmatreq-zstatus,
            lead_time   TYPE zmatreq-lead_time,
         END OF ty_tab.
     itab1 like TABLE OF itab.
  DATA : itab1 TYPE  TABLE OF ty_tab.
  DATA : wa_tab TYPE ty_tab.
  LOOP AT itab INTO wa.
  move wa-reqno to wa_tab-reqno.
    wa_tab-reqno    = wa-reqno.
    wa_tab-zitem    = wa-zitem.
    wa_tab-zreqtype = wa-zreqtype.
    wa_tab-maktx    = wa-maktx.
    wa_tab-meins    = wa-meins.
    wa_tab-matkl    = wa-matkl.
    wa_tab-zbrand   = wa-zbrand.
    wa_tab-zvers    = wa-zvers.
    wa_tab-a_material = wa-a_material.
    wa_tab-a_price    = wa-a_price.
    wa_tab-waers      = wa-waers.
    wa_tab-zmenge     = wa-zmenge.
    wa_tab-name1      = wa-name1.
    wa_tab-bill       = wa-bill.
    wa_tab-zstatus    = wa-zstatus.
    wa_tab-lead_time  = wa-lead_time.
    APPEND wa_tab TO itab1.
    CLEAR wa_tab.
  ENDLOOP.
  LOOP AT itab1 INTO wa_tab.
    CONCATENATE text
                wa_tab-reqno
                wa_tab-zitem
                wa_tab-zreqtype
                wa_tab-a_material
                wa_tab-maktx
                wa_tab-meins
                wa_tab-zmenge
                wa_tab-a_price
                wa_tab-waers
                wa_tab-matkl
                wa_tab-zbrand
                wa_tab-zvers
                wa_tab-name1
                wa_tab-bill
                wa_tab-lead_time
                wa_tab-zstatus
                cl_abap_char_utilities=>newline INTO text SEPARATED BY
                cl_abap_char_utilities=>horizontal_tab.
*append text.
  ENDLOOP.
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = text
    IMPORTING
      buffer = xtext.
  wdr_task=>client_window->client->attach_file_to_response(
**path to the word file
  i_filename = 'Pre_Purchase_Query.XLS'
String Variable
  i_content =  xtext
File Type
  i_mime_type = 'EXCEL' ).
ENDMETHOD.
regards
Suprith

Hi Suprith,
    Here is a complete working sample code for downloading from WD table(context) to excel.
method ATTACH_FILES .
  data: xml_out TYPE string.
  data: string_out type string.
  data: line type string.
  data: line2 type string.
  data: conv_out type ref to cl_abap_conv_out_ce.
  data: content1 type xstring.
    data: begin of break,
              mandt type mandt,
              linekey type char_02,
              linebreak type ZLINEBREAK,
        end of break.
    DATA lo_nd_node_data TYPE REF TO if_wd_context_node.
    DATA lo_el_node_data TYPE REF TO if_wd_context_element.
    DATA ls_node_data TYPE wd_this->element_node_data.
    DATA export_line type wd_this->element_node_data.
    DATA export_tab like STANDARD TABLE OF export_line.
    lo_nd_node_data = wd_context->get_child_node( name = wd_this->wdctx_node_data ).
   select SINGLE * from ZCH_LINEBREAK into break
              where linekey = '01'.
#### This is where you add the header####
  CONCATENATE 'Submission ID'
               'Function'
               'FPO Type'
               'FPO Value'
               'Business Code'
               'Due Date'
               'Bridger'
               'Submitter'
               'Approver'
               'Recharger'
               'Actuals Manager'
               'Local Analyst'
               'Submitter'
             into line SEPARATED BY ','.
  CONCATENATE line break-linebreak into string_out.
*   alternative access  via index
  do.
   lo_el_node_data = lo_nd_node_data->get_element( index = sy-index ).
*   @TODO handle non existant child
    IF lo_el_node_data IS INITIAL.
      exit.
    ELSE.
*   get all declared attributes
    lo_el_node_data->get_static_attributes(
      IMPORTING
        static_attributes = ls_node_data ).
    export_line = ls_node_data .
*    append export_line to export_tab.
    replace: ALL OCCURRENCES OF ',' in export_line-submission_id with space,
             ALL OCCURRENCES OF ',' in   export_line-fnc_desc with space,
             ALL OCCURRENCES OF ',' in   export_line-fpo_type with space,
             ALL OCCURRENCES OF ',' in   export_line-fpo_value with space,
             ALL OCCURRENCES OF ',' in   export_line-bu_code with space,
             ALL OCCURRENCES OF ',' in   export_line-zdue_date with space,
             ALL OCCURRENCES OF ',' in   export_line-bridger_text with space,
             ALL OCCURRENCES OF ',' in   export_line-submitter_text with space,
             ALL OCCURRENCES OF ',' in   export_line-approver_text with space,
             ALL OCCURRENCES OF ',' in   export_line-recharger_text with space,
*             " Added - Multipule Template assigment D.Wong 03/12/08
*             ALL OCCURRENCES OF ',' in   export_line-ztext with space,
*             " End - Multipule Template assigment D.Wong 03/12/08
             ALL OCCURRENCES OF ',' in   export_line-actuals_manager_text with space,
*             ALL OCCURRENCES OF ',' in   export_line-zassigned_to_text with space,
             ALL OCCURRENCES OF ',' in   export_line-local_analyst_text with space.
    CONCATENATE
                export_line-submission_id
                export_line-fnc_desc
                export_line-fpo_type
                export_line-fpo_value
                export_line-bu_code
                export_line-zdue_date
                export_line-bridger_text
                export_line-submitter_text
                export_line-approver_text
                export_line-recharger_text
                export_line-local_analyst_text into line SEPARATED BY ','.
    CONCATENATE string_out line break-linebreak into string_out.
    ENDIF.
  enddo.
*  call transformation ('ID') source tab = export_tab result xml xml_out.
  conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
  EXPORTING
  text = string_out
* MIMETYPE = ' '
* ENCODING =
  IMPORTING
  BUFFER = content1
* EXCEPTIONS
* FAILED = 1
* OTHERS = 2
* attach the first file
    conv_out->convert( exporting data = content1 ).
    cl_wd_runtime_services=>attach_file_to_response(
    i_filename  = 'file1.csv'
    i_content   = content1
    i_mime_type = 'application/msexcel'
    i_in_new_window = i_in_new_window
    i_inplace       = i_inplace ).
endmethod.
Please appreciate if helpful.

Similar Messages

  • Warning while downloading an Excel file from WD ABAP

    Hi folks,
    In one of requirements, Client wants to download all the data that is appearing on the screen ( WD ABAP Application ) to an Excel with a layout in different manner.
    We achieved this with Simple Transformations.
    Now the question is while downloading the excel file, the framework/other  is throwing an Warning like
    " The file you are trying to open, 'info.xls', is in a different format than specified by the extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now? "
    Note: All the users of my client are using MS Office 2002 / 2003.
    I am using the following code........!
    *------ Call Transformation for Excel OUTPUT
      CALL TRANSFORMATION ZEXCEL_OUTPUT
          SOURCE
                 t_dates     = t_dates
                 t_info        = t_info
          RESULT XML l_xml_string.
    REPLACE ALL OCCURRENCES OF '<?xml version="1.0" encoding="utf-16"?>'  l_xml_string WITH '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>'.
    **-- Call Function Module for converting string data to XSTRING
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text           = l_xml_string
          mimetype = 'application/xml'
        IMPORTING
          buffer      = l_xml_xstring
        EXCEPTIONS
          failed   = 1
          OTHERS   = 2.
      CALL METHOD cl_wd_runtime_services=>attach_file_to_response
        EXPORTING
          i_filename       = 'info.xml'
          i_content        = l_xml_xstring
          i_mime_type   = 'application/vnd.ms-excel'.
    With this code I am generating a file of type XML SPREADSHEET 2003. While opening this file I am getting the above message which the user unwanted......
    Can any one help me on this -
    > How to avoid this warning?
    Thanks and Regards,
    Aneel Danda
    Edited by: danda aneel on Jul 13, 2010 1:43 PM

    Firstly, Thanks for Your quick Response, Thomas.
    Even though what ever may be the file name I am passing either info.xml or Info.xls , In error info.xls is coming.
    Kindly provide me an alternative on this  XML doesn't seem like it would match the 'application/vnd.ms-excel'.
    what is the supported format.?
    Similarly, It is not considering the UTF-8 / UTF-16 for xml.........same result is appearing in the output.
    Edited by: danda aneel on Jul 14, 2010 7:52 AM

  • Doubt on ALV report download to EXCEL

    Hi All,
    i have written a report with ALV_GRID FM, by default we get the option to download the output to excel. But when we click on the download to excel, it displays the output
    in the frist page, but it also opens so many pages like
    format, header, pivot,sub1,sub1....etc.
    Pls. check the SAP standard report BCALV_TEST_FULLSCREEN, does the same thing when we do download to excel.
    How can i avoid opening so many pages in excel?
    Thanks for the help.
    Sekar

    Hi ,
    prabhu here , i think check the FM wheather u r passing all these to FM. for Excel keep export.param: --> i_save only and check.
    regards
    prabhu

  • Help needed: Download to excel without pop-up

    Hi All,
    In a particular scenario, I require to trigger an action once a file have been successfully downloaded to EXCEL from Webdynpro UI. But in case of download functionilty, once the MS window pop-up for download comes up, the control is lost from Webdynpro and its impossible to track whether user have saved, opened or canceled the file.
    Is there any functionality to directly download internal table content to EXCEL, without facing the download popup. Please let me know any function module or functionality for this.
    Thanks in advance to all.
    Regards,
    Mainak

    yes there are many tutorials on SDN regarding this
    u may procced like this :
    get the contents in internal table  and then use the FM 'SCMS_STRING_TO_XSTRING'
    DATA text   TYPE string.
      DATA xtext  TYPE xstring.
    *   get all declared attributes
      lo_nd_sbook->get_static_attributes_table(
        IMPORTING
         table = lt_sbook ).
      LOOP AT lt_sbook INTO ls_sbook.
    CONCATENATE text ls_sbook-carrid
    ls_sbook-connid
    ls_sbook-fldate
    ls_sbook-bookid
    ls_sbook-order_date
    ls_sbook-counter
    ls_sbook-passname
    cl_abap_char_utilities=>newline INTO text SEPARATED BY
    cl_abap_char_utilities=>horizontal_tab.
    ENDLOOP.
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            text   = text
          IMPORTING
            buffer = xtext.
        wdr_task=>client_window->client->attach_file_to_response(
    **path to the word file
    i_filename = 'WDP.xls'
    * String Variable
    i_content =  xtext
    * File Type
    i_mime_type = 'EXCEL' ).
    here it_sbook is the inernal table and ls_sbook is the structure type of the attributes declared in the context node sbook
      DATA ls_sbook TYPE wd_this->element_sbook.
    *  data LT_SFLIGHT type WD_THIS->ELEMENTS_SFLIGHT.
      DATA lt_sbook TYPE wd_this->elements_sbook.
    Edited by: amit saini on Oct 14, 2009 1:30 PM

  • Download to Excel is hiding rows in a pivot view

    Hello ,
    When downloading a report to excel from OBIEE Dashboard , certain rows are getting hidden . For instance , I have total 15 rows in my pivot view and when I download that report into excel format , the rows from 8-13 are not showing up . After 7th row I see 14th row .
    But when I download the same report from Answers I can see all rows in the pivot view .
    I tried looking at the formatting options of the pivot view and everything is normal . This is happening only with this particular report , other reports in dashboard download normally .
    Please let me know if anybody has ideas .
    Thank you
    Karthik

    karthik,
    From where ur downloading to excel ...use the download option available at "preview " button ,if you are using the same go with report links download button option
    Last option create a new report (without any filters in case if u have)
    Thanks,
    Saichand.v

  • Download to excel using GUI_DOWNLOAD : Date format

    Hi Gurus,
    I am downloading the data from an internal table to excel file using FM gui_download. The date field in my internal table is in the format MM-DD-YYYY (stored as Char 10 field). But when it downloads to excel, the date format changes to MM/DD/YYYY. I want to keep original format of MM-DD-YYYY in excel.
    Please help, sure points for helpful answers.
    should i use FM gui_download only, or is there some Other useful FM.
    Regards,
    Abhishek

    Hi,
    Check the code below:
    v_date = sy-datum.
    IF v_date CA '/'.
      REPLACE '/' WITH '-' INTO v_date.
    ENDIF.
    Regards
    Kannaiah

  • Upload and download of  excel file in the application server in background

    Hi all,
    i want to download the excel file from application server into internal table and after processing i have to upload to excel file in the application server in the background mode..
    i mean i'll schedule the program in background.
    im using FM ALSM_EXCEL_TO_INTERNAL_TABLE its working fine in fore ground but not in back ground.
    what method i have to follow ?

    Hi Ankit,
    I think this is not possible to open a Excel-File from the application server because the Excel format before Office 2007 where a binary format (Suffix: .xls). The newer Office file format (Suffix: xlsx) is a zipped XML Format. To read the binary Excel-Format you need an OLE Connection between SAP GUI and Office. But at the application server in background you doesn't have this OLE Connection.
    In my opinion you have two possibilities:
    1. Convert all files in the CSV format. This file format can be read with open dataset.
    2. Upload the files from the presentation server in forground. There are some funktion modules in the standard which can read the xls format. But they have some limits regarding the length of cells content.
    My recommendation is solution no. 1. If you know an VBA expert, he can write an Excel-macro which converts all Excel Files in the CSV-Fomat.
    Regards
    Dirk

  • BSP-MVC download to excel

    Hello experts,
    I know there are many threads on this topic in the forum. I tried using method cl_bsp_utility=>download
    but nothing happens. Here is the scenario -
    1. I have BSP
    2. From Do_handle_event in controller class I am calling model method which handles downloading to excel.
    Please help as this is real showstopper for the application, I am developing.
    Thanks, in advance.
    Trupti

    Hi Gopal,
    Thanks for your reply.
    Tried the code you sent me. As I am using BSP-MVC, I am building method in controller class and with event handling calling the method that handles download to excel. But it is not doing anything at all.
    Thank you.
    Trupti

  • In download to excel from bsp hw to increase excel column width to wrap txt

    in download to excel from bsp how to increase excel column width to wrap text
    in each column.
    My client does not want to manually click each cell aftet downloading to excel to see full text in each column

    Hi,
    You can achieve this by formatting your output using HTML table tag.
    Try the following code.
      DATA: lv_output  TYPE string.
      concatenate
      '<table border="1">'
      '<tr style="font-weight: bold; text-align:center; "><td>Name</td><td width="150">Description</td></tr>' cl_abap_char_utilities=>cr_lf
      '<tr><td>First Name</td><td>Some Description goes here..... ....... ...... </td></tr>' cl_abap_char_utilities=>cr_lf
      '<tr><td>2nd Name</td><td>XYZ.......</td></tr>' cl_abap_char_utilities=>cr_lf
      '</table>'
      into lv_output.
      response->set_cdata( data = lv_output ).
    Regards
    Geogy
    PS. Reward the useful answers.

  • How can i bring the column heading downloaded in excel sheet?

    hi all,
    I am using  FM SAP_CONVERT_TO_XLS_FORMAT to downloading populated internal table data into excel sheet by using filename type rlgrap-filename.
    Now I need the column heading(field name) for downloaded data in excel sheet.
    pls tell me how can i merge the col heading with data perfectly. Is there any FM fulfills this requirement.
    pls give me a suitable approch.
    Thanks
    PRR

    HI,
    Go thru this code.
    REPORT  ZRMM0056  NO STANDARD PAGE HEADING
                          MESSAGE-ID ZZ
                          LINE-SIZE 300
                          LINE-COUNT 65.
    Program              : ZRMM0056
    Title                : Non Inventory PO's
    Description          : Non Inventory Purchase Orders details with
                           Vendor and Invoice Receipts and Goods Receipts.
    Input  :
           Select-options  : 1. G/L Account No
           Parameters      : 1.File Paths for the Excel sheet
           Others (Specify):
    Output : Extract Files in the application server
           Report  :
    Hear Ticket #        : 113392
    Created by           : Srinivas Rao.M
    Created on           : 12/15/2005
    Version              : 1
    Request              : D10K944304
    Transaction Code     : Z420
    Change History                                                       *
    Date         Programmer  Search String   Description                 *
    12/19/2005   Srinivas    D10K944316      Removed Purchasing document
                                             Company code and Plant from
                                             Select-Options and Inculded
                                             G/L Account No and changed
                                             code accordingly.
    T A B L E S                                                          *
    TABLES: EKBE,              " History of Purchasing Document
            EKPO,              " Purchasing Document Item
            EKKO,              " Purchasing Document Header
            LFA1,              " Vendor master (general section)
            EKKN.              " Account Assignment in Purchasing Doc
                        INTERNAL TABLES
    *--Internal table to store Purchasing document header data
    DATA : BEGIN OF IT_POHEADER OCCURS 0,
            EBELN LIKE EKKO-EBELN,      "Purchasing document
            AEDAT LIKE EKKO-AEDAT,      "Created on
            ERNAM LIKE EKKO-ERNAM,      "Created by
            LIFNR LIKE EKKO-LIFNR,      "Vendor
          END OF IT_POHEADER.
    *--Internal table to store Purchasing document Item data
    DATA : BEGIN OF IT_POITEM OCCURS 0,
            EBELN LIKE EKPO-EBELN,       "Purchasing document
            EBELP LIKE EKPO-EBELP,       "Item Number
            MATNR LIKE EKPO-MATNR,       "Material number
            BUKRS LIKE EKPO-BUKRS,       "Company code
            WERKS LIKE EKPO-WERKS,       "Plant
            MATKL LIKE EKPO-MATKL,       "Material Group
            MENGE LIKE EKPO-MENGE,       "Order Quantity
            NETPR LIKE EKPO-NETPR,       "Net Price
            PEINH LIKE EKPO-PEINH,       "Price unit
            NETWR LIKE EKPO-NETWR,       "Net Value
          END OF IT_POITEM.
    *--Internal table to hold final display data.
    DATA : BEGIN OF IT_FINAL OCCURS 0,
             EBELN LIKE EKKO-EBELN,       "Purchasing document
             EBELP LIKE EKPO-EBELP,       "Item Number
             AEDAT LIKE EKKO-AEDAT,       "Created on
             ERNAM LIKE EKKO-ERNAM,       "Created by
             MATNR LIKE EKPO-MATNR,       "Material number
             BUKRS LIKE EKPO-BUKRS,       "Company code
             WERKS LIKE EKPO-WERKS,       "Plant
             MATKL LIKE EKPO-MATKL,       "Material Group
             MENGE LIKE EKPO-MENGE,       "Order Quantity
             NETPR LIKE EKPO-NETPR,       "Net Price
             PEINH LIKE EKPO-PEINH,       "Price unit
             NETWR LIKE EKPO-NETWR,       "Net Value
             LIFNR LIKE EKKO-LIFNR,       "Vendor
             NAME1 LIKE LFA1-NAME1,       "Vendor Name
             GSBER LIKE EKKN-GSBER,      "Business area
    *--IR details
            IR_BELNR LIKE EKBE-BELNR,     "IR-Number of Material Document
            IR_BUZEI LIKE EKBE-BUZEI,     "IR-Item in material Document
            IR_BUDAT LIKE EKBE-BUDAT,     "IR-Posting date
            IR_MENGE LIKE EKBE-MENGE,     "IR-Quantity
    *--GR details
            GR_BELNR LIKE EKBE-BELNR,     "GR-Number of Material Document
            GR_BUZEI LIKE EKBE-BUZEI,     "GR-Item in material Document
            GR_BUDAT LIKE EKBE-BUDAT,     "GR-Posting date
            GR_MENGE LIKE EKBE-MENGE,     "GR-Quantity
          END OF IT_FINAL.
    *--Internal table to store History per Purchasing Document data
    DATA : BEGIN OF IT_HISTORY OCCURS 0,
            EBELN LIKE EKBE-EBELN,        "Purchasing document
            EBELP LIKE EKBE-EBELP,        "Item
            VGABE LIKE EKBE-VGABE,        "Trans/Event type
            BELNR LIKE EKBE-BELNR,        "Number of Material Document
            BUZEI LIKE EKBE-BUZEI,        "Item in material Document
            BUDAT LIKE EKBE-BUDAT,        "Posting date
            MENGE LIKE EKBE-MENGE,        "Quantity
            BEWTP LIKE EKBE-BEWTP,        "Posting history category
           END OF IT_HISTORY.
    *--Internal table to store vendor name.
    DATA : BEGIN OF IT_VENDOR OCCURS 0,
             LIFNR LIKE LFA1-LIFNR,      "Vendor Number
             NAME1 LIKE LFA1-NAME1,      "Vendor Name
           END OF IT_VENDOR.
    *--Internal table to store Business area for Purchasing document
    DATA : BEGIN OF IT_BUSINESS OCCURS 0,
             EBELN LIKE EKKN-EBELN,      "Purchasing document
             EBELP LIKE EKKN-EBELP,      "Purchasing Item
             SAKTO LIKE EKKN-SAKTO,      "G/L Account No
             GSBER LIKE EKKN-GSBER,      "Business area
           END OF IT_BUSINESS.
    DATA : BEGIN OF FIELDNAMES OCCURS 0,
           TEXT(40),
          END OF FIELDNAMES.
                    VARIABLES DECLARATION                                *
    DATA: V_FILE LIKE IBIPPARMS-PATH,         "File path
           V_FLD  LIKE DYNPREAD-FIELDNAME,     "Dynpread fieldname
           V_FLAG(1) VALUE SPACE.              "FLAG VARIABLE
                            SELECTION-SCREEN                             *
    SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.
    *--Begin of change D10K944316
    SELECT-OPTIONS : S_SAKTO FOR EKKN-SAKTO.  "G/L Accoun no.
    *--End of change D10K944316
    SELECTION-SCREEN END OF BLOCK S1.
    SELECTION-SCREEN BEGIN OF BLOCK S2 WITH FRAME TITLE TEXT-002.
    PARAMETERS : P_EXCEL    AS CHECKBOX DEFAULT ' ' .  " download to excel
    PARAMETERS : C_FILE(128) DEFAULT : 'C:\ZRMM0056.xls'.
    SELECTION-SCREEN END OF BLOCK S2.
    A T   S E L E C T I O N - S C R E E N                                *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR C_FILE.
    *-Form to get file path for download of data
      PERFORM GET_FILE_PATH.
    AT SELECTION-SCREEN.
      PERFORM SCREEN_VALIDATIONS.
    START-OF-SELECTION
    START-OF-SELECTION.
    *--Extract Purchasing document header data.
       PERFORM GET_PO_HEADER_DATA.
    *--Extract Purchasing document Item data.
       IF NOT IT_BUSINESS[] IS INITIAL.
         PERFORM GET_PO_ITEM_DATA.
    *--Get complete required data in final internal table
         PERFORM GET_FINAL_DATA.
       ENDIF.
    END-OF-SELECTION
    END-OF-SELECTION.
      IF V_FLAG IS INITIAL.
    *--Display Purchasing document details
        IF NOT IT_FINAL[] IS INITIAL.
           PERFORM DISPLAY_PODATA.
          IF P_EXCEL = 'X'.
    *--To down load data to excel sheet
            PERFORM DOWN_LOAD_TO_EXCEL.
          ENDIF.
        ENDIF.
      ELSE.
           MESSAGE I001(ZZ) WITH 'No data found'(003).
      ENDIF.
    TOP-OF-PAGE
    TOP-OF-PAGE.
    *--To display page header
      PERFORM PAGE_HEADER.
    *&      Form  GET_PO_HEADER_DATA
          To Get Purchasing header data
    FORM GET_PO_HEADER_DATA .
    *--To extract Business Area details
           CLEAR IT_BUSINESS.
           REFRESH IT_BUSINESS.
            SELECT EBELN    "Purchasing document
                   EBELP    "Purchasing document item
                   SAKTO    "G/L Account no
                   GSBER    "Business area
                   FROM EKKN
                   INTO TABLE IT_BUSINESS
                   WHERE SAKTO IN S_SAKTO.
      IF SY-SUBRC <> 0.
        V_FLAG = 'X'.
        MESSAGE I001(ZZ)  WITH
        'No data selected for the given selection criteria'(004).
        STOP.
      ELSE.
    *--To extract Purchasing document details with respect
    to G/L Account no
           CLEAR   IT_POHEADER.
           REFRESH IT_POHEADER.
           SELECT EBELN       "Purchasing document
                  AEDAT       "Created on
                  ERNAM       "Created by
                  LIFNR       "Vendor
                FROM EKKO
                INTO TABLE IT_POHEADER
                FOR ALL ENTRIES IN IT_BUSINESS
                WHERE EBELN = IT_BUSINESS-EBELN.
             IF NOT IT_POHEADER[] IS INITIAL.
                CLEAR   IT_VENDOR.
                REFRESH IT_VENDOR.
    *--Extracting Vendor details
                SELECT LIFNR   "Vendor #
                       NAME1   "Name
                     FROM LFA1
                     INTO TABLE IT_VENDOR
                     FOR ALL ENTRIES IN IT_POHEADER
                     WHERE LIFNR = IT_POHEADER-LIFNR.
            ENDIF.
      ENDIF.
    ENDFORM.                    " GET_PO_HEADER_DATA
    *&      Form  GET_PO_ITEM_DATA
          To extract Purchasing document item data
    FORM GET_PO_ITEM_DATA .
    CLEAR   IT_POITEM.
    REFRESH IT_POITEM.
       SELECT EBELN        "Purchasing document
              EBELP        "Item Number
              MATNR        "Material number
              BUKRS        "Company code
              WERKS        "Plant
              MATKL        "Material Group
              MENGE        "Order Quantity
              NETPR        "Net Price
              PEINH        "Price unit
              NETWR        "Net Value
           FROM EKPO
           INTO TABLE IT_POITEM
           FOR ALL ENTRIES IN IT_BUSINESS
           WHERE EBELN = IT_BUSINESS-EBELN
            AND  EBELP = IT_BUSINESS-EBELP.
    IF NOT IT_POITEM[] IS INITIAL.
       CLEAR   IT_HISTORY.
       REFRESH IT_HISTORY.
       SELECT EBELN    "Purchasing document
              EBELP    "Item
              VGABE    "Trans/Event type
              BELNR    "Number of Material Document
              BUZEI    "Item in material Document
              BUDAT    "Posting date
              MENGE    "Quantity
              BEWTP    "Posting history category
            FROM EKBE
            INTO TABLE IT_HISTORY
            FOR ALL ENTRIES IN IT_POITEM
            WHERE EBELN = IT_POITEM-EBELN
              AND EBELP = IT_POITEM-EBELP
              AND ( VGABE = '1' OR VGABE = '2' )   "1 = GR , 2 = IR
              AND ( BEWTP =  'Q' OR BEWTP = 'E' ). "Q = GR , R = IR
       IF SY-SUBRC = 0.
         SORT IT_HISTORY BY EBELN EBELP.
       ENDIF.
    ENDIF.
    ENDFORM.                    " GET_PO_ITEM_DATA
    *&      Form  GET_FILE_PATH
          Select file path
    FORM GET_FILE_PATH .
    CLEAR V_FILE.
      MOVE 'p_flname' TO V_FLD.
      MOVE C_FILE TO V_FILE.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME  = SYST-CPROG
                DYNPRO_NUMBER = SYST-DYNNR
                FIELD_NAME    = V_FLD
           IMPORTING
                FILE_NAME     = V_FILE
           EXCEPTIONS
                OTHERS        = 1.
      MOVE V_FILE TO C_FILE.
    ENDFORM.                    " GET_FILE_PATH
    *&      Form  PAGE_HEADER
           To Print page header and other details
    FORM PAGE_HEADER .
    *--Page Header
    ULINE AT /1(300).
      FORMAT COLOR 1.
      WRITE:/ 'Run Date:'(005), SY-DATUM, 45 'Stanley Works'(006),
             100 'Page No:'(007), SY-PAGNO LEFT-JUSTIFIED, 298 ''.
      WRITE:/ 'Run Time:'(008), SY-UZEIT, 43 SY-TITLE, 100 SY-UNAME, 298 ''.
      WRITE:/ 'Source  :'(009), SY-SYSID, 100 SY-CPROG, 298 ''.
      FORMAT COLOR OFF.
      ULINE AT /1(300).
      FORMAT COLOR 4.
      WRITE : / SY-VLINE , (10) 'Purchasing Doc'(010),
                SY-VLINE,  (5)  'Item'(011),
                SY-VLINE,  (10) 'Created On'(012),
                SY-VLINE,  (7)  'Crea By'(013),
                SY-VLINE,  (10) 'Material'(014),
                SY-VLINE,  (6)  'Com cd'(015),
                SY-VLINE,  (5)  'Plant'(016),
                SY-VLINE,  (10) 'Mat Group'(017),
                SY-VLINE,  (13) 'Order Qty'(018),
                SY-VLINE,  (11) 'Net Price'(019),
                SY-VLINE,  (10) 'Price Unit'(020),
                SY-VLINE,  (13) 'Net Value'(021),
                SY-VLINE,  (8)  'Bus Area'(022),
                SY-VLINE,  (10) 'Vendor'(023),
                SY-VLINE,  (28) 'Vendor Name'(024),
    *--IR details
                SY-VLINE,  (10) 'IR-Mat Doc'(025),
                SY-VLINE,  (5)  'IR-It'(026),
                SY-VLINE,  (9) 'IR-Post dt'(027),
                SY-VLINE,  (13) 'IR-Quantity'(028),
    *--GR details
                SY-VLINE,  (10) 'GR-Mat Doc'(029),
                SY-VLINE,  (5)  'GR-It'(030),
                SY-VLINE,  (9) 'GR-Post dt'(031),
                SY-VLINE,  (13) 'GR-Quantity'(032), SY-VLINE.
      FORMAT COLOR OFF.
      ULINE AT /1(300).
    ENDFORM.                    " PAGE_HEADER
    *&      Form  SCREEN_VALIDATIONS
          Selection screen validations
    FORM SCREEN_VALIDATIONS .
    *--Validation for G/L Account No
    IF NOT S_SAKTO IS INITIAL.
        SELECT SAKNR UP TO 1 ROWS
               INTO EKKN-SAKTO
               FROM SKA1 WHERE
               SAKNR IN S_SAKTO.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E001(ZZ) with 'Please enter a valid G/L Account no'(048).
        ENDIF.
      ENDIF.
    *--Validation for Excel file path
    IF P_EXCEL = 'X'.
        IF C_FILE = ' '.
          MESSAGE E001(ZZ) with 'Please enter a valid Excle Path'(035).
        ENDIF.
      ENDIF.
    ENDFORM.                    " SCREEN_VALIDATIONS
    *&      Form  DISPLAY_PODATA
          To Display Purchasing Document details
    FORM DISPLAY_PODATA .
    FORMAT COLOR 2.
    SORT IT_FINAL BY EBELN EBELP AEDAT BUKRS WERKS.
    LOOP AT IT_FINAL.
         WRITE : / SY-VLINE ,(10)  IT_FINAL-EBELN,     "Purchasing Doc
                   SY-VLINE,  (5)  IT_FINAL-EBELP,     "Item
                   SY-VLINE,  (10) IT_FINAL-AEDAT,     "Created On
                   SY-VLINE,  (7) IT_FINAL-ERNAM,      "Created By
                   SY-VLINE,  (10) IT_FINAL-MATNR,     "Material
                   SY-VLINE,  (6) IT_FINAL-BUKRS,      "Company code
                   SY-VLINE,  (5)  IT_FINAL-WERKS,     "Plant
                   SY-VLINE,  (10) IT_FINAL-MATKL,     "Material Group
                   SY-VLINE,  (13) IT_FINAL-MENGE, "#EC UOM_IN_MES
                                                       "Order Qty
                   SY-VLINE,  (11) IT_FINAL-NETPR, "#EC UOM_IN_MES
                                                       "Net Price
                   SY-VLINE,  (10) IT_FINAL-PEINH, "#EC UOM_IN_MES
                                                       "Price Unit
                   SY-VLINE,  (13) IT_FINAL-NETWR, "#EC UOM_IN_MES
                                                        "Net Value
                   SY-VLINE,  (8)  IT_FINAL-GSBER,     "Bus Area
                   SY-VLINE,  (10) IT_FINAL-LIFNR,     "Vendor
                   SY-VLINE,  (28) IT_FINAL-NAME1,     "Vendor name
    *--IR details
                   SY-VLINE,  (10) IT_FINAL-IR_BELNR,  "IR-Mat Doc
                   SY-VLINE,  (5)  IT_FINAL-IR_BUZEI,  "IR-It
                   SY-VLINE,  (9) IT_FINAL-IR_BUDAT,   "IR-Post dt
                   SY-VLINE,  (13) IT_FINAL-IR_MENGE,  "#EC UOM_IN_MES
                                                        "IR-Quantity
    *--GR details
                   SY-VLINE,  (10) IT_FINAL-GR_BELNR,  "GR-Mat Doc
                   SY-VLINE,  (5)  IT_FINAL-GR_BUZEI,  "GR-It
                   SY-VLINE,  (9) IT_FINAL-GR_BUDAT,   "GR-Post dt
                   SY-VLINE,  (13) IT_FINAL-GR_MENGE, SY-VLINE.
                                                       "#EC UOM_IN_MES
                                                       "GR-Quantity
      ENDLOOP.
      FORMAT COLOR OFF.
    ENDFORM.                    " DISPLAY_PODATA
    *&      Form  DOWN_LOAD_TO_EXCEL
          text
    FORM DOWN_LOAD_TO_EXCEL .
      <b>REFRESH FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-010.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-011.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-012.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'Created By'(036).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-014.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'Company Code'(037).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-016.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'Material Group'(038).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'Order Quantity'(039).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-019.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-020.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-021.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'Business Area'(040).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-023.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-024.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'IR Material Doc'(041).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'IR Item'(042).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'IR Posting Date'(043).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-028.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'GR Material Doc'(044).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'GR Item'(045).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = 'GR Posting Date'(046).
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
      FIELDNAMES-TEXT = TEXT-032.
      APPEND FIELDNAMES.CLEAR FIELDNAMES.
    *--FM to download data to Excel sheet
    CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                FILENAME                = C_FILE
                FILETYPE                = 'DAT'
                TABLES
                DATA_TAB                = IT_FINAL
                FIELDNAMES              = FIELDNAMES
           EXCEPTIONS
                FILE_OPEN_ERROR         = 1
                FILE_WRITE_ERROR        = 2
                INVALID_FILESIZE        = 3
                INVALID_TABLE_WIDTH     = 4
                INVALID_TYPE            = 5
                NO_BATCH                = 6
                UNKNOWN_ERROR           = 7
                GUI_REFUSE_FILETRANSFER = 8
                OTHERS                  = 9.
      IF SY-SUBRC <> 0.
         MESSAGE E001(ZZ) WITH 'Data could not downloaded'(047).
      ENDIF.</b>ENDFORM.                    " DOWN_LOAD_TO_EXCEL
    *&      Form  GET_FINAL_DATA
          To Populate required data in final internal table
    FORM GET_FINAL_DATA .
    CLEAR   IT_FINAL.
    REFRESH IT_FINAL.
    LOOP AT IT_POITEM.
       CLEAR IT_POHEADER.
       READ TABLE IT_POHEADER WITH KEY EBELN = IT_POITEM-EBELN.
       IF SY-SUBRC = 0.
        MOVE :  IT_POHEADER-EBELN TO IT_FINAL-EBELN,     "Purchasing Doc
                IT_POITEM-EBELP   TO IT_FINAL-EBELP,     "Item
                IT_POHEADER-AEDAT TO IT_FINAL-AEDAT,     "Created On
                IT_POHEADER-ERNAM TO IT_FINAL-ERNAM,     "Created By
                IT_POITEM-MATNR   TO IT_FINAL-MATNR,     "Material
                IT_POITEM-BUKRS   TO IT_FINAL-BUKRS,     "Company code
                IT_POITEM-WERKS   TO IT_FINAL-WERKS,     "Plant
                IT_POITEM-MATKL   TO IT_FINAL-MATKL,     "Material Group
                IT_POITEM-MENGE   TO IT_FINAL-MENGE,     "Order Qty
                IT_POITEM-NETPR   TO IT_FINAL-NETPR,     "Net Price
                IT_POITEM-PEINH   TO IT_FINAL-PEINH,     "Price Unit
                IT_POITEM-NETWR   TO IT_FINAL-NETWR,     "Net Value
                IT_POHEADER-LIFNR TO IT_FINAL-LIFNR.     "Vendor
    *--To Insert IR details
        CLEAR IT_HISTORY.
        READ TABLE IT_HISTORY WITH KEY EBELN = IT_POITEM-EBELN
                                       EBELP = IT_POITEM-EBELP
                                       VGABE = '2'
                                       BEWTP = 'Q'.
          IF SY-SUBRC = 0.
            MOVE :
              IT_HISTORY-BELNR TO IT_FINAL-IR_BELNR,  "IR-Number of Mat Doc
              IT_HISTORY-BUZEI TO IT_FINAL-IR_BUZEI,  "IR-Item in mat Doc
              IT_HISTORY-BUDAT TO IT_FINAL-IR_BUDAT,  "IR-Posting date
              IT_HISTORY-BUDAT TO IT_FINAL-IR_MENGE.   "IR-Quantity
          ENDIF.
    *--To insert GR details
        CLEAR IT_HISTORY.
        READ TABLE IT_HISTORY WITH KEY EBELN = IT_POITEM-EBELN
                                       EBELP = IT_POITEM-EBELP
                                       VGABE = '1'
                                       BEWTP = 'E'.
          IF SY-SUBRC = 0.
            MOVE :
              IT_HISTORY-BELNR TO IT_FINAL-GR_BELNR,  "IR-Number of Mat Doc
              IT_HISTORY-BUZEI TO IT_FINAL-GR_BUZEI,  "IR-Item in mat Doc
              IT_HISTORY-BUDAT TO IT_FINAL-GR_BUDAT,  "IR-Posting date
              IT_HISTORY-BUDAT TO IT_FINAL-GR_MENGE.  "IR-Quantity
          ENDIF.
    *--To insert Vendor details
         CLEAR IT_VENDOR.
         READ TABLE IT_VENDOR WITH KEY LIFNR = IT_POHEADER-LIFNR.
         IF SY-SUBRC = 0.
          MOVE : IT_VENDOR-NAME1 TO IT_FINAL-NAME1.
         ENDIF.
    *--To insert Business area
         CLEAR IT_BUSINESS.
         READ TABLE IT_BUSINESS WITH KEY EBELN = IT_POITEM-EBELN
                                         EBELP = IT_POITEM-EBELP.
         IF SY-SUBRC = 0.
           MOVE : IT_BUSINESS-GSBER TO IT_FINAL-GSBER.
         ENDIF.
          APPEND IT_FINAL.
          CLEAR  IT_FINAL.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_FINAL_DATA
    thanks
    Sunil

  • Regarding Download to Excel

    hi,
    by ALV_GRID is it possible to filter the no of columns download into Excel?
    EX: if my ALV(report) contains 30 fileds and i am diplaying only 10 fileds on output by using variant.. is it possible to down load that displayed 10 feilds into excel sheet not total 30 fileds..
    sample codes are welcome......
    Regards
    Ashok Parupalli.
    Message was edited by: Ashok Parupalli

    Hi Ashok,
    You need to download the total excel sheet into Internal table, there is a one way to ignore excel sheet rows, but you can ignore records only starts from first in the excel sheet, you can not ignore the middle of records in the excel sheet, i mean if the excle sheer is having 30 rows, then you can take from 20th row to 30th row, but you can not ignore the middle of records while uploading the excel sheet.
    i do not know whether it is possible with OLE, anyways Look at transaction DWDM for demo/examples, there's lots of tricks with OLEobjects
    look at the below program, this is OO concept
    http://www.sapgenie.com/abap/code/abap41.htm
    Thanks
    Sudheer

  • Using download button in ALV to download to excel

    Hi,
    Please provide me the solution on using download button in Hierarchial List ALV to download to excel.I need to download the Header and Item details in a single line (in one line)in the Excel sheet.
    Please suggest the solution and sample code ASAP.
    Thanks and Regards,
    Latha.

    Hi Rames,
    my mail id : [email protected]
    Thanks and Regards,
    Vidyullatha.

  • ALV download to excel inquiry

    Hi,
    I have a problem with regards to the ALV download to excel.  I have an ALV grid with 40 columns and i need to download the output to an excel file.  But after downloading the ALV output, i noticed that some columns are already on the next line. i need to have all columns to be in the same line.  Does anyone have an idea how to prevent columns to be printed in the next line?
    Thanks in advance!
    Kind regards,
    Merriam

    Looks like Note 855314 has a workaround ... my be more.
    Of course (yuk!), write you own download.
    Best!
    Jim

  • Reg: ALV output download using excel option

    Hi Team,
    I  created  a report using ALV Function modules, I want to download in  Excel sheet the  output list. i am trying to download but i am not getting proper values. I am populating around 50 fileds.
    is there any settings for these download.
    <<removed by moderator>>
    Thanks & Regards,
    Mahendar patha.

    hi mahendra;
    use this step-by-step procedure it will help u a lot:
    Firstly export  the data to memory using the FM LIST_FROM_MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = t_listobject
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE e000(su) WITH text-001.
    ENDIF.
    then i converted it into ASCII using LIST_TO_ASCI,
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = t_xlstab
    listobject = t_listobject
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3.
    IF sy-subrc NE 0.
    MESSAGE e003(yuksdbfzs).
    ENDIF.
    This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
    cl_abap_char_utilities=>horizontal_tab.
    Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
    This will create an excel attachment.
    Sample code for formatting the data for the attachment in excel format.
    u2022     Format the data for excel file download
    LOOP AT t_xlstab INTO wa_xlstab .
    DESCRIBE TABLE t_xlstab LINES lw_cnt.
    CLEAR lw_sytabix.
    lw_sytabix = sy-tabix.
    u2022     If not new line then replace '|' by tabs
    IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
    WITH cl_abap_char_utilities=>horizontal_tab.
    MODIFY t_xlstab FROM wa_xlstab .
    CLEAR wa_xlstab.
    wa_xlstab = cl_abap_char_utilities=>newline.
    IF lw_cnt NE 0 .
    lw_sytabix = lw_sytabix + 1.
    u2022     Insert new line for the excel data
    INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
    lw_cnt = lw_cnt - 1.
    ENDIF.
    CLEAR wa_xlstab.
    ENDIF.
    ENDLOOP.
    Sample code for creating attachment and sending mail:
    FORM send_mail .
    u2022     Define the attachment format
    lw_doc_type = 'XLS'.
    u2022     Create the document which is to be sent
    lwa_doc_chng-obj_name = 'List'.
    lwa_doc_chng-obj_descr = w_subject. "Subject
    lwa_doc_chng-obj_langu = sy-langu.
    u2022     Fill the document data and get size of message
    LOOP AT t_message.
    lt_objtxt = t_message-line.
    APPEND lt_objtxt.
    ENDLOOP.
    DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
    IF lw_tab_lines GT 0.
    READ TABLE lt_objtxt INDEX lw_tab_lines.
    lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
    lwa_doc_chng-obj_langu = sy-langu.
    lwa_doc_chng-sensitivty = 'F'.
    ELSE.
    lwa_doc_chng-doc_size = 0.
    ENDIF.
    u2022     Fill Packing List For the body of e-mail
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = 'RAW'.
    APPEND lt_packing_list.
    u2022     Create the attachment (the list itself)
    DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
    u2022     Fill the fields of the packing_list for creating the attachment:
    lt_packing_list-transf_bin = 'X'.
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = lw_doc_type.
    lt_packing_list-obj_name = 'Attach'.
    lt_packing_list-obj_descr = w_docdesc.
    lt_packing_list-doc_size = lw_tab_lines * 255.
    APPEND lt_packing_list.
    u2022     Fill the mail recipient list
    lt_reclist-rec_type = 'U'.
    LOOP AT t_recipient_list.
    lt_reclist-receiver = t_recipient_list-address.
    APPEND lt_reclist.
    ENDLOOP.
    u2022     Finally send E-Mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    sent_to_all = lw_sent_to_all
    TABLES
    packing_list = lt_packing_list
    object_header = lt_objhead
    contents_bin = t_xlstab
    contents_txt = lt_objtxt
    receivers = lt_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    Hope it will help you
    Regards
    Rahul sharma
    Edited by: RAHUL SHARMA on Nov 4, 2008 1:22 PM

  • ALV output download to excel with top of page

    Hi,
    i want to download ALV grid output to excel sheet including the top of page. i am using the icon in application tool bar. but only data's are download to excel sheet. i cannot download the top of page. with out write coding in program can we download it. if yes pls explain.
    thanks.

    I'm sorry but I can't find FM with DOWNLOAD_EXCEL_*.
    I want to know more detail thing.
    plz. give answer to me anytime.
    I'm waiting..
    Edited by: Kwang Seop Kim on Sep 26, 2008 6:57 AM

  • ALV grid toolbar - standard download to excel error

    Hi Experts,
    In my ALV grid report,  when i click on the standard ALV toolbar to download the output to excel file, the data gets downloaded fine execpt for one field called serial number. It is of size 18 chars.
    The last number on this field is getting truncated when it is downloaded to excel. Only 17 characters is being shown. There is no output lenght specification in the field catalog. The column width optimize property is also not set. Any ideas on what might be the problem?
    Cheers

    Hi,
    Check this link:
    Re: Digit missing in the alv export
    Hope this helps.
    Regards,
    Satish Kanteti

Maybe you are looking for

  • Project-wise cash Flow

    Respected Guru's,                              There is a requirement of project wise Cost flow here. So, Please suggest what are the attributes needed to get on the same? And, what are the reports needed to analyze upon? Any documentary will be of g

  • IMovie won't update to 9.0.8, Mac App Store tells me I have to buy?

    So, the problem I am having, as alluded to by the title, is that in the "Updates section of the Mac App Store, iMovie has an update to 9.0.8 listed, but when I attempt to update to the new version, the Mac App Store tells me I need to buy it, However

  • Benefits and utilization of ST-ETP addon in Test Management

    Hi Experts, We have installed ST-ETP addon in our Solman. Kindly describe the benefits which we can derive in the Test Management and also how to go about it. Reg, Ashok Singh

  • DETAIL REPORTS OF LOGISTICS

    Hello all Guru's , Kindly advice how to view the report of outbound delievery by a T. CODE., How a project history can be seen, How shipping customer details can be seen , Here my user is from Logistics , pl help. km

  • How to see parallel execution servers

    Hi From a session I am running a query in parallel. Having the session's ID and serial number I want to identify the query coordinator process and the slave processes which run in parallel. Please, tell me from which views and how can I query this in