Download content of internal table to local file

Hello SDN
I have got a BSP application using pages with flow logic. What I want to do is downloading the content of an internal table to a local file, when a user triggers a certain event. In the event-handler "OnInputProcessing" I tried to use "CALL METHOD cl_gui_frontend_services=>gui_download" but this causes an error in the browser.
Can anybody help me?
Regards
Markus
Message was edited by: Markus Tschiderer

hello markus,
cl_gui_frontend_services can only be used in sapgui-applications.
what you could do is to create a bsp-page that doesn't generate html, but only a list of data, separated by tabs and line-breaks. on the top of the bsp, you would have to set the mime-type to text/plain, so the browser will offer so save the file or open it in notepad.
regards,
norbert

Similar Messages

  • Downloading data from internal table to xls file leading zeros are not disp

    Hai abap gurus,
    when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
    Ex:
    <b>ECC Code.</b>
    045234
      88567
    098456 
    but output is giving like this:
    45234
    88567
    98456
    how to get the actual values.....
    plz help me in this matter.

    Dear Kiran,
    Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
    Then use the function module to download the content of the internal table to the excel file.
    Regards,
    Abir
    Don't forget to Reward Points  *

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

  • Download data from internal table to flat file.

    I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
    but if it is please guide me how to use this.
    is thre any other F.M. please provide the information.
    Thanks in advance

    Hi,
    Try this,
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data  
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open 
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open 
        ENDIF.
      ENDIF.
    Regards,
    Raghav

  • Upload data from Internal table to text file with  '~' separator

    can anyone help me to download data from internal table to flat file with  ''  separator. GUI_DOWNLOAD is not working in my case ....like for ''  separator

    Here it is
    REPORT  zkb_test1.
    TYPE-POOLS: truxs.
    DATA: i_scarr TYPE TABLE OF scarr,
    i_conv_data TYPE truxs_t_text_data.
    SELECT * FROM scarr INTO TABLE i_scarr.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator    = '~'
      TABLES
        i_tab_sap_data       = i_scarr
      CHANGING
        i_tab_converted_data = i_conv_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.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = 'C:\Test1.txt'
        filetype                = 'ASC'
      CHANGING
        data_tab                = i_conv_data
      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.
    Regards
    Kathirvel

  • How to download leading zeros from internal table to XL file

    Hi,
    i am dowanloading data from interna table to XL file using GUI_DOWNLOAD FM. i want download the leading zeros  also into xl file
    EX: 012345
    at present only "12345" is down loading into XL file. But i want "012345" into XL file.
    Please help me.

    Hi,
    Can you try with DBF format(Pass FILETYPE = 'DBF'? I remember that in this format data will be downloaded in database storage format. Just check and update if it works!!!
    This is what FM documentation says.
    'DBF' :
    The data is downloaded in dBase format. With this format, the data types are stored as well, For this reason, import problems can be avoided - for example, problems with Microsoft Excel. In particular, you can avoid problems with the interpretation of numeric values.
    Thanks,
    Vinod.

  • Download database table content into internal table using Function Module?

    HI,
    Experts,
    I need a function module which can download ddic table content into internal table.
    Thank u ,
    Shabeer Ahmed.

    >
    shabeer ahmed wrote:
    > HI,
    > Experts,
    >
    > I need a function module which can download ddic table content into internal table.
    >
    > Thank u ,
    > Shabeer Ahmed.
    Hi Shabeer,
      We don't require a function module to download ddic table content to an internal table. We can use the SELECT statement for the same. Example would be:-
    DATA: <INTERNAL TABLE> type table of <DATABASE>.
    SELECT * FROM <DATABASE> into corresponding fields of <INTERNAL TABLE>.
    Also, function module might be required when you need the data from a remote system, but then it is the developer's task create this function module and the function module should be remote enabled function module.
    This remote enable function module should have the above SELECT query as its code.
    Many Regards,
    Ravi.

  • 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

  • Email internal table as zip file

    Hello everyone
    I spent several days to have a full example on how to convert an internal table has ZIP file than send it by email.
    I found several example to upload file from the OS and than convert it to ZIP to save it after. But nothing from the current internal email.
    So, for the benefit of everybody who that can interrest, here is the code I did. Feel free to optimize it and post the new version here.
    ===========================================
    Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
    ==========================================
    Regards
    dstj
    Edited by: Rob Burbank on Feb 12, 2010 2:09 PM

    Hello Daniel,
    Thank you very much for this post, it is quite helpful. However, I have followed your template very closely and my file will not send. I am not an advaned ABAP programmer, but have a good knowledge of programming in general...here's a bit of my code related to this...
    *-Create table body
      LOOP AT (internal table) INTO (structure)
      (Fill lv_line with one line of string based on structure)
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            text = lv_line
          IMPORTING
            buffer = lv_xline
        CONCATENATE lv_xcontent lv_xline INTO lv_xcontent IN BYTE MODE.
      ENDLOOP.
    *-Create zip xstring
      CREATE OBJECT lo_zipper.
      CALL METHOD lo_zipper->add
        EXPORTING
          name = 'AHReport.zip'
          content = lv_xcontent.
      CALL METHOD lo_zipper->save
        RECEIVING
          zip = lv_xzipcontent.
    *-Convert zip xstring to binary
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          buffer = lv_xzipcontent
        TABLES
          binary_tab = lt_data.
    *-    Add attachment     
          TRY.
            CALL METHOD l_document->add_attachment
                EXPORTING
                  i_attachment_type = 'ZIP'
                  i_attachment_subject = 'Report'
                  i_att_content_hex = lt_data.
            CATCH cx_document_bcs.
          ENDTRY.
    Any help would be very much appreciated, ty.

  • 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

  • Convert data from internal table to XML file.

    Hi All,
    I am selecting data from database into one internal table.
    Now I want to convert data from internal table to xml file format and save in to my desktop. Please suggest me how I can achieve my requirement.
    Kindly reply me ASAP.

    Use this FM. SAP_CONVERT_TO_XML_FORMAT
    Check this link too -
    Re: Data Export in XML format
    XML files from ABAP programs

  • 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

  • Reading file content into internal table

    Hi All,
    I'm facing problem reading pdf file content into an internal table. I need to read this file from communication server (neither presentation nor application server). I have tried gui_upload , it is working fine but it does not work in batch jobs. Open dataset in binary mode is also not helping much. Could anyone help ?
    Thanks a lot

    "open dataset <filepath> for input in binary mode" should work.... what does it say when you try this?
    Thanks
    Muktar

  • How to save internal table data to file on local disk from smartforms?

    Hi there,
    I'm trying to save internal table data into .csv file on presentation server from within smartforms using GUI_DOWNLOAD function.
    This function works fine from abap program, but when I call it from smartforms it does nothing. Form prints ok and there is no file created on local dick.
    Is there a way to save smartforms internal table data to local disk?
    Thanks in advance,
    Baske

    Hi Jey,
    Thanks for your prompt replay.
    Unfortunately, Iu2019ve tried both your suggestions without success. Smartforms behaves just like in case of GUI_DOWNLOAD. There is no file saved on disk.
    Do you have any other idea?
    BR,
    Baske

  • 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

Maybe you are looking for