Reputation: 956
I entered a new database connection in transaction DBCO to another sap system. and testet it successfully with the report ADBC_TEST_CONNECTION
.
How do I make use of this connection in a CDS view? Is it even possible? I thought it would work with table functions but didn't get it to work.
Alternatively I tried to use it within an abap programm with no success:
data: lt_vbak(20).
exec sql.
CONNECT TO 'SECOND_DB'
endexec.
exec sql.
SELECT vbeln into :lt_vbak FROM vbak where mandt = 500
endexec.
exec sql.
DISCONNECT :'SECOND_DB'
endexec.
It says that the table vbak
does not exist.
We are currently on SAP ECC with ABAP 7.50.
Any suggestions? Thanks
Upvotes: 3
Views: 1720
Reputation: 899
Not sure about CDS views but in an ABAP program you can do it via Open SQL by using the CONNECTION option and specifying the name of your secondary database connection:
SELECT vbeln INTO TABLE lt_vbak FROM vbak WHERE mandt = 500 CONNECTION ('SECOND_DB').
However, this requires that you have table VBAK with the same structure as the VBAK that you are querying also defined in the DDIC of your ECC system.
See also the documentation for the CONNECTION parameter here: SELECT additional options
Upvotes: 1
Reputation: 10396
This is a broad question and the information provided don't allow to tell what did not work correctly in your example.
It might just be that the logon user for the secondary connection does not connect to the correct schema or does not have the privileges to access the table VBAK
.
As you basically ask for a how-to I recommend checking the extensive ABAP documentation on the topic and/or the well written and informative blog post from one of the ABAP core developers.
Upvotes: 0