cancel
Showing results for 
Search instead for 
Did you mean: 

Querying SAP Database

Former Member
0 Kudos

I seen in some sites that we can query the SAP database using doQuery()..

If i use the tablename eg.OCRD used by SAP for my application.. Is there any chance of changing the table name in SAP..

If anybody having exposure in SAP SDK please give me some ideas about that

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey Sooriya,

Where possible you should use the business objects in the API such for objects that are avaiable such as OCRD (business partners), OITM (items) etc.. This ensures compatibility with the Business one system. Unfortunately not all of the objects you need are available and you have to use the query method to get the information you need. When doing this you must be aware that the database structure may change in patches, upgrades etc.. You will need to test your application for each release when you upgrade the client.

Usually table names do not change a whole lot. But field names can change with major releases.

Former Member
0 Kudos

Hi Curtis..

Thanks for ur immediate reply..

I m in ETL project to access data from SAP to Access and vise versa.

I want to know some more details..

1.We usually retrieve the Business Partners List by using GetBPList() method and we traverse record by record and save it as a XML.(XML contains a single recordset)

Is there a way to retrieve full Business Partner Records in a single XML?

Please reply immediately

Thanks in Advance

Sooriyakala.P

Former Member
0 Kudos

Hey Sooriyakala,

I am unsure if you can save all of the BPs as one xml file. The GetBPlist generates a recordset and it has a get as xml method. You can try this to see what it returns. I have not tried it before so I do not know if this will work for you or not.

Former Member
0 Kudos

Hi Curtis,

i used GetBPList(),it saves only a single record in a XML if we store as SaveXML().

I want to get all records of a table using BusinessObject of any SAP module without specifying any keys.If i access using GetByKey(1) ,like that i can access a single record as resultset.But my requirement is getting the whole records <b>without using keys</b>.Is it possible by ur experience..

If u give ur official id,i can get more details regarding SAP SDK.

Thanks and regards

Sooriyakala

Former Member
0 Kudos

As J stated below the only way you can do this is with a recordset.

Not sure what you mean by giving you my official Id?

Former Member
0 Kudos

Hi Curtis,

i mean ur personal yahoo/hotmail id,so that we can get valuable details.Since u are a SAP Certified SDK programmer,We really need ur help.

Former Member
0 Kudos

Sorry I do not give out my personal email address for people to contact me. I will be happy to help with any posts that you submit to the forum so that everyone can benefit from the answers.

Curtis

Answers (2)

Answers (2)

jaccomoolenaar
Participant
0 Kudos

Following code works for me (in VB):

Dim rs As SAPbobsCOM.Recordset

Dim query As String

Try

query = "SELECT * FROM OCRD"

rs = oCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

rs.DoQuery(query)

Console.WriteLine("aantal regels ", rs.RecordCount) If rs.RecordCount > 0 Then Dim file As String = "c:\temp\bp.xml" Console.WriteLine("file: ", file)

rs.SaveXML(file)

End If

Catch e As Exception

Dim message As String = _

e.[GetType].ToString + ":" + vbCrLf + _

e.Message + vbCrLf + _

e.StackTrace

Console.Error.WriteLine(message)

MsgBox(message, MsgBoxStyle.Critical)

End Try

Regards,

Jacco.

jaccomoolenaar
Participant
0 Kudos

Hi,

Maybe you can do something like this (example is in JAVA):

IRecordset rs = null;

try

{

String selectQry = "select * from OCRD";

rs = SBOCOMUtil.runRecordsetQuery(oCmp, selectQry);

if (rs.getRecordCount() > 0)

{

rs.saveXML("c:\temp\bp.xml");

rs.release();

}

}

catch (SBOCOMException e)

{

e.printStackTrace();

}

Hope it helps.

Kind regards,

Jacco.