on ‎2004 Sep 09 3:04 PM
Hello,
I have coded a Visual Basic 6 procedure to insert some rows into standard tables ( OOCR, OCR1 ).
I have done this in a transaction :
Dim oRec As SAPbobsCOM.Recordset
Set oRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRec.DoQuery ("INSERT INTO [dbo].[OOCR] VALUES ('" & RepCode & "','" & RepDesc & " '," & TotalFacteur & ",'" & Direct & "','N','N'," & vUserId & ")")
Imagine that I have 2 same RepCode to insert , as for the table OOCR the primary key is the RepCode, it bugs ...!
Is there a way to catch the database bugs ( such as duplicate data, constraints violations ... ) in visual basic 6 using SDK ( SDK Exceptions object ?? ) without writing a lot of code ... ?
Thanks.
Romeo.
Request clarification before answering.
Hi Romeo,
please note that the name of the recordset object's method you are using is "DoQuery". This indicates that this method was never intended to be used for anything else but database queries (Select statements only). Right now the method seems to support other statements as well, including Updates, Deletes , Inserts and more.
8Just for the records, the query designer in SAP client supports all of these statements as well, although you can clearly tell that it was never meant to.
Whenever you can you should go through SAP business logic via the given Business Objects. However, developers cannot fail to notice that only the very basic (and most important) Business Objects are exposed via DIApi. I guess SAP will continually add more of the less important objects time at a time.
Clearly the SAP recordset was not made for things other than querying. The errors the company object returns are at best SQL server errors. Therefore you will be much better off using an ADO connection to the database. Here you get the regular SQL Server errors as well and do not run into potential trouble whenever SAP decides to redesign the DoQuery method in a way that it does only queries.
Since you bypass the business layer anyway, you can as well go with ADO. Looking at the addons SAP itself published, the first thing that meets the eye is the fact that you are required to execute two SQL statements in order to get the Datev interface up and running. (Datev is a german interface for tax information)
You could probably just use Query analyzer as well.
Anyway, ADO provides you with all necessary information to catch any database errors.
HTH Lutz Morrien
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 41 | |
| 25 | |
| 15 | |
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.