Read SQL database by ABAP using OLE

Is somebody using abap to get a sql recordset?
I can connect to SQL and get a recordset but I can not retrieve data from the recordset.
I think this syntax is not correct:
<
data: records type P.
get property of field 'Value' = records.
>
is someone can help me?
thanks.
report chap2801.
include ole2incl.
data: con type ole2_object,
      rs type ole2_object,
      field type ole2_object.
* creating an object
create object con 'adodb.connection'.
check sy-subrc = 0.
* setting properties
set property of con 'connectionstring' = 'dsn=Northwind'.
* calling methods
call method of con 'open'.
check sy-subrc = 0.
create object rs 'adodb.recordset'.
check sy-subrc = 0.
set property of rs 'activeconnection' = con.
call method of rs 'open'
  exporting #1 = 'select count(*) as a from Products'.
check sy-subrc = 0.
get property of rs 'fields' = field exporting #1 = 0.
data: records type P.
*Get number of records
get property of field 'Value' = records.
free object con.
free object rs.
free object field.

I think this is what you need.
http://sqlage.blogspot.com/2013/11/ssis-read-excel-file-after-skipping-few.html
http://www.mssqltips.com/sqlservertip/2176/dynamically-find-where-table-data-starts-in-excel-using-ssis/
http://beyondrelational.com/modules/24/syndicated/398/Posts/9953/ssis-read-and-export-excel-data-from-nth-row.aspx
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Similar Messages

  • What's a better connection to an SQL database? ODBC or OLE DB

    NEw user here, but what would be a preferred way of connecting to my SQL database?  So far I have option of using ODBC (RDO) connection or OLE DB(ADO) connection. I'm not sure what the differences or when to use one or the other.
    Thanks

    I like OLE DB for the simply because it's "portable". With OLE DB the connection info is stored in the report. With ODBC, the report is using a system dsn connection. It means that if you want to send it to another user / computer, you also have to make sure the other computer has the same ODBC connection.
    In terms of performance... I've used both and have never seen a difference.
    Jason

  • Unable to launch a new document in winword 2007 from abap using OLE

    Dear Developers,
    We have a customized abap report which use OLE to launch a new document and display SAP data in that document. It is working on winword 2003.
    When we upgrade our version to office 2007 (winword 2007), the abap report will only launch a blank screen with no new document , no data is displayed.
    After reading OSS note 1286768, I tried with sap gui version 7.10 patch 17, but it still did not work.
    Some part of the codes below :
    CREATE OBJECT wordobj 'Word.Basic' .
    CALL METHOD OF wordobj 'AppInfo' = version EXPORTING #1 = 2.
    CALL METHOD OF wordobj 'FileNew' EXPORTING #1 = 'normal.dot'.
    CALL METHOD OF wordobj 'AppShow'.
    Do we need to install any files in SAP server to enable winword 2007?
    Do you have any tips to share?
    Thanks & regards
    Bee Khuan

    HI,
       use the following
    create object wordobj 'WORD.APPLICATION' .
      if sy-subrc ne 0 .
        message s000(su) with 'Error while creating OLE object!'.
        leave program .
      endif .
      set property of gs_word 'Visible' = '1' .
    SET PROPERTY OF gs_word 'Save' = '1' .
      get property of gs_word 'documents' = gs_documents.
      call method of gs_documents 'Add' = newdoc.
    Thanks & Regards,
    Vallamuthu. M

  • How to read Oracle Database as Input using BDC..

    Hello SAP Minds,
    How to read the data from Oracle data base to SAP tables. How can i use directly the Oracle database as input..
    I have to upload the time data  for my client for each of its employee per day. Their clock in and clock out time is recorded in the time maching and finally it gets stored into centralised oracle database, now they want me to  use this centralised database as input and upload the same into SAP.
    For example :
    pernr          time-in            time-out                 begda                   endda
    00001        8.00               18.00                  26-11-2007     26-11-2007

    You can use the database connector (DBCON) to read external databases directly.
    matt

  • Excel from abap using OLE, trying to make an excel cell-property currency

    Hello everyone,
    I have build an abap application which generates a price list as a MS Excel file using OLE techniques (ole2incl).
    One small thing in the excel file is lacking and I hope some one can help me out:
    I want to give certain cells in excel the "cell property - currency", so that excel shows the amounts as currency values. 
    Has anyone done or seen that before?
    Thanks a lot in advance.
    Kind regard, Archie Oomen

    Hi,
    I am having a similiar problem trying to fix the CELL format as TEXT.
    No matter how I try, it often ends up as 'GENERAL.
    Have you resolved your issue?
    Prehaps, you could share it if you had already rectify your problem.
    Thanks a lot

  • Querying an SQL Database from ABAP

    Is is possible from within ABAP in R/3 (or NetWeaver) to query a non-SAP database? For example, can I write ABAP code which will go after data in say a non SAP DB2 database at some remote location?
    Kevin

    Hi
    Connecting to an External database from SAP
    Step 1: Create an entry for the External database in DBCON table using Trxn: DBCA.
    Table: DBCON (Description of Database Connections)
    Field Name Description Value (For: E.g.:)
    CON_NAME Logical name for a database connection RAJ
    DBMS Database system MSS
    USER_NAME Database user <username>
    PASSWORD Password for setting up the connection to the database <pwd>/<pwd>
    CON_ENV Database-specific information for a database connection MSSQL_SERVER=depotserver MSSQL_DBNAME=HOF_INDORE
    DB_RECO Availability type for an open database connect  
    Step 2: Now you can write code to connect to the external database…
    Your Sample code can be something like this……
    DATA: BEGIN OF wa,
    c_locid(3),
    c_locname(50),
    c_locstate(5),
    END OF wa.
    EXEC SQL.
    CONNECT TO 'RAJ' AS 'V'
    ENDEXEC.
    EXEC SQL.
    SET CONNECTION 'V'
    ENDEXEC.
    *- Get the data from MS-SQL Server
    EXEC SQL.
    open C1 for
    select
    loc_id,
    loc_name,
    loc_state
    from ho_loc_mast
    ENDEXEC.
    DO.
    EXEC SQL.
    FETCH NEXT C1 into :wa-c_locid, :wa-c_locname, :wa-c_locstate
    ENDEXEC.
    IF sy-subrc = 0.
    PERFORM loop_output.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    EXEC SQL.
    CLOSE C1
    ENDEXEC.
    *& Form LOOP_OUTPUT
    Output
    FORM loop_output .
    WRITE: /5 wa-c_locid, 10 wa-c_locname, 65 wa-c_locstate.
    CLEAR wa.
    ENDFORM. " LOOP_OUTPUT
    Regards
    Raj

  • Read SOAP envelope into ABAP using XSLT?

    Hello,
    I have another problem here and this is really driving me nuts - I just don't get it to work.
    As a reply to a web-service I call I get the following xml file. All I need is an xslt that gets me errorCode and errorDescription into an ABAP structure...
    file:
    <?xml version="1.0" encoding="utf-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <SOAP-ENV:Body>
    <mit:rgo xmlns:mit="http://myurl.com"><mit:TECHNICALHEADER><mit:errorCode>A1014</mit:errorCode><mit:errorDescription>Unable to perform operation</mit:errorDescription><mit:password/><mit:user/><mit:applicationKey/></mit:TECHNICALHEADER><mit:file_creation_date>2005-09-06</mit:file_creation_date><mit:file_creation_time>15:06:33.0</mit:file_creation_time><mit:registration><mit:order_nr>DE999TEST</mit:order_nr><mit:vin>XXXXXXXXXXXXXXX04</mit:vin></mit:registration></mit:rgo>  </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    my corresponding XSLT is:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mit=
    "http://myurl.com" xmlns:asx="http://www.sap.com/abapxml" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap>
          <asx:values>
            <SOAP-ENV:Envelope>
              <SOAP-ENV:Body>
                <mit:rgo>
                  <mit:TECHNICALHEADER>
                    <ANSWER>
                      <mit:errorCode>
                        <xsl:value-of select="ERRORCODE"/>
                      </mit:errorCode>
                      <mit:errorDescription>
                        <xsl:value-of select="ERRORCODEDESCRIPTION"/>
                      </mit:errorDescription>
                    </ANSWER>
                  </mit:TECHNICALHEADER>
                </mit:rgo>
              </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
          </asx:values>
        </asx:abap>
      </xsl:template>
    </xsl:transform>
    What am I doing wrong or what do I need to do? I'm lost!
    Thank you for your help!
    Johannes.

    Thank you Durairaj, as a matter of fact my program is based on your post (one that you pointed me to). For whatever reason I'm not having luck figuring it out (may be just a bit of work pressure) could you please hlep me a bit more by pointing me to where in my program code/xslt I'm going wrong? I somehow feel that it could be my table structure or xslt.
    I would really appreciate it!
    Thanks again,
    erfan.

  • Transfering data from External SQL database to BW

    Hi Experts,
         I am trying to extract data from an External SQL Database  in BW using      
         DB Connect.
        1. I have created a  DB Source System.
        2. Using this Source System I have generated a Datasoure.
           ( following all the naming conventions for Table Names and Field Names)
        Till this point everything is OK.
        Then I assign a Infosource and try to upload the data into PSA.
        The process is never complete and I am getting a message
       <i> <b>Request still running
        Diagnosis
        No errors could be found. The current process has probably not finished yet.
        System response
        The ALE inbox of the SAP BW is identical to the ALE outbox of the source
        system
        and/or
        the maximum wait time for this request has not yet run out
        and/or
        the batch job in the source system has not yet ended.
        Current status
        No Idocs arrived from the source system</b>.</i>
         please help me.
      thanks
      arshad

    please first tell me which wich user you connect and the exact name of your table/view: is it dbo.table?
    as I said, better create a user in your SQL, log with this user and create a view.
    in RSBDC select this view and generate datasource. Check if you see data.
    if yes, the load shouldn't fail.
    We came across the same issue: login with sa, accessing a dbo. object; seing the data in RSDBC but nothing loading...
    let me know
    Olivier.

  • Load image from SQL database with ASP?

    Hello,
    Does anyone know a tutorial where you can load an image from
    a SQL database ?
    I would like to show this image in Flash, but i don't know
    how to load in from a SQL database using ASP.
    Regards,
    Micheal

    Flash cannot load images from an SQL database.
    Flash can load JPEG, PNG, GIF, SWF, MP3, and FLV files.
    An SQL database can be used to store the file names and their
    location. ASP can retrieve that data from the SQL and return to
    Flash to load the above file formats.
    For Flash to do the communication with ASP you need to
    determine if you are using URL Encoded or XML data structures.
    For URL Encoded data you look at
    LoadVars.sendAndLoad
    For XML Encoded data you look at
    XML.sendAndLoad
    Then in their onLoad methods you use
    MovieClip.loadMovie
    to load JPEG, GIF, PNG and SWF;
    Sound.loadSound
    for MP3,
    NetConnection.connect,
    Video.attachVideo and NetStream.play for FLV.
    For the ASP side the work with the database has nothing to do
    with Flash other than using any search variable sent from Flash
    with LoadVars.sendAndLoad or XML.sendAndLoad. In other words it
    could be an HTML form sending the same variable and calling the
    same ASP script. Same with returning values except with Flash only
    URL Encoded or XML data structures are sent back and not
    HTML.

  • Data Type for saving Base64 image string into SQL database

    Hi Team! I have image base64 string to be save into sql database. I use Varchar(MAX) data type. The problem is there are certain image string that cannot be enter (paste) into the table (due to the size) then i need to resize the image then i can paste
    the string into the table. How to make all image string size be able to be save in the table? Or there is limit on the image size to be save into the table? I'm using mssql 2008. Thanks a lot.

    There is a limit of 2GB. Which means that the actual image size must be less, since you encode the image in Base64 for some reason.
    Now, "pasting" strings is not the normal way to store data in an SQL Server database, so the question is a little funny. Normally data is stored in a database through a program of some sort. One way is to use OPENROWSET(BULK) as HuaMin suggested.
    Here is a link to a simple example of how to do it from .NET:
    http://www.sommarskog.se/blobload.txt
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Using OLE for download MS-Word

    Hello,
    can I use a MS-Word Template while creating an word obejct to write on the template
    I mean here-->
    CREATE OBJECT gs_word 'WORD.APPLICATION'.             "Create word object
    Thank you

    Hi,
    Chek out this wiki page:
    [Sample program to create a Word document from ABAP (using OLE) |http://wiki.sdn.sap.com/wiki/display/Snippets/SampleprogramtocreateaWorddocumentfromABAP%28usingOLE%29]
    Regards

  • Troubles Exporting SQL databases from Azure

    1. If I connect via SQL Server Management Studio and choose Export Data Tier Application to local disk, it never ends
    2. If I export via Azure web portal, it takes few hours
    3. The only way that works is using  SQL Server Management Studio and exporting to Azure container and then downloading it and importing via SQL Server Management Studio, seems like a lot of hassle
    I need Azure SQL database to be transferred daily to my local machine, preferably automatically. How can I do it?

    Hi Alex,
    Since the issue regards Windows Azure SQL Database, I will help you move the question to the related forums, It is appropriate and more experts will assist you.
    As Olaf’s post, if you want to migrate databases between the SQL Server Database Engine and Windows Azure SQL Database, you can use the Windows Azure SQL Database Import and Export operations to copy databases between two different SQL Database servers.
     In addition, you can also use the Windows Azure SQL Database copy database feature to make a consistent copy of a database, and perform the export from the copy. For more information, see
    Copying Databases in Windows Azure SQL Database. And you also can migrate a database by using the generate scripts wizard. For more information, see:
    How to: Migrate a Database by Using the Generate Scripts Wizard (Windows Azure SQL Database)
    According to your description, you want to migrate database daily and automatically, you can configure automated exports to schedule export operations for a SQL database, and to specify the frequency of export operations, and to set the retention period
    to store export files. Also you can set data sync between SQL Server and Windows Azure SQL database, configure bi-directional for database. For more information, see:
    Windows Azure SQL Data Sync.
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Who to use Native SQL statements in ABAP

    hi all,
    who to use native sql staements in abap bypassing Application server.
    with regards,
    suresh babu aluri.

    Hi
    Native SQL statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check. The statements entered there are passed to the Native SQL interface and processed there as follows:
    Almost all SQL statements that are valid for the addressed database system can be included between EXEC and ENDEXEC, in particular the DDL statements. These SQL statements are passed from the Native SQL interface to the database system largely unchanged. The syntax rules are specified by the database system, in particular the case sensitivity rules for database objects. If the syntax allows a separator character between individual statements, you can include several Native SQL statements between EXEC and ENDEXEC. Generally, the semicolon ( is used as the separator character.
    You can also include SAP-specific Native SQL language elements between EXEC and ENDEXEC. These statements are not passed directly from the Native SQL interface to the database, but are converted appropriately.
    All Native SQL statements bypass SAP buffering.
    The ENDEXEC statement sets sy-dbcnt to the number of table rows processed in the last Native SQL statement. After implicit cursor processing with PERFORMING, sy-dbcnt contains the total number of lines read.
    Programs with Native SQL statements are generally dependent on the database system used, so that they cannot be executed in all ABAP systems. This is especially true for the examples in this section, which was written for Informix database systems.
    Example
    Inserting two rows in the database table SCARR. If neither of these rows exists, sy-subrc is set to 0 by ENDEXEC and sy-dbcnt to 1. Otherwise, an exception is raised and handled.
    DATA: exc_ref    TYPE REF TO cx_sy_native_sql_error,
          error_text TYPE string.
    TRY.
        EXEC SQL.
          INSERT INTO scarr
                      (MANDT, CARRID, CARRNAME, CURRCODE, URL)
            VALUES ('000', 'FF', 'Funny Flyers', 'EUR',
                    'http://www.ff.com');
          INSERT INTO scarr
                     (MANDT, CARRID, CARRNAME, CURRCODE, URL)
            VALUES ('000', 'EF', 'Easy Flyers', 'EUR',
                    'http://www.ef.com');
        ENDEXEC.
      CATCH cx_sy_native_sql_error INTO exc_ref.
        error_text = exc_ref->get_text( ).
        MESSAGE error_text TYPE 'I'.
    ENDTRY.
    Reward points if useful
    Regards
    Anji

  • Update database outside SAP using Abap program

    Hi guys, I have the following scenario:
    Today, I have an abap program that calls a RFC to update a database outside SAP using Business Connector.
    The problem is that I won't be allowed to use Business Conncetor (and can't use XI too) to access the outside database (SQL Server 05).
    Is possible to update the SQL Server 05 from an Abap program without a Java based connector? Because my main problem is that I can't use Java...
    Thank you
    Robert

    hi,
    you can use the database connection
    >exec
    > native sql statment
    >endexec
    check theese links for generating source code in ABAP
    [How to use INSERT in EXEC SQL ...... ENDEXEC ?;  insert data to external database
    [exec sql help;  read data from external database
    check theese links for configurating of DBCO (DataBase COnnection)
    [/thread/108422 [original link is broken];
    [http://help.sap.com/saphelp_nw04/helpdata/en/df/455ec9747111d6b25100508b6b8a93/frameset.htm]
    hope that is useful.
    Regards
    Marco

  • How to store data into database by reading sql statements from text file

    how to write java program for storing data into database by reading sql statements from text file

    Step 1: Create a property file to add various queries.
    Step 2: Read the properties file using ResourceBundle
    Step 3: Use the jdbc to execute the query read from the property file.
    So in future if you need to change query no need do any modifications in java program. But depends on how you use the property file.

Maybe you are looking for

  • Not supported features - Nokia Lumia 525

    SLEEPING NOKIA AND WINDOWS DEVELOPER??? 1. In any browser mail did attach any file(doc,pdf in memory card..) 2. No pen drive connect and projector connect 3. No printer connect 4. Very worst office hub compare to king office soft in android 5. No mem

  • Hyper-V guest boots to recovery console after shutdown

    I experience the following scenario: After a hyper-V host (W2008R2 Ent.) is restarted, the guest VMs (W2008R2 Ent.) boot randomly to recovery console. This means some of the VMs boot correctly into Windows server environment while others boot into re

  • SOAP header in my WSDL ignored by Creator

    The soap:header element from the bind section of my WSDL file is being ignored by Creator. Creator is picking up the soap:operation element soapAction=.. and My <input> element for a operation has both soap:body and soap:header elements. The soap:bod

  • N97 - Unable to upload images to Facebook

    Hi, I've been very happy with the recent v2 software update and had no problems so far (after the mess the previous firmware update left my phone in), my only problem is while using the facebook application I can no longer upload images from my phone

  • Activating and Installation help BW statistic in BI 7.0

    I have installed the business content for SAP Statistics, but don't have the BI_BW_Administration role authorization. I don't know if it is possible to still go ahead with the Statistics peice. I don't see the process chains created by following the