Saving query results to a flat file

Hello Experts!
We have a very specific issue on our current project and I would like to know if any of you have ever done something similar. We are taking query results from BW (after complex calculations, some based on SY-DATE) and saving them to flat files to transfer to a SQL database structure on the Enterprise Portal. From here, the portal team renders the information into more "static" dashboards that include mouse over features and even limited drilldown (i.e. no matter where a user clicks the report always drills down on profit center)
There are many reasons why the model is set up as such (mostly training of executive level end users), and even though it doesn't mesh with the idea that BW could do this work on its own, we have to work with what we have.
We have come up with 3 possible ways to save this data to flat files and hopefully someone can tell us which might be the most effective.
1.) Information Broadcasting. If we broadcast XML files to the portal, will the portals team be able to read that data into a SQL database? Is there another way to use broadcasting to create and send a flat file to specific location?
2.) RSCRM_BAPI. This transaction seems to not support texts.
3.) Open Hub. In order to get the open hub to work, we first have to save all of our query results to direct write data store objects using APD. (calculations based on current date, for example, would require daily full loads to the underlying data providers otherwise.)
What is the best way to accomplish this? Is information broadcasting capable of doing this?
Thanks!

Hi Adam,
Do you have to use flat files to load the information to a SQL database? (if so maybe someone else has a suggestion on which way would be the best).
I try to stay away from flat file uploads as there is a lot of manual work involved. May I suggest setting up a connection to your SQL table in the DBCON table and then writing a small abap program to push data into the SQL database (which you can automate).
1) Use APD to push data into a table within BW.
2) Go to transaction SM30 > table DBCON and setup a new entry specifying the conncection parameters to your SQL database.
3) In SE38 Write an ABAP program along the folloing lines (assuming the connection you set in DBCON is named conn1:
data: con_name like dbcon-con_name
con_name = 'conn1'.
exec sql.
  set connection :con_name
endexec.
****have a select statement which reads data from your table which the data is saved from the APD into an internal table**********
****loop on the internal table and have a SQL insert statement to insert the records into the SQL table as below******
exec sql.
insert into <SQL TABLE> (column names seperated by ,)
values (column names of the internal table seperated by ,)  if the internal table is named itab the columns have to be specified as :itab-column1
If you decide to take this approach you may find more info on DBCON and the process in sdn. Good Luck!
endexec.

Similar Messages

  • Saving query result to a file

    Hi,
    I have a sql*developer version 1.5 but i am getting a problem while saving query result to a file. When i click on "script output "-> "file icon" nothing is showing.
    Can anyboby guide me whether its a bug or some other settings are required.
    I have oracle 10.2.0.3 working on linux.
    Thanks & regards
    Girish

    I am getting the same thing and as far as I know it is a bug.
    As a workaround, you can either copy the contents of the script output or run the query as a statement (F9) instead of as a script (F5) and export the query results from the results tab.

  • Query extraction to a flat file

    We have a requirement to extract the query result and send it as a flat file to a different system. The query is created on a multi provider and the key figures have lot of restrictions. We currently use RSCRM_BAPI for this. Would like to know if there is a better options, if any one has used it.
    Thanks,
    VJ Sudharsan

    Hi,
    It might help you:
    Program to run query and save to flat file
    Best regards,
    Eugene

  • Automate a report execution & save results as a flat file on FTP server

    Hello Gurus
    I am working on BW 3.5 version. I want to Automate a report execution, and save the results of the same as a flat file on a FTP server.---- (So that another program could look it up and run few processes at it's end). pls give me solution in step-by-step format. Plss help.....

    Hi Priyadarshini,
    You can Automate a Report Execution and Save the results as a flat file by creating a Query Extract and by scheduling  the Query Extractor using the T-Code RSCRM_BAPI.
    Steps:
    1. Goto RSCRM_BAPI T-Code
    2. Select the Quey from the list
    3. Click on Query Extract
    4. Create a Query Extractor and give the file name and Path.
    5. Schedule the Query Extractor.
    Hope it helps.
    Regards,
    -Vijay

  • How to output a query results into a text file

    How to output a query results into a text file instead of outputing it to the screen..
    is there a way for us to write a SQL query which specifies to output the query results to a text file.
    Pls let me know how to do it
    Thanking u in advance
    regards
    Muraly

    Muraly,
    If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
    SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
    SPOOL c:\temp\report.html
    SELECT DEPARTMENT_NAME, CITY
    FROM EMP_DETAILS_VIEW
    WHERE SALARY>12000;
    SPOOL OFF
    SET MARKUP HTML ENTMAP OFF
    In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
    Alison

  • Display the query result in an Excel file??

    hi there..
    am writing one script file that queries my DB and display the query result in an Excel file??
    i.e: if my query is :
    select col1, col2
    from table;
    and i want the results to dispalys in 2 col. in an Excel spreadsheet..
    Appreaciating ur cooperation..
    Mourad

    set colsep to a delimiter that is not normally part of your data like |
    also setup the environment with these other setup commands
    Set Echo Off;
    Set Concat Off;
    Set Pagesize 9999;
    Set Feedback Off;
    Set Verify Off;
    Set Term Off;
    Set Space 0;
    Set Colsep '|'
    Set Underline Off;
    If you wanted to use a comma delimiter the setup would be same but the set colsep='","'
    with the addition of concatenating a " on the first col and last col of the query
    eg.
    -- if first col and last_col are character types then
    SELECT '"'||col1,....,last_col||'"'
    FROM table;
    Otherwise if either is a number they would have to be converted with a TO_CHAR

  • Saving query results to text file

    Hi experts,
    I would like to save a query results to text file.
    The query has desined to the correct structure and I wish the query results will be saved automaticly to text file every time the query is running.
    The query should cintain some sql code that will save the query to text file instead of show the query results.
    What function of SQL should I add to query to achieve that goal. (The query is a long one).
    Thanks in advance,
    Joseph

    If you are talking about Query Manager, it is not difficult to do.  No matter how long your query coding is, just go to the start point of your query.  Then press CtrlShiftEnd to select all the TEXTs.  CtrlC and CtrlV will copy the text (query codes) to text file easily.
    Thanks,
    Gordon

  • URGENT How to map an aggregated result to Target flat-file?**

    All,
    I am trying to map the result of the following query from 'source1' to my target which is a flat file.
    The query result set has 'one row per account' which is unique and record looks like :
    12300,9675,2008,6,11250,$-2095.48
    Questions>>>
    1. what is the proper context ( at what level-- project, global?) should I create the $v_year, $v_period variables.?
    I need the values for this 2 variables to be recognized at the end once I 'package' the mapping
    so user can pass on the values at runtime.
    2. Can this query somehow to be plugged as a 'filter' on top of the 'source1' in the interface? and result then mapped to the target?
    what is the alternative if not? (dump it to another temp table? in SUNOPSIS memory engine?)
    SELECT
    PS_.product,
    PS_.operating_unit,
    $V_YEAR,
    $V_PERIOD,
    PS_.account,
    SUM(PS_.posted_total_amt) TOT_AMT
    FROM psoftdb.ps_ledger PS_
    WHERE
    ((PS_.ledger='ACTUALS')
    AND (PS_.accounting_period <=$V_PERIOD)
    AND (PS_.fiscal_year=$V_YEAR)
    AND ((SUBSTR(PS_.account,1,1)='1' OR
    SUBSTR(PS_.account,1,1)='2' OR
    SUBSTR(PS_.account,1,1)='3')
    GROUP BY
    PS_.product,
    PS_.operating_unit,
    PS_.account

    IN order to do this you will need to declare two variables - at project level, with non-persistent type. You will need to have reverse engineered the source table into a data model. You should also define your flat file as a data model too. If this does not already exist, you will need to manually define it.
    Create a package in which the first steps are to declare the variables.
    then insert an interface which uses your source table as a source and your flat file as a target.
    In the interface select "Staging area different from target" and select the schema of your source from the drop-down.
    In your source, drag all the columns on which you want to filter (including accounting_period and fiscal_year) on to the grey background and fill in the filter details. Use the expression editor to set the filter, selecting the variable from the list, which ensures the correct syntax is used.
    Fill in all the other mapping details.
    On the flow tab select the IKM SQL to File Append as your IKM. This should allow you to create your output in one step.
    Build a scenario from your package, and when you execute it pass in the variables:
    e.g. startscen MYSCEN MYCONTEXT 001 "-MYPROJ.V_YEAR=1999" "-MYPROJ.V_PERIOD=07"

  • How to upload the web query result  to CSV/Text file

    Hi,
    Kindly help me on the following.
    1)       I have info-provider (IP), which has info-objects "company code" and "supplier".
    2)       I built a query by putting company-code with a variable in free-charateristics and supplier-code in row.
    3)       When I run this query, it will ask company-code as input and the result will be filtered using company-code.
    4)       For this query, I created a web-template and assigned data-provider to display the data on the web.
    5)       The user wants to enter input company-code='1000' and write the data in a CSV file in a specific directory. i.e, by clicking the execute button (after entering company code) , the result should go to the CSV or text file. i.e. the application should automatically generate the file with query results.
    Note: The user should not use context menu to EXPORT TO CSV OR EXCEL file.
    Please let me know, if there is any tutorial. Thanks a lot advance help.
    Regards
    Kandasamy

    1. SELECT INTO
    Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
    Use AdventureWorks2008R2;
    Go
    ---Insert data using SELECT INTO
    SELECT AddressLine1, City
    INTO BothellAddresses
    FROM Person.Address
    where City = 'Bothell';
    GO
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    2. INSERT INTO SELECT
    Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
    another table.
    Use AdventureWorks2008R2;
    Go
    ---Create Table
    CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
    ---Insert into above table using SELECT
    INSERT INTO BothellAddresses(AddressLine1, City)
    SELECT AddressLine1, City
    FROM Person.Address
    where City = 'Bothell';
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    Regards,
    Vishal Patel
    Blog: http://vspatel.co.uk
    Site: http://lehrity.com

  • Exporting query result set into CSV file using Forms

    Hi ,
    My requirement is
    -> I need to create a form where I have a Multi line text box and two button.
    -> When I enter a query in text box and click on Execute button, It should execute a select query.
    -> After execution, Result set needs to be exported into an Excel file.
    Please give a hint how to do this????
    Thanks,
    maddy

    as you are using text item to write SQL query by the user
    so for that you need to use the exec_sql package to parse the text items query and get definitions and values of the columns being
    resulted in the result set of the query.
    once your query is execute to the desired connection then you need to use fetch the result to the CSV file by use of the TEXT_io package
    which will open the text file with .csv extension and you have to pass the each line to that text file with comma separated values as "ss","rr" etc.
    or you can use the ole2 package to call the excel application and then fetch the data of exe_sql query to that.

  • Sending query results to an excel file

    hai friends,
    Can any one help me out in sending the results of a query to an excel file once i press a button on my jsp.
    I need to display the results of the query and has to send those results to the excel file.
    Thanks and regards,
    ravikiran

    The solution is simple and the trick lies in setting the Content Type of the response and producing the output.
    If we remember, while coding in servlets, one needs to set the content type on the response object. For outputting in Excel format, the content type has to be set as "application/vnd.ms-excel"
    Once this is done, the servlet knows that it has to produce the output in MS Excel Sheet.
    You can query the databsae and loop over your record set and output it in any manner you like.
    eg
    <!-- Printing the Row Headers-->
    out.println("Header1 \t Header 2 \t Header3");
    <!-- printing the actual values from database-->
    while(rs.next()){
    out.println(rs.getString(1) + "\t" + rs.getString(2) + "\t" + rs.getString(3));
    Hopefully this will work for all of you.
    Thanks

  • Saving query results as excel

    hi,
    Is there a way to save the query results as excel programatically (some kind of utility which does the job)? we are using oracle 10g. This will be a nightly job.. so that every other day morning we have the huge excel report ready for viewing. Any help is appreciated..

    Did you think to try searching the forum? I typed in the EXACT string you used for your thread title and the first hit was ...
    Saving sql query result as excel file

  • Need SQL Query which saves query results to an excel file

    Hi,
    I am looking for a sql query which saves/ export results of an query to a excel file
    Thanks,
    Chetan

    I am looking for a sql query which saves/ export results of an query to a excel file
    Thanks,
    Chetan
    Options:
    1) You can use
    BCP command to export result to excel
    2) Insert into excel by using OPENROWSET
    3) Use Import and Export Wizard and provide SQL query as source and Excel as destination
    Please refer:
    http://stackoverflow.com/questions/87735/how-do-you-transfer-or-export-sql-server-2005-data-to-excel
    http://www.codeproject.com/Questions/617527/Export-sql-query-result-in-excel-file
    Cheers,
    Vaibhav Chaudhari
    [MCTS],
    [MCP]

  • How can I export the query result into access(*.mdb) file?

    Dear all:
    I want to export the query result displayed in jsp into excel file
    and access file. And I have exported the result into excel format successfully, only one line should be added in the head of Jsp:
    <%@ page contentType="application/vnd.ms-excel; charset=gb2312" %>
    But how can I export it in access(*.mdb) file? I have replaced "excel"
    with "access". But it can't achive my goal.
    What should I do to achieve my goal?
    Thanks!

    The only reason your Excel export works is that Excel knows how to interpret comma separated values as an input file format. Access has no such beast.
    If you absolutely must provide info in an mdb, one solution would be to create an ODBC datasource pointing to an empty mdb, then push data into it using the jdbc:odbc bridge, then make a copy of the file and stream it down to the browser. You may run into some ugly file locking items here - set the ODBC connection so it is not shared, and that might help.
    This one is going to be ugly.
    I suppose another approach would be to write a simple VB applicatin that uses automation to create an MDB, then stream that file down to the browser from your servlet. That would almost certainly be faster than the ODBC approach.
    - K

  • Saving database records in a flat file

    I am trying to save data from relational database into a flat file and then read back records based on the certain criteria.
    What will be a good approach for me? Should I use random access files or sequential files for storing and
    retrieving data or is there some other technique that is more efficient that I can use.
    Thanks

    I don't think that reading database records from a flat file based on certain criteria is a good approach, no matter how you produce the flat file. Using a second database table makes more sense to me, especially since you already have database software available and ready for use.
    (You asked about a "good approach" and then you wanted a technique that was "more efficient". Those two aren't the same thing at all.)

Maybe you are looking for