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

passing data from abap-program to mssql database table thro native sql

Former Member
0 Likes
741

Hi,

To pass the data from abap-program to mssql server,i have created database connection through dbco t.code.

now i am trying to get connection thro native sql but am not able to get it .Am working in ECC 5.0.

Could anyone help me on this.Did i miss anything?

i have tried Native-sql like this.

DATA: CON_NAME LIKE DBCON-CON_NAME VALUE 'BIW'.

EXEC SQL.

  CONNECT TO :con_name AS 'C1'

ENDEXEC.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
677

Hi,

Trying to do the same here, only using Oracle DB.


....
DATA:     dbc TYPE DBCON_NAME VALUE 'BI'

....
TRY.
  EXEC SQL.
    CONNECT TO :dbc
  ENDEXEC.

  IF sy-subrc NE 0.
    RAISE EXCEPTION TYPE cx_sy_native_sql_error.
  ENDIF.
CATCH cx_sy_native_sql_error INTO oref_native_sql_error.
  sql_emsg = oref_native_sql_error->get_text( ).
  MESSAGE sql_emsg TYPE 'I'.
ENDTRY.

I keep getting the message 'Native SQL exception has occured' (because of the RAISE statement, I wonder how we can get a meaningfull error description).

Of course this can be a result of a number of network issues, so I'm trying to resolve this together with my BC admin.

I suggest the same to you..

In the meantime, if anyone can help out, it will be appreciated.

Regards,

SD

4 REPLIES 4
Read only

Former Member
0 Likes
677

could anyone give some ideas on this pls?

Read only

Former Member
0 Likes
678

Hi,

Trying to do the same here, only using Oracle DB.


....
DATA:     dbc TYPE DBCON_NAME VALUE 'BI'

....
TRY.
  EXEC SQL.
    CONNECT TO :dbc
  ENDEXEC.

  IF sy-subrc NE 0.
    RAISE EXCEPTION TYPE cx_sy_native_sql_error.
  ENDIF.
CATCH cx_sy_native_sql_error INTO oref_native_sql_error.
  sql_emsg = oref_native_sql_error->get_text( ).
  MESSAGE sql_emsg TYPE 'I'.
ENDTRY.

I keep getting the message 'Native SQL exception has occured' (because of the RAISE statement, I wonder how we can get a meaningfull error description).

Of course this can be a result of a number of network issues, so I'm trying to resolve this together with my BC admin.

I suggest the same to you..

In the meantime, if anyone can help out, it will be appreciated.

Regards,

SD

Read only

Former Member
0 Likes
677

Closing this thread...

Read only

0 Likes
677

I have solved this, with the help of the BC.

BC needs to make changes to a configuration file, to enable listeners, according to the address and port.

In DBCO, make sure you test your connection (for example: my_dbc) and verify it's working.

In ABAP,

Define my_dbc, like it is, in the post above.

use CONNECT TO :my_dbc, and it should work!

Instead of RAISE exception, use CATCH cx_native_sql_exeption (or something like that, I can't verify at the moment) INTO oref

In CATCH block, use method get_text() of the oref, to fetch the error description into a string variable..then just write it out via list, or message, etc...

Regards