Query SAP Database with Native Sql.

Hi,
I would like to query the table MARA with native sql and return all headings and data
Select * from MARA where MATNR = '00000000151515'          
<i>I need this to be able to TEST my Sql statements.</i>
In SqlServer you have the Query Analyser where I can do just this, but is there some nice in SAP Tool for this as well ?
[Unfortanely I can't connect to SAP_U01 database from QA...]
//Martin

Hi Martin,
maybe you give ST05 a try: last button gives the possibility to enter a SQL-statement directly - and for explanation it has to be executed (somehow).
Regards,
Christian

Similar Messages

  • Performance for join 9 custom table with native SQL ?

    Hi Expert,
    I need your opinion regarding performance to join 9 tables with native sql. Recently i have to tunning some customize extraction cost  report. This report extract about 10 million cost of material everyday.
    The current program actually, try to populate the condition data and insert into customize table and join all the table to get data using native sql.
    SELECT /*+ ordered use_hash(mst,pg,rg,ps,rs,dpg,drg,dps,drs) */
                mst.werks, ....................................
    FROM
                sapsr3.zab_info mst,
                sapsr3.zab_pc pg,
                sapsr3.zab_rc rg,
                sapsr3.zab_pc ps,
                sapsr3.zab_rc rs,
                sapsr3.zab_g_pc dpg,
                sapsr3.zab_g_rc drg,
                sapsr3.zab_s_pc dps,
                sapsr3.zab_s_rc drs
            WHERE mst.zseq_no = :p_rep_run_id
            AND mst.werks = :p_werks
            AND mst.mandt = rg.mandt(+)
            AND mst.ekorg = rg.ekorg(+)
            AND mst.lifnr = rg.lifnr(+)
            AND mst.matnr = rg.matnr(+)
            ...............................................   unitl all table (9 tables)
            AND ps.mandt = dps.mandt(+)
            AND ps.knumh = dps.knumh(+)
            AND ps.zseq_no = dps.zseq_no(+)
            AND COALESCE (dps.kbetr, drs.kbetr, dpg.kbetr, drg.kbetr) <> 0
    It seems the query ask for database to using hashed table. would that be it will burden the database ? and impacted to others sap process ?
    Please advise
    Thank You and Best Regards

    you can only argue coming from measurements and that is not the case.
    Coming from the code, I see only that you do not understand it at all, so better leave it as it is. It is not a hash table, but a hash join on these table.

  • Mapping Problem with Native SQL query

    My application uses a native SQL query to locate certain entities. It looks like this:
    SELECT UPLOADATTEMPTREF, STUDENTNUMBER, USERID, WORKITEMCODE, WORKITEMINSTURN, WORKITEMTITLE, MODULERUNCODE, STUDENTNAME, SUBMISSIONDEADLINE, UPLOADATTEMPTSERVERDATE, FILENAME, UPLOADCOMPLETESERVERDATE, NEWFILENAME, FILESIZE, FILEPATH, DOWNLOADSERVERDATE, MODULECODE, MODULETITLE
    FROM Submission_Attempt WHERE UPLOADATTEMPTREF IN (
    SELECT uploadAttemptRef FROM (" +<br /><br />                         "SELECT MAX(uploadAttemptRef) AS uploadAttemptRef, UserID, workItemInstUrn, " +<br /><br />                         "workItemCode FROM Submission_Attempt where workiteminsturn = ?1 " +<br /><br />                         "GROUP BY UserID, workItemInstUrn, workItemCode) Table1 ) " +<br /><br />                         "and uploadCompleteServerDate is not null;"<br />
    My expectation was that EclipseLink would be able to handle the mapping of the results to the entity quite happily. However, I get a NonSynchronizedVector of Objects - each Object representing one field of data.
    I need help with either:
    Converting the above SQL into JPQL so that I (hopefully) don't have to worry about the SQL or
    Understanding why this isn't working properly...
    Anyone able to help?
    Edited by: phunnimonkey on Nov 6, 2008 3:33 AM

    Never mind - the problem was to do with not specifying a class when creating the native query.

  • Fetch join with Native SQL Query?

    Hello all,
    I am using the J2EE 5.0 persistence api with the SUN appserver v9. As the java persistence api does not yet support spatial queries ("... where contains(polygon, point)") I have to use native SQL queries for that purpose.
    Now my question is how can I "join fetch" my ManyToOne-related entities when using a native SQL query? Is this somehow possible using the SqlResultSetMapping annotation?

    Never mind - the problem was to do with not specifying a class when creating the native query.

  • How do I join with native SQL?

    I'm just starting to dip my toes in Toplink/Eclipselink using jDeveloper 11g. I've got a database schema that looks like this:
    Organization > Site > Program / MhProgram
    Every program and MhProgram has a site_id, and every site has an organization_id.
    The POJO objects wizards seems to have set the relationships up correctly and I'm able to pull out Organization objects that have siteCollections and the sites have programCollections and MhProgramCollections. The part where I'm having trouble is pulling out organizations the way I'd like to.
    I'm querying them with this SQL:
    select o.*
    from organization o,
    site s,
    program p
    where o.organization_id = s.organization_id
    and s.site_id = p.site_id
    and s.site_number = 1
    and p.program_name = "Test Name"
    The problem seems to be that Toplink isn't actually recognizing that I want to do these joins. Its grabbing an organization and then doing SQL to separately get each site, then each program. During this process SQL like s.site_number = 1 is ignored. This leaves me with siteCollections and programCollections that are just raw unfiltered rows. I've tried the same with JPQL and I'm having no luck there either.
    Am I missing something with the Native SQL support?
    Edited by: user519677 on May 5, 2009 5:32 AM

    The code is below. Its just a test client until I can get it working. When I put the word FETCH beside the INNER JOIN in the JPQL I get the following exception:
    Exception Description: Syntax error parsing the query [select o from Organization o INNER JOIN FETCH o.siteCollection s where s.siteNumber = 1 ], line 1, column 63: syntax error at [s].
    Internal Exception: MismatchedTokenException(66!=-1)
    Code:
    Project project = XMLProjectReader.read("META-INF/tlMap.xml", Thread.currentThread().getContextClassLoader());
    DatabaseSession session = project.createDatabaseSession();
    session.shouldLogMessages();
    session.login();
    session.setLogLevel(org.eclipse.persistence.logging.SessionLog.FINE);
    ReadAllQuery query = new ReadAllQuery(Organization.class);
    String EJBQuery = "select o from Organization o " +
    "INNER JOIN o.siteCollection s " +
    "where s.siteNumber = 1 ";
    query.setEJBQLString(EJBQuery);
    Collection<Organization> results = (Collection<Organization>) session.executeQuery(query);
    Edited by: user519677 on May 5, 2009 6:31 AM

  • JDBC Receiver Adapter with Native SQL String

    Hi experts
    I need to use a JDBC Receiver Adapter with Message Protocol of Native SQL String, but I don´t understand how to create my data type for XML Document Format. I studied the following example from the SAP Library,
    INSERT INTO tableName (column-name1, column-name2, column-name3) VALUES(u2018column-value1u2019, u2018column-value2u2019, u2018column-value3u2019)
    i´ll be very thankful of your recommendations.

    Another simple way is..
    Create receiver data structure like this....
    <StatementName>
    <anyName action=u201DSQL_DMLu201D>
    <access>INSERT INTO tableName (column-name1, column-name2, column-name3) VALUES('$column-value1$', '$column-value2$', '$column-value3$')
    </access>
    <key>
      <column-value1>value1</column-value1>
      <column-value2>value2<column-value2>
       <column-value3>value3<column-value3>
    </key>
    </anyName > 
    </StatementName>
    Rest are all same.

  • DMS Storage in SAP Database with Kpro.

    Hello SAP Gurus,
    we are using the ECC 6.0 client and still have not configured any content servers for storing the originals,
    but i could make use of Kpro Tick in Document type and attach n no of file to DIR,
    also i have tried using KPRO tick and also making the file Size as 00000,
    but its working and allowing me to store originals in DMS_C1_S1 content repository.
    But when i dont give Kpro tick in document type, then original is not checked in using KPRO, (but again it is also storing original in SAP Database), then it is at this point it is required to give the file size or else it is giving the error,  what is the reason for this strange behavior,
    as in both the case the document is getting stored in SAP database only.
    as content repository DMS_C1_S1 is again using SAP Data Base itself. (Verify from OACT transaction.)
    Please clarify,
    Points awaiting.
    regards
    Priya

    Dear friends thanks for your reply,
    as i have detailed in my quiry,
    i could see  if we use Kpro we can attach more than 2 originals in a DIR, and also get the advantages of Kpro,
    and if i dont give Kpro tick only 2 originals can be attached in the original.
    but in both the cases the original is being stored in the SAP Database only.(in my case as content server is not yet installed)
    i want to know as the original files if stored in SAP DMS either with Kpro or with out Kpro, can this original files stored be copied in to external storage device say CDs and opened with out SAP logon. (like opening the files in normal windows system)
    thanks and regards,
    Priya
    Edited by: Priya S on Feb 19, 2009 11:46 AM

  • Query distributed database with different character sets.

    Hello experts, this is my situation:
    I have two databases A and B, the same version 11.1.0.7, the same OS Suse Linux Enterprise 10 but with different character sets, A has WE8MSWIN1252 while B has AL32UTF8. The database B is my XML DB repository so there I have some XML type tables. I need to query this tables from the database A using a dblink and in fact I have done that but the XML content is trasformed due to the different character sets between the databases. Some time there are data loss and some time there are data missmatch.
    Is there any way to query the tables stored in the database B without problems? I do not know if the following is correct: Maybe I can set the character set for the session in the database A during the time it query the database B. That is, change the character set in fly at session level.
    Do you have any special suggestion?
    I hope you can help me, thank you in advance.

    The Globalization Support Guide for 11.1.0.7 has a chapter on character set migration that should be helpful. AL32UTF8 is a superset of WE8MSWIN1252 but it is not a strict superset. That is, it doesn't meet the second prong of the test in the documentation
    The new character set is a strict superset of the current character set if:
    Each and every character in the current character set is available in the new character set.
    Each and every character in the current character set has the same code point value in the new character set. For example, many character sets are strict supersets of US7ASCII.Exporting the data from the A, changing the character set (or creating a new database with the AL32UTF8 character set), and then importing the data may be the easiest approach in your case.
    Justin
    Edited by: Justin Cave on Jan 13, 2011 12:08 PM

  • Problem with native SQL cursor in generic data source

    Hi, All!
    I am implementing generic data source based on FM.
    Because of complicated SQL I canu2019t use Open SQL and RSAX_BIW_GET_DATA_SIMPLE-example u201Cas isu201D.
    So, I have to use Native SQL. But Iu2019ve got a problem with a cursor. When I test my data source in RSA3, everything is Ok. But, if I start appropriate info-package, I get error u201CABAP/4 processor: DBIF_DSQL2_INVALID_CURSORu201D. It happens after selecting of 1st data package in line u201CFETCH NEXT S1 INTOu2026u201D. It seems to me that when system performs the second call of my FM the opened cursor has already been disappeared.
    Did anyone do things like this and what is incorrect?
    Is it real to make generic data source based on FM with using Native SQL open, fetch, closeu2026

    Hi Jason,
    I don't think this SQL is very valuable It is just an aggregation with some custom rules. This aggregation is performing on info-provider which consists of two info-cubes. Here we have about 2 billion records in info-provider and about 30 million records in custom db-table Z_TMP (certainly, it has indexes). I have to do this operation on 21 info-providers like this and I have to do this 20 times for each info-provider (with different values of host-variable p_GROUP)
    SELECT T.T1, SUM( T.T2 ), SUM( T.T3 ), SUM( T.T4 )
            FROM (
                    SELECT F."KEY_EVENT06088" AS T1,
                            F."/BIC/EV_COST" + F."/BIC/EV_A_COST" AS T2,
                            DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_COST") +
                              DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_A_COST") AS T3,
                            DECODE( D.SID_EVENTTYPE, 23147, F."/BIC/EV_DURAT",
                                                          23148, F."/BIC/EV_DURAT",
                                                          23151, F."/BIC/EV_DURAT",
                                                          23153, F."/BIC/EV_DURAT",
                                                          23157, F."/BIC/EV_DURAT",
                                                          23159, F."/BIC/EV_DURAT",
                                                          24896734, F."/BIC/EV_DURAT",
                                                          695032768, F."/BIC/EV_DURAT",
                                                          695029006, F."/BIC/EV_DURAT",
                                                          695029007, F."/BIC/EV_DURAT",
                                                          695036746, F."/BIC/EV_DURAT", 0) AS T4
                      FROM "/BIC/VEVENT0608F" F,
                           Z_TMP G,
                           "/BIC/DEVENT06085" D
                      WHERE F."KEY_EVENT06088" = G.ID
                            AND F."KEY_EVENT06085" = D.DIMID
                            AND G.GROUP_NO = :p_GROUP
                            AND ( F."/BIC/EV_COST" < 0 OR F."/BIC/EV_A_COST" < 0 )
                            AND D.SID_EVENTTYPE <> 695030676 AND D.SID_EVENTTYPE <> 695030678
                    UNION
                    SELECT F."KEY_EVNA06088" AS T1,
                            F."/BIC/EV_COST" + F."/BIC/EV_A_COST" AS T2,
                            DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_COST") +
                              DECODE( D.SID_EVENTTYPE, 23147, 0,
                                                          23148, 0,
                                                          23151, 0,
                                                          23153, 0,
                                                          23157, 0,
                                                          23159, 0,
                                                          24896734, 0,
                                                          695032768, 0,
                                                          695029006, 0,
                                                          695029007, 0,
                                                          695036746, 0, F."/BIC/EV_A_COST") AS T3,
                            DECODE( D.SID_EVENTTYPE, 23147, F."/BIC/EV_DURAT",
                                                          23148, F."/BIC/EV_DURAT",
                                                          23151, F."/BIC/EV_DURAT",
                                                          23153, F."/BIC/EV_DURAT",
                                                          23157, F."/BIC/EV_DURAT",
                                                          23159, F."/BIC/EV_DURAT",
                                                          24896734, F."/BIC/EV_DURAT",
                                                          695032768, F."/BIC/EV_DURAT",
                                                          695029006, F."/BIC/EV_DURAT",
                                                          695029007, F."/BIC/EV_DURAT",
                                                          695036746, F."/BIC/EV_DURAT", 0) AS T4
                    FROM "/BIC/VEVNA0608F" F,
                         Z_TMP G,
                         "/BIC/DEVNA06085" D
                    WHERE F."KEY_EVNA06088" = G.ID
                          AND F."KEY_EVNA06085" = D.DIMID
                          AND G.GROUP_NO = :p_GROUP
                          AND ( F."/BIC/EV_COST" < 0 OR F."/BIC/EV_A_COST" < 0 )
                          AND D.SID_EVENTTYPE <> 695030676 AND D.SID_EVENTTYPE <> 695030678
                 ) T
            GROUP BY T.T1

  • Querying SAP Database

    I seen in some sites that we can query the SAP database using doQuery()..
    If i use the tablename eg.OCRD used by SAP for my application.. Is there any chance of changing the table name in SAP..
    If anybody having exposure in SAP SDK please give me some ideas about that

    Following code works for me (in VB):
            Dim rs As SAPbobsCOM.Recordset
            Dim query As String
            Try
                query = "SELECT * FROM OCRD"
                rs = oCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                rs.DoQuery(query)
                Console.WriteLine("aantal regels ", rs.RecordCount)
                If rs.RecordCount > 0 Then
                    Dim file As String = "c:\temp\bp.xml"
                    Console.WriteLine("file: ", file)
                    rs.SaveXML(file)
                End If
            Catch e As Exception
                Dim message As String = _
                    e.[GetType].ToString + ":" + vbCrLf + _
                    e.Message + vbCrLf + _
                    e.StackTrace
                Console.Error.WriteLine(message)
                MsgBox(message, MsgBoxStyle.Critical)
            End Try
    Regards,
    Jacco.

  • Problem with Native SQL DB connection.

    Hi Gurus,
    Depending on the value of a  parameter (a or b)
    I create 2 connections.
    In both the cases connection is made as follows.
    EXEC SQL.
    CONNECT TO :CONNECTIONNAME AS :SY-UNAME.
    ENDEXEC.
    (Where connection name is different in both the cases & accessing DB table is also different).
    Now it gives me following dump when both the cases are executed one by one.
    EXSQL_ILLEGAL_CONNECTION
    How to avoid this dump ?
    Thanks in Advance,
    deepanadhi.

    You can't use SY-UNAME in the Native Sql, So give the DB connection name

  • Search for tablenames in the database using native sql query script

    How do i search for the names of the tables in the database using select statement? I do not know the names of the tables but I know the name of the database and i do not have the sys priviliges.
    thanks
    SS

    SELECT owner, table_name
    FROM all_tables;

  • RPD - Cannot obtain number of columns for the query result :Working with MS SQL 2012 schema

    Hi All,
    I have created my warehouse in MS SQL 2012.
    For management purpose, I have created different schemas in SQL database
    In RPD, Physical layer, when i view data > I get error as
    [nQSError:16002] Cannot obtain number of columns for the query result.
    [nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid object name 'tbl'..
    [nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Statements could not be prepared..
    I have already browsed : OBIEE 11g Strange ODBC Driver Error with SQL Server : Total Business Intelligence ... did not help me
    please help!!!

    Hi All,
    After all R&D it is been found that Oracle business administrator( RPD) needs default dbo schema. It doesn't accept custom schema for pulling data.
    If anybody have other views please share.!!
    Thank you

  • Use a variable as a table name with NATIVE SQL

    Hi all,
    I am trying to execute a SELECT statement in order to fetch data from an external Oracle DB table to SAP with the following instructions:
    EXEC SQL.
      SELECT cityfrom, cityto
             INTO STRUCTURE :wa
             FROM spfli
             WHERE mandt  = :sy-mandt AND
                   carrid = :p_carrid AND connid = :p_connid
    ENDEXEC.
    However, I need to indicate the external table name from a variable instead of the solution above. That is, declaring a variable and store the name of the table (e.q. spfli) in it. The resulting ABAP code would be something like:
    EXEC SQL.
      SELECT cityfrom, cityto
             INTO STRUCTURE :wa
             FROM <VARIABLE>
             WHERE mandt  = :sy-mandt AND
                   carrid = :p_carrid AND connid = :p_connid
    ENDEXEC.
    Does anybody know if is possible to do that?
    If not, is there any other solution?
    Thank you in advance

    Yes, as Suhas said, you could use the ADBC API and his class CL_SQL_CONNECTION to achieve this...
    Here is a small example:
    PARAMETERS: p_carrid TYPE spfli-carrid,
                               p_connid TYPE spfli-connid.
    DATA:
      l_con_ref      TYPE REF TO cl_sql_connection,
      l_stmt         TYPE string,
      l_stmt_ref     TYPE REF TO cl_sql_statement,
      l_dref         TYPE REF TO data,
      l_res_ref      TYPE REF TO cl_sql_result_set,
      l_col1         TYPE spfli-carrid,
      l_col2         TYPE spfli-connid,
      l_wa           TYPE spfli.
    CONSTANTS:
      c_tabname  TYPE string VALUE 'SPFLI'.
    * Create the connecction object
    CREATE OBJECT l_con_ref.
    * Create the SQL statement object
    CONCATENATE 'select * from' c_tabname 'where carrid = ? and connid = ?'
           INTO l_stmt SEPARATED BY space.                           "#EC NOTEXT
    l_stmt_ref = l_con_ref->create_statement( ).
    * Bind input variables
    GET REFERENCE OF l_col1 INTO l_dref.
    l_stmt_ref->set_param( l_dref ).
    GET REFERENCE OF l_col2 INTO l_dref.
    l_stmt_ref->set_param( l_dref ).
    * Set the input value and execute the query
    l_col1 = p_carrid.
    l_col2 = p_connid.
    l_res_ref = l_stmt_ref->execute_query( l_stmt ).
    * Set output structure
    GET REFERENCE OF l_wa INTO l_dref.
    l_res_ref->set_param_struct( l_dref ).
    * Show result
    WHILE l_res_ref->next( ) > 0.
      WRITE: / 'Result:', l_wa-carrid, l_wa-connid.
    ENDWHILE.
    * Close the result set object
    l_res_ref->close( ).
    Otherwise you can also use the FM DB_EXECUTE_SQL...
    Kr,
    m.

  • Querying Multiple databases on Azure SQL

    Does anybody know if there is a way to query multiple Azure sql databases in a query?
    I have tested the query on a standard sql server I have setup here and that works fine.
    I believe Azure does not support cross database queries and you have to do an elastic database query.  Any ideas how this works?
    This topic first appeared in the Spiceworks Community

    Hello. We currently have a database cluster that has a WSUS database on it.  We wanted to setup another WSUS server in our environment, is this possible?  I have read some posts saying that there was a 1 to 1 for WSUS DB to SQL Instance
    but those were from 2008 and 2011 and I am wondering if it is possible today.  If not, what would be the recommendation?  Another SQL Instance or just use the Windows Internal Database. 
    There is still a limitation of 1 WSUS to 1 SQL Instance, because the database name is hardcoded to SUSDB. To use multiple WSUS servers on that same cluster will require the installation of an additional instance.
    If that additional server is destined to be a downstream server, though, I would recommend just using the native Windows Internal Database on the local system.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

Maybe you are looking for

  • How can I create a data connection without ODBC (directly with OLE DB)

    If connecting to an OLE DB data source, which is not defined as ODBC, the well known error message appears in Acrobat, that the environment is not trusted. The Designer Help says, that the document must be certified in Acrobat to run OLE DB without O

  • Accordion on SharePoint's td element

    I'm trying to use Accordion on my SharePoint project and I have this CEWP using JavaScript that creates a header placed under <td> element (see attached) class name "sectionHeader" the problem is its not working. Do we have some work around so I can

  • Apple monitor problem

    Hi. I am from Romania and I have a Apple LCD display (m2454) with ADC conector. My video card provide DVI and VGA outputs and I reorder pins on ADC conector to use DVI output like in this page: http://developer.apple.com/documentation/Hardware/Develo

  • Report containing bar chart

    I am new to charts in crystal reports. In my database i am having 200 students. In that i have one coloumn which is containing the ranks of student (1,2,3,..). In the report , i need to display, 1) X-axis ->ranks should be dispalyed (1,2,3,4,5) 2) Y-

  • Posting in Local ledger on different G/L accounts

    I have set up the following depreciation area in OADB 1 US GAAP                                                                          real   G/L 1 ledger 0L      2 LC Statutory GAAP                                                     real  G/L 3 l