‎2016 Jan 29 11:15 AM
Hi,
I'm beginner in that kind of action so that's why I'm asking there help to masters
My need is : I must connect in an external database (other company) and insert data in several tables!
I have an access to that DB in display with "Microsoft SQL Server 2012" so I'm able to check inside the table if lines exist...
But now, my issue is how to connect on this database and do the insert in one table (+check if the insert was well done) ??? 😕
to access via MS SQL server i use things like
- server name
- ID
- password
is that a way to exectute I don't know, a kind of SQL statement with inside the notion of connection to the external database + the insert X Y Z into table Where blablabla... ?
Thanks in advance for your help.
Pascal.
‎2016 Jan 29 12:37 PM
Hi,
You can use SQL syntax.
These statements define an area in an ABAP program in which one or more Native SQL statements are to be carried out. The area between EXEC and ENDEXEC is not completely checked by the syntax check.
Here is a small example in DEMO_NATIVE_SQL report.
‎2016 Jan 29 12:41 PM
‎2016 Jan 29 2:45 PM
‎2016 Jan 29 12:41 PM
Hi Pascal,
While i personally dont like the idea of connecting directly to a 3rd party database and doing updates/changes from a data control perspective, this is possible.
Take a look at this SCN thread
But just a suggestion it would probably be safer for the other system if you did a ftp/sftp of a flat file or even a SOAP call so that the other system could then handle the update of it's own database and ensure that nobody tries to update fields their not supposed to while also making it easier for them to update their system without fear of connections instantly failing due to fields being changed.
Just a thought that may make it less risky to the downstream system,
Hope this helps,
Geoffery
‎2016 Jan 29 1:19 PM
I know it's not really nice ... but it's a customer who impose me that ... so no choice
(he's working like that since a long time and won't change for me )
But it's not his finale DB but a template one (and then, he transfer the templ into the final one himself I suppose)
‎2016 Jan 29 1:21 PM
Fair enough, guess some people really dont care bout the risk.
Hope that link with the configuration and code sample works for you then
Geoffery
‎2016 Jan 29 1:18 PM
thanks for the example (DEMO_EXEC_SQL).
I had a quick look but nothing around the connection to the other system... isn't it?!
It's more this point which bring me some interrogations ... and not the "insert" SQL syntax
I'll have a look deeper to see if there's something around a connection to 1 other syst.
‎2016 Jan 29 2:42 PM
To create a conection with another DB you must set up configuration in transaction DBCO..
Take a look at this sap notes: 178949, 323151
‎2016 Jan 29 10:59 PM
Pascal, everyone can search on Google, beginners including. When I go to Google and type in "connect external database site:sap.com" or "insert to external database site:sap.com" it brings up very many posts. Native SQL is also covered in ABAP Help.
I'd suggest to ask your Basis admin to establish the DB connection. In case your SAP system does not run on Windows/SQL (ours is on Linux/Oracle, for example) there is a bit more work needed.
Overall agree with Geoffery's suggestion that it's not a good idea in general (and be prepared for a slow performance) but alas, some occasions call for it.