Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Trying to connect to SQL SERVER

$
0
0

We have SAP on Oracle database but as we are implementing our HR system on SQL Server so we need to connect to SQL SERVER through ABAP in order to retrieve some information. We created the Connection successfully but when trying to retrieve the data it is giving us following dump :

 

Runtime Errors         DBIF_DSQL2_INVALID_CURSOR

Except.                   CX_SY_NATIVE_SQL_ERROR

 

Invalid interruption of a database selection

 

The code through which i am trying to retrieve the data is as follows :

 

DATA: c1  TYPE cursor.

 

DATA : BEGIN OF EMP_DATA OCCURS 0,

        FNAME(5000) TYPE C,

        END OF EMP_DATA.

 

DATA : fnm TYPE STRING.

 

EXEC SQL.

   CONNECT TO  'HRMS'

ENDEXEC.

 

 

if sy-subrc eq 0.

   MESSAGE 'Connected..' TYPE 'I'.

else.

   MESSAGE 'Not Connected..' TYPE 'I'.

endif.

 

EXEC SQL.

   OPEN c1  for

   SELECT FNAME

   FROM view_EMPDATAPayroll_New

ENDEXEC.

 

if sy-subrc eq 0.

   MESSAGE 'Access Successful..' TYPE 'I'.

else.

   MESSAGE 'Access Not Successful..' TYPE 'I'.

endif.

 

DO.

   EXEC SQL.

     FETCH NEXT c1 INTO  :EMP_DATA.FNAME;

   ENDEXEC.

 

   APPEND EMP_DATA.

 

   IF sy-subrc <> 0.

     EXIT.

   ENDIF.

 

ENDDO.

 

EXEC SQL.

   CLOSE c1

ENDEXEC.

 

EXEC SQL.

   DISCONNECT 'HRMS'

ENDEXEC.


We have tried a lot to solve the error but every time we are getting the same dump. It is giving dump at the following command :



FETCH NEXT c1 INTO  :EMP_DATA.FNAME;


The connection properties are also as follows :


DB Connection      HRMS

DBMS                 MSS

User Name           sa

Conn. info            MSSQL_SERVER=192.168.0.60\SQLEXPRESS MSSQL_DBNAME=HRAlign_Rubamin

 

Please help me out.

 

Tarun.


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>