Skip to Content
avatar image
Former Member

Querying SAP Database

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 03, 2006 at 12:08 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Apr 04, 2006 at 07:09 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 03, 2006 at 01:42 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded