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

Problem with report using DBCON multiconnect to MSSQL Server.

Former Member
0 Likes
522

Hi,

I have created this report following OSS note 738371 and it works fine:

-


REPORT z99bc_dbcon_test.

DATA: dbn(128).

PARAMETERS: pconn TYPE dbcon_name DEFAULT 'TEST-CONN'.

ptab TYPE string DEFAULT 'MYSCHEMA.MYTABLE'.

EXEC SQL.

CONNECT TO :pconn

ENDEXEC.

EXEC SQL.

SET CONNECTION :pconn

ENDEXEC.

EXEC SQL.

SELECT db_name() INTO :dbn FROM MYSCHEMA.MYTABLE

ENDEXEC.

EXEC SQL.

SET CONNECTION DEFAULT

ENDEXEC.

WRITE: / 'current database name', dbn.

-


DBCON entry has conn info very simple: 'MSSQL_SERVER=<IP Address> MSSQL_DBNAME=TEST'

This program connects to database TEST, and reads table MYTABLE in schema MYSCHEMA.

I would know if it is possible to select the table name in a dynamic way:

SELECT db_name() INTO :dbn FROM :ptab

But this line fails with meesages:

dbdsmss: DBSL99 SQL1087

Must declare the table variable "@P1".

***LOG BY2=> sql error 1087 performing OPC dbds#2 @ 486 dbds 0486

***LOG BY0=> Must declare the table variable "@P1". dbds#2 @ 486 dbds 0486

Any idea ? It is possible at all ?

Regards,

Joan B. Altadill

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
429

Hello Joan,

You have to use the [ADBC classes|http://help.sap.com/abapdocu_702/en/abenadbc.htm] to fulfill your requirement. using these classes it is possible to select the data dynamically. Please refer to the SAP Online documentation for details.

You can use the demo program ADBC_DEMO for your reference.

BR,

Suhas

1 REPLY 1
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
430

Hello Joan,

You have to use the [ADBC classes|http://help.sap.com/abapdocu_702/en/abenadbc.htm] to fulfill your requirement. using these classes it is possible to select the data dynamically. Please refer to the SAP Online documentation for details.

You can use the demo program ADBC_DEMO for your reference.

BR,

Suhas