Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Connect to External Database from SAP (same Server)

venkateswaran_k
Active Contributor
0 Likes
786

Dear All


We have SQL Server in the Quality Server. We have two databases in it.

   1. SAP R3 database is AEQ.
   2. HR Database is     HRMS

I need to access a table inside HRMS database from SAP R3 database AEQ.  (Both the database are in same server where SAP is installed)

I have set the following Configuration in order to Connect to External Datbase (SQL Server database)from SAP.

However

It gives error on third EXEC SQL

   saying


You tried work with name of the table or view that does not exist in the databse.


However, my table name is correct.  i am able to view it in the database.


Kindly help me where I am missing.

Regards,
Venkat

1. DBCO.

    I set DATABASE Connection :  <TDATA>

           DBMS                           :  MSS

           Username and Password:  <uid./<pwd>

           Connection informaltion  :   MSSQL_SERVER=<IP Address> SQL_DBNAME=<dbname>


2. I have written a connection ABAP program and tested.  It displays an error message as follows


   TRY .
      EXEC SQL .
        CONNECT TO 'TDATA'
      ENDEXEC.

       EXEC SQL.
        SET CONNECTION  'TDATA'
      ENDEXEC.

      EXEC SQL.
        SELECT COUNT(*) into :l_counter from <tablename>
      ENDEXEC.

      write : l_counter .

     CATCH cx_sy_native_sql_error INTO exc_ref.

        error_text = exc_ref->get_text( ).
        MESSAGE error_text TYPE 'I' RAISING sql_error.

ENDTRY.

3 REPLIES 3
Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
725

Hi Venkateswaran,

if I understand you correctly the connection works (no error after CONNECT TO...), but the table is not found.

One guess: which user did you enter in DBCO? I recall (but from some tests in relation to SAP HANA, not with MSS) that - at least per default - the ABAP system connects to the schema equal to the user.

Best regards

Thorsten

Read only

0 Likes
725

Dear Thorsten,

Thankyou for the reply, 

The CONNECT itself gives sy-subrc = 4.  That means the connection is failed.  I an worried, where i am missing.

Is there any Notes, or other configurations to be done?

If anyone help, will be greatful.

Regards,

Venkat

Read only

schneidertho
Product and Topic Expert
Product and Topic Expert
0 Likes
725

Hi Venkat,

do you know note 178949? Best regards

Thorsten