Conversion of internal table into excel file format &put it on app server

Hi,
My requirement is to convert the internal table into excel file format and I have to store it on application server so that administrator can send the file thr e-mail attachment.
So, please let me know how to convert the records of internal table and store it on application server in Excel file format.
TIA,
Nitin

Hi,
  Use FM GUI_DOWNLOAD to download the data from inernal table to excel sheet.
Then Using tcode CG3Z u can transfer file to application server.
*&      Form  sub_download
      text
-->  p1        text
<--  p2        text
FORM sub_download.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE                    =
      filename                        = p_path
     filetype                        = 'ASC'
    APPEND                          = ' '
     write_field_separator           = 'X'
    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
    HEADER_TOO_LONG                 = 10
    DP_ERROR_CREATE                 = 11
    DP_ERROR_SEND                   = 12
    DP_ERROR_WRITE                  = 13
    UNKNOWN_DP_ERROR                = 14
    ACCESS_DENIED                   = 15
    DP_OUT_OF_MEMORY                = 16
    DISK_FULL                       = 17
    DP_TIMEOUT                      = 18
    FILE_NOT_FOUND                  = 19
    DATAPROVIDER_EXCEPTION          = 20
    CONTROL_FLUSH_ERROR             = 21
    OTHERS                          = 22
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " sub_download
Otherwise use OPEN DATASET and TRANSFER statement to download data from internal table to direct application server
Regards,
Prashant

Similar Messages

  • Reg: Downloading the internal table into excel file.

    Hi,
    My requirement is i am collecting data in the internal table and i have to download the contents in an excel file and i have declared like this.
    PARAMETERS : x_test    TYPE string
                          DEFAULT 'C:\temp\file.txt'.
    I have given the default file path  like this and i am using the function module .
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                    =
          FILENAME                      = OUTPUT_PATH
          FILETYPE                      = 'DAT'
    IMPORTING
      FILELENGTH                      =
        TABLES
          DATA_TAB                        = INT_INPUT
      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.
    My requirement is i dont want to change my extension as .txt from .exl to my parameter addition and in the function module the file type should be 'dat' only and in the runtime i want to change the file name which i have given in the .
    PARAMETERS : x_test    TYPE string
                          DEFAULT 'C:\temp\file.txt' this file.txt into datas.xls.
    it would be grateful if some one share some valuable views to wards this query
    Thanks and Regards,
    Keny

    Hi,
    Use this code.
    It will ask for the file name...there u can change.
      data : l_filename type string,
             l_filetype type char10,
             l_path type string,
             l_fullpath type string.
      l_filetype = 'DAT'.
    *Get the file name
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
        EXPORTING
          FILE_FILTER          = '*.DAT'
          INITIAL_DIRECTORY    = 'C:\'
        CHANGING
          FILENAME             = l_filename
          PATH                 = l_path
          FULLPATH             = l_fullpath
        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.
      check l_fullpath is not initial.
    *Download file
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        EXPORTING
          FILENAME                = l_fullpath
          FILETYPE                = l_filetype
        CHANGING
          DATA_TAB                = t_data_sum[]
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          NOT_SUPPORTED_BY_GUI    = 22
          ERROR_NO_GUI            = 23
          others                  = 24.
      IF sy-subrc NE 0.
        MESSAGE e398(00) WITH sy-subrc ' Error downloading file' '' ''.
      ENDIF.
    Regards
    Sandeep REddy

  • Send An Internal Table Via Excel File As An Attachment of E-mail

    Hi,
    I've sent my internal table via Excel file as an attachment of email but all records of internal table are in a row of sended excel file.
    How can i send an internal table via excel file , records of internal table for each rows of excel file,as an attachment of email correctly?
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list     "   t_packing_list-doc_type   =  'XLS'.
                contents_bin               = pit_attach " this is a normal internal table.
                contents_txt               = pit_message
                receivers                  = t_receivers
           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.

    Hi,
    CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
    CONSTANTS:
    CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
    CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
          LOOP AT T_FINAL INTO WA_T_FINAL.
            CONCATENATE WA_T_FINAL-PERNR
                        WA_T_FINAL-NAME
                        WA_T_FINAL-LEVEL
                        WA_T_FINAL-POS
                        WA_T_FINAL-JOB
                        WA_T_FINAL-SECTION
                        WA_T_FINAL-DEPT
                        WA_T_FINAL-GROUP
                        WA_T_FINAL-EX_HEAD
                        WA_T_FINAL-SUPID
                        WA_T_FINAL-SUPNM
                        WA_T_FINAL-FHRNM
                        WA_T_FINAL-VACID
                        WA_T_FINAL-VAC_SECTION
                        WA_T_FINAL-VAC_DEPT
                        WA_T_FINAL-VAC_GROUP
                        WA_T_FINAL-VAC_EX_HEAD
                        WA_T_FINAL-VAC_FHRNM
            INTO T_FINAL3 SEPARATED BY CON_TAB.
            CONCATENATE CON_CRET T_FINAL3 INTO T_FINAL3.
            APPEND T_FINAL3.
          ENDLOOP.
    *Fill the document data.
      W_DOC_DATA-DOC_SIZE = 1.
    *Populate the subject/generic message attributes
      W_DOC_DATA-OBJ_LANGU = SY-LANGU.
      W_DOC_DATA-OBJ_NAME = 'REPORT'.
      W_DOC_DATA-OBJ_DESCR = LD_MTITLE . "mail description
      W_DOC_DATA-SENSITIVTY = 'F'.
    *Fill the document data and get size of attachment
      CLEAR W_DOC_DATA.
      READ TABLE T_FINAL1 INDEX W_CNT.
      W_DOC_DATA-DOC_SIZE =
      ( W_CNT - 1 ) * 255 + STRLEN( T_FINAL1 ).
      W_DOC_DATA-OBJ_LANGU = SY-LANGU.
      W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
      W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
      W_DOC_DATA-SENSITIVTY = 'F'.
      CLEAR T_ATTACHMENT.
      REFRESH T_ATTACHMENT.
      T_ATTACHMENT[] = PT_FINAL1[].
    *Describe the body of the message
      CLEAR T_PACKING_LIST.
      REFRESH T_PACKING_LIST.
      T_PACKING_LIST-TRANSF_BIN = SPACE.
      T_PACKING_LIST-HEAD_START = 1.
      T_PACKING_LIST-HEAD_NUM = 0.
      T_PACKING_LIST-BODY_START = 1.
      DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
      T_PACKING_LIST-DOC_TYPE = 'RAW'.
      APPEND T_PACKING_LIST.
    *Create 1st attachment notification
      T_PACKING_LIST-TRANSF_BIN = 'X'.
      T_PACKING_LIST-HEAD_START = 1.
      T_PACKING_LIST-HEAD_NUM = 1.
      T_PACKING_LIST-BODY_START = 1.
      DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
      T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
      T_PACKING_LIST-OBJ_DESCR = 'Application 1'.
      T_PACKING_LIST-OBJ_NAME = 'Application 1'.
      T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
      APPEND T_PACKING_LIST.
      CLEAR T_PACKING_LIST.
    *Add the recipients email address
      CLEAR T_RECEIVERS.
      REFRESH T_RECEIVERS.
      T_RECEIVERS-RECEIVER = LD_EMAIL.
      T_RECEIVERS-REC_TYPE = 'U'.
      T_RECEIVERS-COM_TYPE = 'INT'.
      T_RECEIVERS-NOTIF_DEL = 'X'.
      T_RECEIVERS-NOTIF_NDEL = 'X'.
      APPEND T_RECEIVERS.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = W_DOC_DATA
          PUT_IN_OUTBOX              = 'X'
          SENDER_ADDRESS             = LD_SENDER_ADDRESS
          SENDER_ADDRESS_TYPE        = LD_SENDER_ADDRESS_TYPE
          COMMIT_WORK                = 'X'
        IMPORTING
          SENT_TO_ALL                = W_SENT_ALL
        TABLES
          PACKING_LIST               = T_PACKING_LIST
          CONTENTS_BIN               = T_ATTACHMENT
          CONTENTS_TXT               = IT_MESSAGE
          RECEIVERS                  = T_RECEIVERS
        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.
    Edited by: Rahul Ghosh on Apr 6, 2009 6:42 AM

  • 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.

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    EXCEPTIONS
      CONVERSION_FAILED          = 1
      OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • Downloading internal table in excel file on application server

    Hi,
        I am trying to download ITAB into excel file on my application server . I am using FM 'SAP_CONVERT_TO_XLS_FORMAT' for that .
        When I run the report I can see file getting generated on APP server but no ITAB data is saved in that excel.
        After debugging I found that error code  'SAVE_DOCUMENT_FAILED'  is retuned in above FM.
        Could any one please suggest how to go about this?
    Regards,
    Ganesh

    Hi ganesh,
    Please have a look into the below link
    [Link1|How to Upload Excel file to Application Server]
    [Link2|Error in Downloading the Text file on Application Server]
    Hope this will be Helpful
    Thanks
    Kalyan

  • Function module to get data into internal table from Excel file sheets

    Hi,
    I have to upload customers from excel file.
    we are donloading customer data excel file sheets.
    Customer data in 1 sheet, tax data the other sheet of same excel file, Customer master-Credit data in other sheet of same excel file.
    so i have 3-4 sheet in one excel file.
    now my requirement is to get the data from excel file into internal table.
    is there any function module.
    Thanks & Regards

    I am sending you the idea with an example how you can upload data from an EXCEL file into an internal table. I am not sure if you can take data from different sheet in the same EXCEL file. I think that this is not possible (try it )
    Upload the data into an internal table, like the way that I am describing in the above:
      DATA: L_MAX_COL_NB TYPE I.
      DATA: l_file_name LIKE RLGRAP-FILENAME.
    Just to be sure that is the correct type for the FM.
      l_file_name = P_FILE_NAME.
      L_MAX_COL_NB = 58.  "Maximum nb of colums that the FM can read.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = l_file_name
                I_BEGIN_COL             = 1
                I_BEGIN_ROW             = 2
                I_END_COL               = L_MAX_COL_NB
                I_END_ROW               = 9999
           TABLES
                INTERN                  = PT_EXCEL
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
      ENDIF.
    Now you should upload the data into your own itab. The Function Module will return to you all the an itab
    from all fields and columns. Define the structure of the uploading file into SE11 - Data Dictionary. Then read the fieldcatalog of this structure. In the code that I am sending to you, I am insearting an empty line into the internal table and then I am assigning this line into a corresponding field-symbol. Then I am able to change the working area - so and the line of the itab. Propably you could you the statement APPEND INITIAL LINE TO (your_table_name) ASSIGNING <your_field_symbol>, but the example was written in an old SAP version.
      FIELD-SYMBOLS:
                     <F_REC> LIKE WA_UPLOAD_FILE,      "working are of the uploading file
                     <F_FIELD> TYPE ANY.
      DATA: COLUMN_INT TYPE I,
            C_FIELDNAME(30) TYPE C.
      PERFORM GET_FIELDCATOLG TABLES FIELDCAT
                               USING 'ZECO_CHARALAMBOUS_FILE'.
      LOOP AT PT_EXCEL.
        AT NEW ROW.
          ASSIGN WA_UPLOAD_FILE TO <F_REC>.
        ENDAT.
        COLUMN_INT = PT_EXCEL-COL.
        READ TABLE FIELDCAT INTO WA_FIELDCAT INDEX COLUMN_INT.
        CONCATENATE '<F_REC>-' WA_FIELDCAT-FIELDNAME INTO C_FIELDNAME.
        ASSIGN (C_FIELDNAME) TO <F_FIELD>.
        <F_FIELD> = PT_EXCEL-VALUE.
        AT END OF ROW.
          APPEND WA_UPLOAD_FILE TO GT_UPLOAD_FILE.
          CLEAR WA_UPLOAD_FILE.
        ENDAT.
      ENDLOOP.
    With Regards
    George
    Edited by: giorgos michaelaris on Mar 4, 2010 3:44 PM

  • Export internal table to Excel file pressing a new button created in ALV

    Hello, I am trying to implement the functionality to export to excel file inside a button that i have created into my ALV. I don't want to use FileDownload UI.
    The code I have set for event handler of this button is the following:
    METHOD attach_files .
      TYPES:
        BEGIN OF tipo_alv_tab,
          tipod    TYPE objid,
          descd   TYPE p1000-stext,
          begda   TYPE begdatum,
          endda   TYPE enddatum,
          pernr     TYPE pernr_d,
          nombre  TYPE ad_namefir,
          email     TYPE ad_smtpadr,
          posicion TYPE p1000-stext,
          uodesc   TYPE p1000-stext,
        END OF tipo_alv_tab.
      DATA:
        i_alv_tab    TYPE TABLE OF tipo_alv_tab,
        conv_out     TYPE REF TO cl_abap_conv_out_ce,
        content      TYPE xstring,
        lv_filename  TYPE string,
        xml_out      TYPE string.
    Fill values from memory
      IMPORT name1 TO i_alv_tab  FROM MEMORY ID 'ZCA'.
    Build XML file with internal table information
      CALL TRANSFORMATION ('ID') SOURCE tab = i_alv_tab[] RESULT XML xml_out.
    Build XSTRING with XML
      CALL FUNCTION 'CRM_IC_XML_STRING2XSTRING'
        EXPORTING
          instring   = xml_out
        IMPORTING
          outxstring = content.
    Format XSTRING
      conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8'  ).
    Convert data
      conv_out->convert( EXPORTING data = xml_out IMPORTING buffer = content ).
    Save file
      CALL METHOD cl_wd_runtime_services=>attach_file_to_response
        EXPORTING
          i_filename      = 'Excel File.xls'
          i_content       = content
          i_mime_type     = 'application/msexcel'
          i_in_new_window = i_in_new_window
          i_inplace       = i_inplace.
    ENDMETHOD.
    When pressing the button, the file created is without extension, and with a rare name. When trying to open the file, it seems to be corrupted.
    Does anyone know what am I doing wrong???
    Please, help is really really appreciated!!!!

    Hi Jorge,
    The export data to excel functionality is available inbuilt in ALV and you dont have to write any implementation. However, if you want to create your own button for it, you can do so as below.
    data:
    lr_button type ref to cl_salv_wd_fe_button,
    lr_function type ref to cl_salv_wd_function.
    CREATE OBJECT lr_button.
    lr_button->set_text( 'Export to excel' ).
    lr_button->set_tooltip( 'Export data to excel' ).
    lr_function = l_alv_model->if_salv_wd_function_settings~create_function( id = 'EXCEL' ).
    lr_function->set_function_std( IF_SALV_WD_C_STD_FUNCTIONS=>EXPORT_EXCEL ).
    lr_function->set_editor( lr_button ).
    Now, you have created your own button, created a user defined function for the ALV and set this button as editor for the function. And using the set_function_std method, we have just mapped the functionality of your new button to the existing export to excel functionality in ALV.
    Hope this is what you are looking for.
    Regards
    Nithya

  • How to attach an internal table as excel file in wf container.

    Hi all, I have a task that is attaching an xml file in wf container, but I need to attach as excel file, how can I convert this xml to excel ?
    my currento code is like this:
    * Call Transformation to generate XSTRING of the generated data      *
      TRY .
          CALL TRANSFORMATION ztr_wf_excel
                       SOURCE appl_stat = li_data2
                       RESULT XML pi_attach.
        CATCH cx_st_error INTO lo_exception.
          lv_text = lo_exception->get_text( ).
      ENDTRY.
      IF lv_text IS INITIAL.
        pi_header-file_type      = 'B'.
        pi_header-file_name      = 'Data'.
        pi_header-file_extension = 'XLS'.
        pi_header-language       = 'E'.
          CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
            EXPORTING
              workitem_id = lw_worklist-wi_id
              att_header  = pi_header
              att_bin     = pi_attach
              do_commit   = 'X'
            IMPORTING
              att_id      = lw_att_id.
    this code is working fine, but I need to attach an excel file instead an xml file
    How can I do that?
    Regards

    hi ,
    Follow this approach :
    You can use following funcntions. First one to create internal table to string and second FM SCMS_STRING_TO_XSTRING to convert String to XSTRING. Then this XSTRING value you can pass to CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE.
    data: tab_str type string.
      data: begin of it_tab1,
           name(20),
           age(10) ,
          end of it_tab1.
    data : lv_name type xstring.
             data it_tab like STANDARD TABLE OF it_tab1.
             data: wa like line of it_tab.
             wa-name = 'naresh'.
             wa-age = '30'.
             append wa to it_tab.
             wa-name = 'naresh1'.
             wa-age = '31'.
             append wa to it_tab.
    CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'
    IMPORTING
       TEXT                      = tab_str
      TABLES
        TEXT_TAB                  = it_tab
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
      EXPORTING
        TEXT           = tab_str
    IMPORTING
       BUFFER         = lv_name
    CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE
      EXPORTING
        I_FILENAME      = 'c:\test.txt'
        I_CONTENT       = lv_name
        I_MIME_TYPE     = 'TXT'
    Refer below links. This has been discussed many times :
    Re: download a file

  • How to save Internal table into Excel Sheet in App. Sever in Background

    How can i save my file int excel in application server in background.
    i am able to do in fronend but not in back ground.

    HI
    see this example code where i had write EXCEL to INTERNAL TABLE and then TO APPLICATION SERVER
    assign this program to background thats all
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    *   PROGRAM_NAME        = SYST-REPID
    *   DYNPRO_NUMBER       = SYST-DYNNR
    *   FIELD_NAME          = ' '
       STATIC              = 'X'
    *   MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 1
       OTHERS              = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • How to Convert an internal table into Text File

    Hello friends,
    Can you help me to find out the way to convert an internal table data into a flat file.
    the problem is that my internal table contains fields with data type INT also.

    please  go through the code and the parameter passed to the  finction module  ... since  you didn't show your coding  i am giving you the sample code  also ..
    REPORT y_ss_test_ekko .
    * To hold selection data
    DATA: i_ekko TYPE STANDARD TABLE OF ekko.
    * To hold converted text data
    DATA: i_text(4096) TYPE c OCCURS 0.
    * Selection Screen
    PARAMETERS: p_ebeln LIKE ekko-ebeln.
    * Select data into an ITAB based on the selection Criteria
    SELECT * FROM  ekko
             INTO  TABLE i_ekko
             WHERE ebeln = p_ebeln.
    * Process further only if found some data
    IF NOT i_ekko[] IS INITIAL.
    * Convert data in internal table to a delimited text data
      CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
           EXPORTING
                i_field_seperator    = '|'
           TABLES
                i_tab_sap_data       = i_ekko
           CHANGING
                i_tab_converted_data = i_text
           EXCEPTIONS
                conversion_failed    = 1
                OTHERS               = 2.
      IF sy-subrc <> 0.
        WRITE: / 'Program failed to Convert data.'.
      ELSE.
    *   Download convert data to Presentation Server
        CALL FUNCTION 'DOWNLOAD'
             TABLES
                  data_tab = i_text
             EXCEPTIONS
                  OTHERS   = 8.
        IF sy-subrc <> 0.
          WRITE: / 'Program failed to download data.'.
        ENDIF.
      ENDIF.
    ENDIF.
    reward  points  if it is  usefull   ....
    Girish

  • Spliting internal table into multiple files

    hi, i have a quick question and im new in abap.
    lets say i have an internal table gt_output and it has 10 fields and each fields are filled with weekly data.lets say i have 5 rows of data. how  do i split the column/fields so that every field can become one text file?
    thank you.

    So if you're internal table has 10 columns, you need 10 files. If you have 50 columns you need 50 files.
    a possible soultion would be:
    data: gt_string type table of string.
    data: wa_string type string.
    data: gv_file type string.
    field-symbols: <fs_field> type any.
    loop at gt_output into wa_output.
      do.
        assign component sy-index of structure wa_output to <fs_field>.
        if sy-subrc ne 0.
          exit.
        endif.
        concatenate 'c:\file_' sy-index '.txt' into gv_file.
        wa_string = <fs_field>.
        clear gt_string[].
        append wa_string to gt_string.
        call method cl_gui_frontend_services=>gui_download
          exporting
            filename                = gv_file
            append                  = 'X'
            filetype                = 'ASC'
          changing
            data_tab                = gt_string[]
          exceptions
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            no_authority            = 5
            unknown_error           = 6
            header_not_allowed      = 7
            separator_not_allowed   = 8
            filesize_not_allowed    = 9
            header_too_long         = 10
            dp_error_create         = 11
            dp_error_send           = 12
            dp_error_write          = 13
            unknown_dp_error        = 14
            access_denied           = 15
            dp_out_of_memory        = 16
            disk_full               = 17
            dp_timeout              = 18
            file_not_found          = 19
            dataprovider_exception  = 20
            control_flush_error     = 21
            not_supported_by_gui    = 22
            error_no_gui            = 23
            others                  = 24.
        if sy-subrc <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
      enddo.
    endloop.

  • Table into excel file

    i have made this programme to get my measured data in excel file(voltage at ch1,ch2 ratio ch2/ch1)only prolem left is this that i have to make different number of run for measurments but it open each time a new excel file but i want to get all run results in same one excel file without opening new one how i can do this????
    best regards
    rizwan bajwa
    Attachments:
    Ratio and voltage Read-Labview7.vi ‏175 KB

    Hi tizwan,
    as long as all those subVIs from ole-excel.llb are missing we can't tell much...
    General suggestion:
    Open the original excel file, search for the last row of results, append new results in the next row!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to download values in an internal table into an excel file

    is there any fn module to download the values in an internal table into an excel file..

    hi
    the function module "GUI_DOWNLOAD"  downloads the data from
    an internal table into a file (can be xl, dat ,doc etc) .
    Plz follow the usage below ;
    Parameters : pa_pfile LIKE rlgrap-filename OBLIGATORY.
    Data : lv_filename TYPE STRING.
    lv_filename = pa_pfile.
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
       BIN_FILESIZE                  =
         FILENAME                      = lv_filename
         FILETYPE                      = 'ASC'
       APPEND                        = ' '
        WRITE_FIELD_SEPARATOR         = 'X'
       HEADER                        = '00'
       TRUNC_TRAILING_BLANKS         = ' '
       WRITE_LF                      = 'X'
       COL_SELECT                    = ' '
       COL_SELECT_MASK               = ' '
       DAT_MODE                      = ' '
       CONFIRM_OVERWRITE             = ' '
       NO_AUTH_CHECK                 = ' '
    IMPORTING
       FILELENGTH                    =
       TABLES
         DATA_TAB                      = tb_download         " table data to b downlaoded
      EXCEPTIONS
        FILE_WRITE_ERROR              = 1
        NO_BATCH                      = 2
        GUI_REFUSE_FILETRANSFER       = 3
        INVALID_TYPE                  = 4
        NO_AUTHORITY                  = 5
        UNKNOWN_ERROR                 = 6
        HEADER_NOT_ALLOWED            = 7
        SEPARATOR_NOT_ALLOWED         = 8
        FILESIZE_NOT_ALLOWED          = 9
        HEADER_TOO_LONG               = 10
        DP_ERROR_CREATE               = 11
        DP_ERROR_SEND                 = 12
        DP_ERROR_WRITE                = 13
        UNKNOWN_DP_ERROR              = 14
        ACCESS_DENIED                 = 15
        DP_OUT_OF_MEMORY              = 16
        DISK_FULL                     = 17
        DP_TIMEOUT                    = 18
        FILE_NOT_FOUND                = 19
        DATAPROVIDER_EXCEPTION        = 20
        CONTROL_FLUSH_ERROR           = 21
        OTHERS                        = 22
    IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards
    Pankaj

  • Dowloading Internal table into pdf formate

    Hi,
      I want to know how to conert an internal table into pdf file  is there any fm avaliable for this  .
    regards,
    zafar

    try this sample code--
    tables:tsp01.
    TYPE-POOLS : vrm.
    DATA : vrm_val TYPE vrm_values,
           wa_vrm  LIKE LINE OF vrm_val,
           g_name  LIKE wa_vrm-text.
    data: w_pdf like table of tline.
    data:
      print_parameters like pri_params,
      valid_flag(1) type c,
      w_spono type tsp01-rqident.
      CLEAR wa_vrm.
      wa_vrm-key  = 'M'.
      wa_vrm-text = 'Mango'.
      APPEND wa_vrm TO vrm_val.
      CLEAR wa_vrm.
      wa_vrm-key  = 'P'.
      wa_vrm-text = 'Pineapple'.
      APPEND wa_vrm TO vrm_val.
      CLEAR wa_vrm.
      wa_vrm-key  = 'A'.
      wa_vrm-text = 'apple'.
      APPEND wa_vrm TO vrm_val.
    call function 'GET_PRINT_PARAMETERS'
    exporting
         no_dialog          = 'X'
         user               = sy-uname
    importing
       out_parameters       = print_parameters
       valid                = valid_flag
    exceptions
       invalid_print_params = 2
       others               = 4.
    if valid_flag = 'X' and sy-subrc = 0.
      new-page print on parameters print_parameters
                          no dialog.
    LOOP AT vrm_val into wa_vrm.             " your internal table
      WRITE :wa_vrm-key.
    ENDLOOP.
    LOOP AT vrm_val into wa_vrm.
      WRITE : wa_vrm-text.
    ENDLOOP.
    new-page print off.
    endif.
    w_spono = sy-spono.
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
      exporting
        src_spoolid                    = w_spono
    tables
       pdf                            = w_pdf[]
    if sy-subrc  EQ 0.
    endif.
    call function 'GUI_DOWNLOAD'
      exporting
        filename                        = 'C:\w_pdf.pdf'
       filetype                        = 'BIN'
      tables
        data_tab                        = w_pdf[]
    if sy-subrc EQ 0.
    endif.
    Sumit

Maybe you are looking for

  • IOS calendar month in week view

    How to I know what month I am in when using week view in calendar? I only see date and day of the week.

  • Error with the Scope parameter for component

    Hi, I am using JSF2.0 in my web. In the home page (index.xhtml) i have an album gallery with session scope. However the gallery is available to all the users, what should be the scope for this component? After setting session scope, a session key is

  • How can i open and edit microsoft documents in macbook pro

    how can i open and edit microsoft documents in macbook pro with retina display? I am a new user to mac book

  • Width of Report Fields

    HTML_DB Version : 1.6 In Reports, the width is being set to the max width of the data. How can I change the width of fields in Reports ? abhay

  • PKGBUILD parser in Python.

    I've wrote PKGBUILD parser in Python and thought someone else might also want to use it. Here's a little example of how it works # python Python 2.5.2 (r252:60911, Jul 8 2008, 21:21:10) [GCC 4.3.1 20080626 (prerelease)] on linux2 Type "help", "copyri