Read R/3 or BW Table into Excel

Hi Gurus,
is it possible to read a table content from R/3 or BW into Excel?
Does anyone has a piece of working code?
Regards,
Memoli

Hi Memoli,
i dont know what you really want to do with that information but there are many ays. maybe you can use the following VBA code which connects to SAP system and uses the function module "TABLE_ENTRIES_GET_VIA_RFC":
Sub retrieve_table_contents()
Dim R3, MyFunc, App As Object
Dim SEL_TAB, NAMETAB, TABENTRY, ROW As Object
Dim Result As Boolean
Dim iRow, iColumn, iStart, iStartRow As Integer
iStartRow = 4
Sheets("Tabelle1").Select
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.ClearContents
Range("A1").Select
'Create Server object and Setup the connection
Set R3 = CreateObject("SAP.Functions")
R3.Connection.System = "YOUR_SYSTEM_ID"
R3.Connection.SystemNumber = "YOUR_SYSTEM_NUMBER"
R3.Connection.ApplicationServer = "YOUR_SERVER"
R3.Connection.client = "YOUR_CLIENT_NUMBER"
R3.Connection.user = "YOUR_USER"
R3.Connection.Password = "YOUR_PASSWORD."
R3.Connection.Language = "YOUR_LANGUAGE"
If R3.Connection.logon(0, False) <> True Then
Exit Sub
End If
'Call RFC function TABLE_ENTRIES_GET_VIA_RFC
Set MyFunc = R3.Add("TABLE_ENTRIES_GET_VIA_RFC")
Dim oParam1 As Object
Dim oParam2 As Object
Dim oParam3 As Object
Dim oParam4 As Object
Set oParam1 = MyFunc.exports("LANGU")
Set oParam2 = MyFunc.exports("ONLY")
Set oParam3 = MyFunc.exports("TABNAME")
Set oParam4 = MyFunc.Tables("SEL_TAB")
oParam1.Value = "E"
oParam2.Value = ""
oParam3.Value = "TSTCT"
oParam4.Rows.Add
' oParam4.Value(1, "ZEILE") = ""
Result = MyFunc.call
If Result = True Then
Set NAMETAB = MyFunc.Tables("NAMETAB")
Set SEL_TAB = MyFunc.Tables("SEL_TAB")
Set TABENTRY = MyFunc.Tables("TABENTRY")
Else
MsgBox MyFunc.EXCEPTION
R3.Connection.LOGOFF
Exit Sub
End If
'Result = R3.TABLE_ENTRIES_GET_VIA_RFC(EXCEPTION, BELNR:="*8670", LANGU:="E", ONLY:="", NAMETAB:="COSP")
'Quit the SAP Application
R3.Connection.LOGOFF
If Result <> True Then
MsgBox (EXCEPTION)
Exit Sub
End If
'Display table header
iColumn = 1
For Each ROW In NAMETAB.Rows
Cells(iStartRow - 1, iColumn) = ROW("FIELDNAME")
' For C and N datatypes, explicitly set the cell to TEXT format, otherwise leading zeroes will be lost
' when numbers are imported from a SAP text field
If ROW("INTTYPE") = "C" Or ROW("INTTYPE") = "N" Then
Range(Cells(iStartRow - 1, iColumn), Cells(iStartRow - 1 + TABENTRY.RowCount, iColumn)).Select
Selection.NumberFormat = "@"
End If
Cells(iStartRow, iColumn) = ROW("FIELDTEXT")
iColumn = iColumn + 1
Next
Range(Cells(iStartRow - 1, 1), Cells(iStartRow, NAMETAB.RowCount)).Font.Bold = True
'Display Contents of the table
iColumn = 1
For iRow = iStartRow + 1 To TABENTRY.RowCount
For iColumn = 1 To NAMETAB.RowCount
iStart = NAMETAB(iColumn, "OFFSET") + 1
' If this is the last column, calculate the length differently than the other columns
If iColumn = NAMETAB.RowCount Then
iLength = Len(TABENTRY(iRow, "ENTRY")) - iStart
Else
iLength = NAMETAB(iColumn + 1, "OFFSET") - NAMETAB(iColumn, "OFFSET")
End If
' If the fields at the end of the record are blank, then explicitly set the value
If iStart > Len(TABENTRY(iRow, "ENTRY")) Then
Cells(iRow, iColumn) = Null
Else
Cells(iRow, iColumn) = Mid(TABENTRY(iRow, "ENTRY"), iStart, iLength)
End If
Next
Next
'Format the Columns
Range(Cells(iStartRow, 1), Cells(iStartRow + TABENTRY.RowCount, NAMETAB.RowCount)).Select
Selection.EntireColumn.AutoFit
End Sub
The most important part is this one:
'Call RFC function TABLE_ENTRIES_GET_VIA_RFC
Set MyFunc = R3.Add("TABLE_ENTRIES_GET_VIA_RFC")
Dim oParam1 As Object
Dim oParam2 As Object
Dim oParam3 As Object
Dim oParam4 As Object
Set oParam1 = MyFunc.exports("LANGU")
Set oParam2 = MyFunc.exports("ONLY")
Set oParam3 = MyFunc.exports("TABNAME")
Set oParam4 = MyFunc.Tables("SEL_TAB")
oParam1.Value = "E"
oParam2.Value = ""
oParam3.Value = "TSTCT"
oParam4.Rows.Add
' oParam4.Value(1, "ZEILE") = ""
oParam3.Value = "TSTCT" --> TABLE NAME
oParam4.Value --> Here you can make selections!!!
Regards,
Adem
PS: Maybe i cant post the coding correct in the browser as the code can be changed by the forum software. Than i can send it to your mail.

Similar Messages

  • How to read data from an internal table into a real table?

    Hello experts,
    I'm relatively new to ABAP and I'm trying to figure out how to read data from an internal table into a table that I created.  I'm trying to use the RRW3_GET_QUERY_VIEW_DATA function module to read data from a multiprovider.  I'm trying to read data from the e_cell_data and e_axis_data tables into a table that I've already created.  Please see code below.
    TABLES MULTITAB.
    DATA:
      query_name TYPE RSZCOMPID,
      s_cubename TYPE RSINFOPROV,
      t_cell_data TYPE RRWS_T_CELL,
      t_axis_data TYPE RRWS_THX_AXIS_DATA,
      t_axis_info TYPE RRWS_THX_AXIS_INFO,
      wa_t_cell_data like line of t_cell_data,
      wa_t_axis_data like line of t_axis_data,
      w_corp_tab like line of t_cell_data.
    s_cubename = 'CORP_MPO1'.
    query_name = 'Z_corp_test'.
        CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA'
           EXPORTING
             i_infoprovider           = s_cubename
             i_query                  = query_name
            i_t_parameter            = query_string_tab
           IMPORTING
             e_cell_data              = t_cell_data
             e_axis_data              = t_axis_data
             e_axis_info              = t_axis_info.
    If anyone has any information to help me, I would greatly appreciate it.  Thanks.

    Hi,
    <li>Once you call the function module RRW3_GET_QUERY_VIEW_DATA, lets say data is available in the corresponding tables e_cell_data e_axis_data which you have mentioned.
    <li>Modify your internal table defined for other purpose, with data from e_cell_data e_axis_data like below.
    LOOP AT t_cell_data INTO wa_t_cell_data.
      "Get the required data from t_cell_data.
      MOVE-CORRESPONDING wa_t_cell_data TO it_ur_tab.
      "Modify your internal table wih data
      MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
    ENDLOOP.
    LOOP AT t_axis_data INTO wa_t_axis_data.
      "Get the required data from t_cell_data.
      MOVE-CORRESPONDING wa_t_axis_data TO it_ur_tab.
      "Modify your internal table wih data
      MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
    ENDLOOP.
    Thanks
    Venkat.O

  • 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

  • Store data from a table into excel sheet and email

    Hi all,
    I am just wondering, i m not sure where to start. I want to insert data from a table into an excel spread sheet.
    I'm working on a stored procedure with 3 input parameters:
    1. the actual query
    2. userid
    3. the column headers (comma separated) - these will be in the same order as the outer select statement in the query itself. I will use the column headers for the respective columns in Excel worksheet.
    When the proc is executed, the excel is populated. If the record count is > 65536, then I need to create multiple worksheets in the same excel file.
    How can i do that? Can any body please help with this..?

    We are doing like this ( Not sure whether it is the best method available)
    --Get the output of the query (Since the number of columns is not fixed you would have to use dbms_sql package)
    --loop through the output and write into a file, for example test.csv, using UTL_FILE package
    --load the file into a blob variable(we are doing it by loading it into a table)
    --For mailing You can use the below package
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    Mailing code we are using is given below:
    CREATE OR REPLACE procedure xls_mail(
        p_sender     varchar2, -- sender, example: 'Me <[email protected]>'
        p_recipients varchar2, -- recipients, example: 'Someone <[email protected]>'
        p_subject    varchar2, -- subject
         p_text           varchar2, -- text
         p_filename      varchar2, -- name of xls file
         p_blob           blob         -- xls file
    ) is
      conn      utl_smtp.connection;
      i number;
      len number;
    BEGIN
      conn := demo_mail.begin_mail(
        sender     => p_sender,
        recipients => p_recipients,
        subject    => p_subject,
        mime_type  => demo_mail.MULTIPART_MIME_TYPE);
      demo_mail.begin_attachment(
        conn         => conn,
        mime_type    => 'application/xls',
        inline       => TRUE,
        filename     => p_filename,
        transfer_enc => 'base64');
        -- split the Base64 encoded attachment into multiple lines
       i   := 1;
       len := DBMS_LOB.getLength(p_blob);
       WHILE (i < len) LOOP
          IF(i + demo_mail.MAX_BASE64_LINE_WIDTH < len)THEN
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, demo_mail.MAX_BASE64_LINE_WIDTH, i)));
          ELSE
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, (len - i)+1,  i)));
          END IF;
          UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
          i := i + demo_mail.MAX_BASE64_LINE_WIDTH;
       END LOOP;
      demo_mail.end_attachment(conn => conn);
      demo_mail.attach_text(
        conn      => conn,
        data      => p_text,
        mime_type => 'text/html');
      demo_mail.end_mail( conn => conn );
    END;

  • Download tables into Excel or Numbers

    Is there a way to export tables from website with the columns and rows left intact?

    I saw your original post and didn't respond because I don't have any idea how to do what you want to do in any really manageable way. I imagine that's why no one else has responded ...
    I sometimes manage to do what you're looking for by copying and pasting from a web page directly into Excel, but usually not. Sometimes I paste tabular data into a text editor and then do some search-and-replace operations to get it to work as a .csv file, which you can then open with Excel. But it's time-consuming, not something most people would want to try, and still not always effective.
    Message was edited by: Rachel R

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

  • 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

  • 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 read specific fields from BW table  into ABAP?

    Hi Experts,
    Can someone help me how to use to FM: RFC_READ_TABLE to read specific fields from a BW  table '/bic/zcust_chO01' which DOESN't EXIST IN ABAP.
    I am getting an error in OPTIONS & DATA parameters.
    Any help would be higly appreciated with points.
    Thanks
    Dan

    Dan,
    FM: RFC_READ_TABLE is a RF FM so by providing BW system's RF destination you can get the values from required table.
    TRY this:
    CALL FUNCTION RFC_READ_TABLE destination <BW_RF_destination>
    Susanth.

  • Export Multiple tables into a single Excel Sheet

    We have a use case where we need to export multiple tables into an excel sheet. The exportCollectionActionListener only allows one table (which is provided in the exportedId attribute) to be exported into Excel. So is there a method provided by adf to export more that one table into excel ?

    dvohra,
    I need to export multiple tables into a single excel sheet. These links only show how to export a single table to an excel sheet.
    I have tried out this : http://iadvise.blogspot.com/2007/04/export-adf-table-to-excel.html. But i am not getting the popup to save the file. So i can't find out where the file got created.

  • Reading any value from table into a string (Especially date etc..)

    How would I read any value from a table into a string?
    Currently doing the following...
    data ret_val type string.
    select single (wa_map-qes_field) from z_qekko into ret_val
    where
    angnr = _angnr.
    When the source field is a date it bombs though.
    The result goes into a BDCDATA-fval.
    regards
    Dylan.

    Tried...
    1    DATA: lp_data TYPE REF TO DATA.
    2    FIELD-SYMBOLS: <value> TYPE ANY.
    3    CREATE DATA lp_data LIKE (wa_map-qes_field).
    4    ASSIGN lp_data->* TO <value>.
    5    SELECT SINGLE (wa_map-qes_field) FROM zquadrem_qekko INTO <value> WHERE angnr = _angnr.
    Complains that (wa_map-qes_field) is not defined in line 3.
    Think that the bracket thing is only available via SQL.
    What about CREATE DATA lp_data type ref to object. ?
    Would the above declaration work?
    regards

  • Internal table to be downloaded into excel is empty

    Hi everybody,
    I created a page where I'm displaying in a table all the records. OnInitialization, I set my RFC needed to get the data from the Prod.Server and so far is displaying fine the data when I test it.
    Now, I want to download that table into excel so I created a buttom in the Layout and in the same page OnInputProcessing I'm checking the event (IF event_id = CL_HTMLB_MANAGER=>EVENT_ID) to check if the new button was trigered. Next, I copied the solution given by Thomas in the weblogs "BSP Download to Excel in Unicode Format" but when I check my table already displayed and needed by the function 'SCMS_STRING_TO_XSTRING', now is empty.
    I set the Automatic Page Attribute for my table ON but still is empty.
    Do I have to set something else to retain or get my table OnInputProcessing?
    Thanks in advance for your quick answer.
    Juan

    Thanks everybody for your quick answers.
    You are all rights, when I set my page Stateful it solve my problem and I'm getting my table with Data.
    Now, I'm having a second problem.
    As I told you before, I only have one page where in OnInitialization I'm displaying a table, that's fine. I include a button to download the table into excel and I copied the Thomas code into the same page OnInputProcessing Event. I test it in debug mode and it's going fine thrue all the statements: executing the Funtion 'SCMS_STRING_TO_XSTRING' and executing the following statements response->set_header_field and so on..
    The problem is when getting the last statement:
    response->set_data( data = l_xstring
    length = l_len ).
    navigation->response_complete( ).
    My current page becomes blank with no dialog to download the file.
    Here is my code from OnInputProcessing event, sorry for the long message.
    CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
    DATA: WA LIKE LINE OF ZIMSLOC.
    DATA: UNRESTQ(17) TYPE C,
          KLABS(17) TYPE C.
    data: name(60) type C,
          l_string type STRING,
          l_xstring type XSTRING,
          l_len type I,
          APP_TYPE(60) type C.
    DATA: response TYPE REF TO if_http_response.
    create object response type cl_http_response exporting add_c_msg = 1.
    constants: crlf type string value cl_abap_char_utilities=>cr_lf,
               tab type string value cl_abap_char_utilities=>horizontal_tab.
    Optional: test that this is an event from HTMLB library.
    IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.
    See if download is triggered from button
      DATA: event TYPE REF TO CL_HTMLB_EVENT.
      event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
      IF event->name = 'button' AND event->event_type = 'click'.
        DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON.
        button_event ?= event.
      ENDIF.
      CASE event->id.
        WHEN 'download'.
          LOOP AT zimsloc INTO WA.
            UNRESTQ = WA-UNRESTRICTEDQ.
            KLABS = WA-KLABS.
            CONCATENATE l_string
            WA-WERKS tab
            WA-MATNR tab
            WA-CHARG tab
            WA-LICHA tab
            WA-MAKTX tab
            KLABS tab
            UNRESTQ tab
            WA-SOBKZ tab
            WA-SONUM tab
            WA-MEINS tab
            crlf
            INTO l_string SEPARATED BY SPACE.
          ENDLOOP.
          APP_TYPE = 'APPLICATION/MSEXCEL; charset=utf-16le'.
          call function 'SCMS_STRING_TO_XSTRING'
            EXPORTING
              text     = l_string
              MIMETYPE = APP_TYPE
            IMPORTING
              BUFFER   = l_xstring.
    Add the Byte Order Mark - UTF-16 Little Endian
          concatenate  cl_abap_char_utilities=>byte_order_mark_little
                       l_xstring
                       into l_xstring in byte mode.
          response->set_header_field( name = 'content-type'
          value = 'APPLICATION/MSEXCEL; charset=utf-16le' ).
    some Browsers have caching problems when loading Excel format
          response->delete_header_field( name =
          if_http_header_fields=>cache_control ).
          response->delete_header_field( name =
          if_http_header_fields=>expires ).
          response->delete_header_field( name =
          if_http_header_fields=>pragma ).
    start Excel viewer either in the Browser or as a separate window
          response->set_header_field( name = 'content-disposition' value =
    'attachment; filename=webforms.xls' ).
    finally display Excel format in Browser
          l_len = xstrlen( l_xstring ).
          response->set_data( data = l_xstring
          length = l_len ).
          navigation->response_complete( ).
        WHEN others.
      ENDCASE.
    ENDIF.
    Thanks againg for your help.
    Juan

  • Regarding downloading data into excel from internal table

    hi all ,
    i'm using the function module  SAP_CONVERT_TO_XLS_FORMAT to download data of internal table into excel . now i need to know . when user presses the button for downlading it should download after downloading if he again tries to download it in the same  should not allow him to download or  it should refresh the excel of the speecific path and then it should downlaod . please let me know how  make it.

    Hi,
    Use below FM
    call function 'MS_EXCEL_OLE_STANDARD_DAT'
    exporting
    file_name = p_file " path offile where u need to download
    CREATE_PIVOT = 0
    DATA_SHEET_NAME = ' '
    PIVOT_SHEET_NAME = ' '
    PASSWORD = ' '
    PASSWORD_OPTION = 0
    tables
    PIVOT_FIELD_TAB =
    data_tab = <dyn_table>  "internal table with data
    *fieldnames = int_head "internal table with header
    exceptions
    file_not_exist = 1
    filename_expected = 2
    communication_error = 3
    ole_object_method_error = 4
    ole_object_property_error = 5
    invalid_filename = 6
    invalid_pivot_fields = 7
    download_problem = 8
    others = 9
    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,
    Prashant

  • FM to download internal table to excel

    Hi all,
         I want to download my internal table into excel sheet. For this i am using FM
    <b>GUI_DOWNLOAD</b>. But in my internal table each record is of around <b>400</b> char. length. I think because of this the downloaded <b>content is not proper</b> i.e. in junk format. Please sugest some solution for this.
    Regards,
    Vinod.

    Hi Vinod,
    Try this program.Just copy and paste this program....
    REPORT zpck_download_to_excel .
    INCLUDE ole2incl.
    DATA: w_cell1 TYPE ole2_object,
               w_cell2 TYPE ole2_object.
    *--- Ole data Declarations
    DATA: h_excel TYPE ole2_object,      " Excel object
          h_mapl TYPE ole2_object,       " list of workbooks
          h_map TYPE ole2_object,        " workbook
          h_zl TYPE ole2_object,         " cell
          h_f TYPE ole2_object,          " font
          gs_interior TYPE ole2_object,  " Pattern
          worksheet TYPE ole2_object,
          h_cell TYPE ole2_object,
          h_cell1 TYPE ole2_object,
          range TYPE ole2_object,
          h_sheet2 TYPE ole2_object,
          h_sheet3 TYPE ole2_object,
          gs_font TYPE ole2_object,
          flg_stop(1) TYPE c.
    Internal table Declaration
    DATA : t_excel_t076m LIKE t076m OCCURS 0 WITH HEADER LINE.
    TYPES: data1(1500) TYPE c,
           ty TYPE TABLE OF data1.
    DATA: it TYPE ty WITH HEADER LINE,
          it_2 TYPE ty WITH HEADER LINE.
    DATA: rec TYPE sy-tfill,
          deli(1) TYPE c,
          l_amt(18) TYPE c.
    DATA: BEGIN OF hex,
            tab TYPE x,
          END OF hex.
    DATA: l_rc TYPE i.
    FIELD-SYMBOLS: <fs> .
    CONSTANTS cns_09(2) TYPE n VALUE 09.
    ASSIGN deli TO <fs> TYPE 'X'.
    hex-tab = cns_09.
    <fs> = hex-tab.
    DATA gv_sheet_name(20) TYPE c .
    M A C R O Declaration
    DEFINE ole_check_error.
      if &1 ne 0.
        message e002(zz) with &1.
        exit.
      endif.
    END-OF-DEFINITION.
    Fetching Data
    SELECT * FROM t076m INTO TABLE t_excel_t076m.
    LOOP AT t_excel_t076m.
      CONCATENATE
              t_excel_t076m-parart
              t_excel_t076m-konto
              t_excel_t076m-mwart
              t_excel_t076m-mwsatz
              t_excel_t076m-land1
              t_excel_t076m-mwskz
              INTO it
              SEPARATED BY deli.
      APPEND it.
      CLEAR it.
    ENDLOOP.
    IF h_excel-header = space OR h_excel-handle = -1.
    start Excel
      CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
    ENDIF.
    *--- get list of workbooks, initially empty
    CALL METHOD OF h_excel 'Workbooks' = h_mapl.
    SET PROPERTY OF h_excel 'Visible' = 1.
    add a new workbook
    CALL METHOD OF h_mapl 'Add' = h_map.
    Name of the T076
    gv_sheet_name = 'T076M'.
    GET PROPERTY OF h_excel 'ACTIVESHEET' = worksheet.
    SET PROPERTY OF worksheet 'Name' = gv_sheet_name .
    CALL METHOD cl_gui_frontend_services=>clipboard_export
      IMPORTING
        data = it[]
      CHANGING
        rc = l_rc
      EXCEPTIONS
        cntl_error = 1
        error_no_gui = 2
        OTHERS = 4.
    Get the First row and col
    CALL METHOD OF h_excel 'Cells' = w_cell1
      EXPORTING
        #1 = 1
        #2 = 1.
    Get the 255 row and col
    CALL METHOD OF h_excel 'Cells' = w_cell2
      EXPORTING
        #1 = 5000
        #2 = 6.
    Select the Data
    CALL METHOD OF h_excel 'Range' = range
      EXPORTING
        #1 = w_cell1
        #2 = w_cell2.
    CALL METHOD OF range 'Select'.
    CALL METHOD OF worksheet 'Paste'.
    *--- disconnect from Excel
    FREE OBJECT h_zl.
    FREE OBJECT h_mapl.
    FREE OBJECT h_map.
    FREE OBJECT h_excel.
    Hope it helps you.
    Reward points if helpful.
    Regards,
    Chitra.

  • Access 2010: Using VBA to xport table to Excel, then modify the excel workbook externally?

    I've got some tables in Access which I export to Excel using VBA. Once exported, I'd like to add some pivot tables, special formatting and formulas into the workbook.  Any idea how to do this?  Here are some specific tasks after the export:
    1. Insert a pivot table into a 2nd sheet.  The pivot table will have a filter field.
    2. Format the column widths in that pivot table and add some conditional cell colors
    Anybody know how to code this?   I assume I'll need to export from access then open the excel file and use excel object model from within access?
    ajw

    You can certainly import Access tables into Excel:
    http://www.erlandsendata.no/english/index.php?d=envbadacimportado
    http://www.erlandsendata.no/english/index.php?d=envbadacimportdao
    http://www.erlandsendata.no/english/index.php?d=envbadacrs2ws
    See this too.
    http://www.accessmvp.com/KDSnell/EXCEL_Export.htm#WriteRstFile
    http://www.accessmvp.com/KDSnell/EXCEL_Export.htm#ExpCopyFromRst
    That's just several similar, but slightly different, ways to do the same thing.  Once your data is in Excel, turn on the Macro Recorder and run through the steps you need to do, to get the Pivot Table the way you want it, then turn off the Macro Recorder
    and view the code.
    You will almost certainly need to make some modifications to the recorded code, because everything will be fixed (hard-coded).  Post back with additional questions, or start a new thread, to see how to make the next part(s) work.  Just get comfortable
    with the first part(s) for now.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Maybe you are looking for

  • How to send background program output to a printer

    Hi ! I created a background report,running via a job in background. I need to display the output of the background report via two channels : a printer and an e mail. I created the output of the report by using the command Write, and the output is pri

  • ECM: Off-Cycle Adjustments in 0759 or 0008?

    In Compensation Management, you have the ability to create annual or off-cycle pay adjustments.  In Personnel Admin, you can make changes to Basic Pay infotype 0008.  I am not sure how to handle off-cycle pay adjustments when the change and a specifi

  • Why are my pictures negatives

    whenever I open a 'template' the pictures show as 'negatives' or 'inverses' (color-wise) of the original photo whenever I move a photo into a template, the photo is fine in the 'browser' but when I move it into the template - it becomes a 'negative'?

  • Unicode migration via socket

    Dear all, I am converting an ECC system to unicode using the socket option. Shortly after the communication between the two server has been established and 2 jobs has been completed I can not see any procedure. And in sapinst gui I can read "RESPONSE

  • Early 2011 Macbook Pro doesn't POST

    I have an early 2011 13" Macbook Pro purchased in June 2011 that now fails to startup. The symptoms are: 1) immediately starts to power on when the charger is attached 2) white sleep comes on and is steady 3) Hard drive starts and fan comes on but no