Skip to Content
author's profile photo Former Member
Former Member

how can i get the external Sql result return data to abap?

Dear All

I have a problem to how to get the select result data return abap.

I used abap to run external SQL server. below is my code:

***in above ,abap has already connected external SQL.

Sql = u2018select * from user01u2019

CALL METHOD OF rec 'Open'

EXPORTING #1 = sql

#2 = con

#3 = '1'.

IF NOT sy-subrc = 0.

MESSAGE e000 WITH 'run external sql error!'.

ENDIF.

***now ,below code how can I get the select result to abap code?

I know I can use native_sql such as u2018OPEN CUR1 FOR SELECT * FROM user01 AND FETCH NEXT CUR1 INTO :WAu2019.

Thanks for all

Sun

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 30, 2008 at 12:04 AM

    I used this code to get RECORDSET property,but it does not return value.

    data ieof type i.

    CALL METHOD OF con 'Execute' = rec

    EXPORTING

    #1 = con_str.

    GET PROPERTY OF rec 'EOF' = ieof.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks.

      it is okay now by myself.

      con_str = 'Provider=SQLOLEDB.1;Password=pwd;Persist Security Info=True;User ID=name;Initial Catalog=VTL_DEMO;Data Source=192.168.21.50'.

      CREATE OBJECT o_conn 'ADODB.Connection'.

      CREATE OBJECT o_rec 'ADODB.Recordset'.

      SET PROPERTY OF o_conn 'Provider' = provider.

      SET PROPERTY OF o_conn 'ConnectionString' = con_str.

      CALL METHOD OF o_conn 'Open'.

      sql_str = 'select * from userh'.

      CALL METHOD OF o_conn 'Execute' = o_recordset

      EXPORTING

      #1 = sql_str.

      • #2 = o_conn.

      GET PROPERTY OF o_recordset 'EOF' = rs_eof.

      REFRESH itab.

      WHILE rs_eof NE 1.

      CALL METHOD OF o_recordset 'fields' = o_field

      EXPORTING

      #1 = 0.

      GET PROPERTY OF o_field 'Value' = itab-name.

      CALL METHOD OF o_recordset 'fields' = o_field

      EXPORTING

      #1 = 1.

      GET PROPERTY OF o_field 'Value' = itab-cid.

      APPEND itab.

      CALL METHOD OF o_recordset 'MoveNext'.

      GET PROPERTY OF o_recordset 'EOF' = rs_eof.

      ENDWHILE.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.