Bug in SAPbobsCOM.Recordset.GetAsXML()?

I am using the following code:
string query =
        "SELECT BoxCode as stBoxcode, (CASE WHEN TaxCode = 'B' THEN BaseAmount ELSE Debit + Credit END) AS Amountx " +
        "FROM (SELECT VatTaxBox.BoxCode, VatTaxBox.TaxCode, SUM(dbo.JDT1.Basesum * VatTaxBox.FSign) as BaseAmount, SUM(dbo.JDT1.Debit * VatTaxBox.FSign) AS Debit, SUM(dbo.JDT1.Credit * VatTaxBox.FSign) AS Credit " +
        "FROM  dbo.JDT1 INNER JOIN dbo.OJDT ON dbo.JDT1.TransId = dbo.OJDT.TransId " +
        "INNER JOIN dbo.OVTG ON dbo.JDT1.VatGroup = dbo.OVTG.Code " +
        "inner join (SELECT  (CASE WHEN BOXx IS NULL THEN VatBoxes.Boxcode ELSE BOXx END) AS BoxCode, VATMember, FormulSignx * FormulSign as FSign, OBOX.summayfld AS TaxCode " +
        "FROM (SELECT TOP 100 PERCENT B11.BoxCode AS BOXx, B0.boxcode, B0.BoxMember, B0.VATMember, isnull((select (case when formulSign='M' then -1 else +1 END) as FSignX from box1 b1 " +
        "where b1.boxcode=B0.boxcode and b1.SeqNum = B0.Seqnum-1), +1) AS FormulSignx, isnull((select (case when formulSign='M' then -1 else +1 END) as FSignX from box1 b1 " +
        "where b1.boxcode=B11.boxcode and b1.SeqNum = B11.Seqnum-1), +1) AS FormulSign " +
        "FROM BOX1 B0 LEFT OUTER JOIN BOX1 B11 ON B0.BoxCode = B11.BoxMember " +
        "WHERE (NOT (B0.VATMember IS NULL)) ORDER BY B11.BoxCode, B0.BoxCode, B0.SeqNum) AS VatBoxes " +
        "INNER JOIN OBOX ON VatBoxes.boxcode = obox.boxcode) as VatTaxBox ON JDT1.VatGroup = VatTaxBox.VATMember " +
        "WHERE (dbo.OJDT.RefDate >= '2005/01/01') AND (dbo.OJDT.RefDate <= '2005/07/01') AND OJDT.Series = 4 GROUP BY VatTaxBox.BoxCode, VatTaxBox.TaxCode ) as ResultSet ";
      SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)_sapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
      try
        rs.DoQuery(query);
        int i = rs.RecordCount;
        int j = i++;
        string s = rs.GetAsXML(); //-> throws an error: "External component has thrown an exception."
      catch (Exception ex)
        System.Windows.Forms.MessageBox.Show(ex.ToString());
The statement rs.GetAsXML() throws an exception. However when I use a simpler query everything works fine.
What am I doing wrong?
Jurgen

I don't specifically, but one trick I've learned of is to "hide" complex SQL queries in functions or stored procedures.  SBO sometimes has problems with complex SQL queries.  They're aware of this, but until it's fixed, try putting that "monster" in a function or a view. 
Hope that helps.

Similar Messages

  • Using the SAPbobsCOM.Recordset & DataTables

    I'm trying to find the best way to tie the SAPbobsCOM.Recordset object (based, for example, on a query to return all Employees) to a more .NET compatible data object such as a datatable or dataset.
    In other words, for things such as combo boxes, datagrids etc in .NET how are you guys usually binding data from SBO?
    I can just write a call directly to the DB, but wanted to go through the SDK if possible.
    Thanks!

    I actually ended up putting this into a utility .dll, but here's the function...
    Public Function ConvertRecordset(ByVal SAPRecordset As SAPbobsCOM.Recordset) As DataTable
            '\ This function will take an SAP recordset from the SAPbobsCOM library and convert it to a more
            '\ easily used ADO.NET datatable which can be used for data binding much easier.
            Dim dtTable As New DataTable
            Dim NewCol As DataColumn
            Dim NewRow As DataRow
            Dim ColCount As Integer
            Try
                For ColCount = 0 To SAPRecordset.Fields.Count - 1
                    NewCol = New DataColumn(SAPRecordset.Fields.Item(ColCount).Name)
                    dtTable.Columns.Add(NewCol)
                Next
                Do Until SAPRecordset.EoF
                    NewRow = dtTable.NewRow
                    'populate each column in the row we're creating
                    For ColCount = 0 To SAPRecordset.Fields.Count - 1
                        NewRow.Item(SAPRecordset.Fields.Item(ColCount).Name) = SAPRecordset.Fields.Item(ColCount).Value
                    Next
                    'Add the row to the datatable
                    dtTable.Rows.Add(NewRow)
                    SAPRecordset.MoveNext()
                Loop
                Return dtTable
            Catch ex As Exception
                MsgBox(ex.ToString & Chr(10) & "Error converting SAP Recordset to DataTable", MsgBoxStyle.Exclamation)
                Exit Function
            End Try
        End Function

  • VBA with SAPbobsCOM.Recordset

    Hi all,
    I'm trying to do a report using VBA microsoft word.
    I manage to connect to the database using the DI API.
    But when i tried to do the
    SAPbobsCOM.Recordset, i got error.
    Need advice.
    Regards,
    Bruce.

    The code I have contains plenty of other stuff, I try to give you some pseudocode for a dll - OK I know this is a very bad pseudocode, it is just to give you an idea ...;-). You should then use this dll from your VBA module: this is what we did and it worked well.
    SAPbobsCOM.Company company = new Company();
    int Initialize()
    /// connect the company
    int Finalize()
    /// disconnect the company
    /// this method read data from the DB with a Recordset
    /// and returns them into an array of strings
    string[] loadData()
    /// your returned data
    string[] ret = new string[];
    /// your SQL query
    string query;
    /// the recordset
    SAPbobsCOM.Recordset rset;
    rset = company.GetBusinessObject(SAPbobsCOM.BoRecordset);
    rset.DoQuery(query);
    /// loop to fill into the string array
    /// move the position in the recordset with rset.MoveNext
    /// until you reach rset.EoF and copy the data in ret
    return ret;

  • SAPBobsCOM Recordset cannot execute Stored Procedure

    I have a query stored in a SQL 2005 Stored Procedure, and when want to retrieve my procedure with the Recordset.doQuery() command, this error message appears :
    System.Runtime.InteropServices.COMException (0xFFFFF930) at SAPbobsCOM.IRecordset.DoQuery(String QueryStr) at [ blah2..... (it refers to my code line) ]
    My code is :
    Dim oRec As SAPbobsCOM.Recordset
    oRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
    Try
            oRec.DoQuery("EXEC PO_LIst2")
    Catch ex As Exception
            MsgBox(ex.GetBaseException.ToString)
    End Try
    And when I change my code to be like this :
    Dim oRec As SAPbobsCOM.Recordset
    oRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
    Try
            oRec.DoQuery("Select * From OPOR")
    Catch ex As Exception
            MsgBox(ex.GetBaseException.ToString)
    End Try
    I don't get any error....
    For all of the code I use SQL Server 2005, Visual Studio 2008, and SAPBobsCOM version 8.8.
    Have anyone experience this?? Why the recordset can't execute my stored procedure??
    Edited by: Rinaldi Sugiono on Jun 18, 2010 1:44 PM

    I would search the forums for SAPBobsCOM to find a more appropriate forum, since the BusinessOne components are outside of scope for this forum.
    Sincerely,
    Ted Ueda

  • Set crystal report .rtp file with SAPbobsCOM.Recordset type object

    Hi Experts,
    I need to pass the resultset of my SAPbobsCOM.Recordset type query to the rpt file. what report object should i use. at the moment i am using reportdocument but at the point of calling .SetDataSource(rs) it says the datasource is not valid.
    Please help.
    Is there any addon sample regarding setting the recordsouce of a report by setting it with SAPbobsCOM.Recordset type object is availabel.
    Regards.

    Hi Maryam,
    In my sample I'm getting the values from a DataTable. But the procedure is the same for a RecordSet.
        Private Sub PrintDM(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, ByRef oForm As SAPbouiCOM.Form)
            Dim dt_h As Data.DataTable = Nothing
            Dim drh As Data.DataRow = Nothing
            Dim dt_r As Data.DataTable = Nothing
            Dim drr As Data.DataRow = Nothing
            Dim ds As Data.DataSet = Nothing
            Dim rsNotaRecepcao As SAPbobsCOM.Recordset = Nothing
            Dim rsMorada As SAPbobsCOM.Recordset = Nothing
            Dim rptConnectionInfo As ConnectionInfo = Nothing
            Dim rptPath As String = Nothing
            Dim myTables As Tables = Nothing
            Dim myTableLogonInfo As TableLogOnInfo = Nothing
            Dim rptDocument As ReportDocument = Nothing
            Dim FileName As String = "DiarioDeMovimentos"
            Try
                dt_h = New Data.DataTable("HEADER")
                dt_h.Columns.Add("Key")
                dt_h.Columns.Add("Empresa")
                dt_h.Columns.Add("DiaryCod")
                dt_h.Columns.Add("DiaryNam")
                dt_h.Columns.Add("FromNum")
                dt_h.Columns.Add("ToNum")
                dt_h.Columns.Add("FromDate")
                dt_h.Columns.Add("ToDate")
                dt_h.Columns.Add("G")
                dt_h.Columns.Add("A")
                dt_h.Columns.Add("F")
                dt_r = New Data.DataTable("ROWS")
                dt_r.Columns.Add("Key")
                dt_r.Columns.Add("Arquivo")
                dt_r.Columns.Add("DataLancamento")
                dt_r.Columns.Add("TipoDocumento")
                dt_r.Columns.Add("Conta")
                dt_r.Columns.Add("Debito")
                dt_r.Columns.Add("Credito")
                dt_r.Columns.Add("NumExterno")
                dt_r.Columns.Add("DataDocumento")
                dt_r.Columns.Add("DataVencimento")
                dt_r.Columns.Add("Detalhes")
                '#### Fill HEADER fields
                With oForm.DataSources.UserDataSources
                    drh = dt_h.NewRow()
                    drh("Key") = "1"
                    drh("Empresa") = oCompany.CompanyName
                    drh("DiaryCod") = .Item("DSDiaryCod").ValueEx
                    drh("DiaryNam") = .Item("DSDiaryNam").ValueEx
                    If .Item("DSFromNum").ValueEx = "" Then
                        drh("FromNum") = "0"
                    Else
                        drh("FromNum") = DateFromDS(oApplication, .Item("DSFromNum").ValueEx)
                    End If
                    If .Item("DSToNum").ValueEx = "" Then
                        drh("ToNum") = "0"
                    Else
                        drh("ToNum") = DateFromDS(oApplication, .Item("DSToNum").ValueEx)
                    End If
                    If .Item("DSFromDate").ValueEx = "" Then
                        drh("FromDate") = "0"
                    Else
                        drh("FromDate") = DateFromDS(oApplication, .Item("DSFromDate").ValueEx)
                    End If
                    If .Item("DSToDate").ValueEx = "" Then
                        drh("ToDate") = "0"
                    Else
                        drh("ToDate") = DateFromDS(oApplication, .Item("DSToDate").ValueEx)
                    End If
                    drh("G") = .Item("DSGeneral").ValueEx
                    drh("A") = .Item("DSAnalitic").ValueEx
                    drh("F") = .Item("DSCashFlow").ValueEx
                End With
                dt_h.Rows.Add(drh)
                Dim creditString As String = ""
                Dim oBP As SAPbobsCOM.BusinessPartners
                oBP.CreditLimit = IIf(creditString = "", 0.0, Convert.ToDouble(creditString))
                (continues)
    Hope it helps,
    Regards,
    Vítor Vieira

  • SBO B1 2005 SP 01 Patch 11 - Issues with recordsets.

    Hi,
    We are using ‘recordset’ for Query all over our application. I have performance problems when I upgraded to SP01 Patch 11. Recordset retrieves the data fast but takes very very long time when I do movenext() or eof() or movefirst().
    Here is a sample code:
    Dim rs As SAPbobsCOM.Recordset = Query (sqlStmt)
                ' If no record is fetched, returns false which indicates the finding failed
                rs.MoveFirst()
                If rs.EoF() Then Return False
                ' Caches the object columns
                CacheColumns(rs)
                ' Releases the referenced object
                rs = Nothing
    The whole process takes long time. So I debugged the code. The delay is at MoveFirst() and eof() stage. If I comment these 2 steps, it is faster. But I have to use the recordset functions. 
    IT WAS VERY QUICK IN SBO 2005 before upgrading the sp01 patch 11. Am I missing something? Is something changed in SP01? I am using Recordset to query on user tables only.
    Please somebody help me out.
    Regards,
    Prakash

    Does this bug also affect the GetByKey method? Because I am developing an addon, and all of a sudden it starts to hang. I did upgrade to PL11 during the development. I have been going insane trying to figure out what made my program stop working, and I even back-tracked numerous revisions. In the end, it is the following code that made the difference:
    oDocs = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
                            strSQL = "Select DocEntry from ORDR where DocNum = '" + strDocNum + "'"
    oRecs = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                        oRecs.DoQuery(strSQL)
                        strDocEntry = oRecs.Fields.Item("DocEntry").Value
                        If oDocs.GetByKey(strDocEntry) Then
    oDocs.UserFields.Fields.Item("U_MyField").Value = strValue
    end if
    If I comment out the last if statement with GetByKey, it seems to be fine. If I leave it in, it hangs when I click the "Update" button on the Sales Order form. The database I'm working on has thousands of order records. Could it be caused by the bug since it's a large volume of records to go through? We also use record sets all over the place. It also doesn't make sense to me that in other areas it seems to work ok.

  • A bug! -1120 Ref count for this object is higher then 0

    Hello experts!
    the following code makes an error -1120 Ref count for this object is higher then 0
    but the next code doesn't ...
    who is attentively enough, can find the difference. (is commened out)
    please fix the bug.
    static class Program
            static void Main()
                SAPbouiCOM.SboGuiApi SboGuiApi;
                string sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
                SboGuiApi = new SAPbouiCOM.SboGuiApi();
                SboGuiApi.Connect(sConnectionString);
               SAPbouiCOM.Application app = SboGuiApi.GetApplication(-1);
                SAPbobsCOM.Company comp = app.Company.GetDICompany() as SAPbobsCOM.Company;
               rs = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
               SAPbobsCOM.UserTablesMD userTable = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;
                userTable.TableName = "MSB_SL";
                userTable.TableDescription = "TableName";
                userTable.TableType = SAPbobsCOM.BoUTBTableType.bott_MasterData;
                int i = userTable.Add();
                Application.Run();
    static class Program
            static void Main()
                SAPbouiCOM.SboGuiApi SboGuiApi;
                string sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
                SboGuiApi = new SAPbouiCOM.SboGuiApi();
                SboGuiApi.Connect(sConnectionString);
               SAPbouiCOM.Application app = SboGuiApi.GetApplication(-1);
                SAPbobsCOM.Company comp = app.Company.GetDICompany() as SAPbobsCOM.Company;
        // // // rs = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
               SAPbobsCOM.UserTablesMD userTable = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;
                userTable.TableName = "MSB_SL";
                userTable.TableDescription = "TableName";
                userTable.TableType = SAPbobsCOM.BoUTBTableType.bott_MasterData;
                int i = userTable.Add();
                Application.Run();
    Best Regards,
    Alexander Friesen

    Hello
    Remove the following line:
    rs = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
    You have created the rs object from ocompany. You would like to execute a query maybe over a table which will be added later on (in your code in the next lines), so who would handle this?
    Remember, the SAP B1 Gui is reconnects (re-reads) when you creating an UDF/UDT/UDO on a database where multiple users logged in.
    Not a bug, 2007 version working like this:
    So always the 1st step is the creation of Tables
    If a table has been created, you must reconnect the DI API !
    Then, every other operation, declaration, object values could come.
    Older versions of SAP B1 was working in a different way: way enabling the creation of UDT/UDO/UDFs in One rutin. I was caused a lot's of problems.
    Regards
    J.
    Edited by: János Nagy on Jun 1, 2010 4:26 PM

  • SAPbobsCOM.Contacts attatchment.Count always 0

    Hi,
    im Working with sboContacts (Activities in SBo)
    I intend to handle with attachments in Activities.
    Before i add a new Attatchment i have to check, if there ist already one.
    The attachments.count returns 0, even though there are attachments existing.
    Snippet----
         SAPbobsCOM.Contacts sboContacts;
         sboContacts = (SAPbobsCOM.Contacts) company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oContacts);
         SAPbobsCOM.Recordset aktRecs = sboEntry.getSBOCompany().getRecsetBySelect(
            "select ClgCode from oclg where cardcode = 'C1050' and docnum = 174 and doctype = 17");
         if ( aktRecs.RecordCount > 0 )
            sboContacts.Browser.Recordset = aktRecs;
              log.Debug("CardCode: " + sboContacts.CardCode + " ContactCode: " + sboContacts.ContactCode +
               " Docnum: " + sboContacts.DocNum + " DocTypeEx: " + sboContacts.DocTypeEx);
            SAPbobsCOM.Attachments aktAttachments = sboContacts.Attachments;
            log.Info("anzahl Attachments: " + aktAttachments.Count);
    Snippet----
    Version: Business One 2004A 6.70.189 SP:00 PL:29
    As a workaround it´s possible to check the attachments wich DB-Selects...
    regards Matthias Lakämper

    Hi,
    now i solved it on this way but....
    "select Attachment from oclg where cardcode = 'C1050' and docnum = 174 and doctype = 17")
    this returns a list of attachments delimited by ';'
    --- always add a new Attachment and add all old and new items
    string [] dbAttAr = dbAttachments.Split(new Char [] {';'});
    for ( int iLauf = 0; iLauf < dbAttAr.Length; iLauf++)
         aktAttachments.Add();
         aktAttachments.Item(iLauf).FileName = dbAttAr[iLauf];
    if ( inNewAttachment != null )
         aktAttachments.Add();
         aktAttachments.Item(dbAttAr.Length).FileName = inNewAttachment;
    A curious behavior is the following:
    When i add an attachment using the GUI (Button "Durchsuchen"),
    e.g. from a Path: c:/temp/file.txt this file is copied to
    '.../SAP Manage/SAP Business One/Attachments/file.txt
    When i add an attachment with the API the path keeps the value
    "C:/temp/file.txt" and the "Anzeigen"-Button works. This effect is exactly what i need.
    Is this different behavior a bug or a feature ?
    regards

  • Recordset INSERT and exceptions

    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.

    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

  • Help , How to get data from database using recordset with UI API

    I want to get a data from database
    when I want to create recordset i notice that UI API didn't has record set
    so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
    ======================================================
    Dim oCompanyUI As SAPbouiCOM.Company <<UI API
    Dim oRecSet As New SAPbobsCOM.Recordset << DI API
    Dim oCompanyDI As New SAPbobsCOM.Company << DI API
    '=====================================================
    oCompanyDI.Connect
    Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
    oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
    SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
    ======================================================
    but I got an error it said "you are not connected to company"
    I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
    can someone help me please, I really need it
    Thanks

    you need a single sign on
            Dim oDICompany As SAPbobsCOM.Company
            Dim sCookie As String
            Dim sConnStr As String
            Dim ret As Integer
            oDICompany = New SAPbobsCOM.Company
            sCookie = oDICompany.GetContextCookie
            sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
            If oDICompany.Connected Then
                oDICompany.Disconnect()
            End If
            ret = oDICompany.SetSboLoginContext(sConnStr)
            If Not ret = 0 Then
                SBO_Application.MessageBox("set Login Context failed!")
                Exit Sub
            End If
            ret = oDICompany.Connect()
            If Not ret = 0 Then
                SBO_Application.MessageBox("Company Connect failed!")
            End If

  • SAPbobsCOM.BoObjectTypes.BoRecordset

    Hi Experts,
    I am new to SAP Business One SDK, I created a this code :
    Dim oRecordSet As SAPbobsCOM.Recordset
    Dim oItem1 As SAPbouiCOM.EditText = oForm.Items.Item("Item_1").Specific
    oRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
    oRecordSet.DoQuery("SELECT TOP 1 T0.[DocID] FROM [dbo].[@Testtable]  T0 ORDER BY T0.[DocID] DESC")
    If oRecordSet.RecordCount > 0 Then
          oItem1.Value = oRecordSet.Fields.Item(0).Value
    Else
          oItem1.Value = 1
    End If
    I have a clean database and it has no record at all. It gives me a correct value in my first testing but when I try to truncate my table it give me other record number. please help me about what does SAPbobsCOM.BoObjectTypes.BoRecordset do.

    this is the script in my sql
    CREATE TABLE [dbo].[@Testtable](
       [ID] [int] NOT NULL,
        [DocEntry] [int] NOT NULL,
        [DocNum] [int] NULL,
    CONSTRAINT [Testtable] PRIMARY KEY CLUSTERED
        [ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    Im still trying to figuring it out.

  • Recordset.DoQuery?

    Anyone know why I can't Execute the Following SQL in Recordset.DoQuery? Always returns COM Exception. Runs fine in SSMS, also there are no sub queries in the Select line.
    Any help is deeply appreciated,
    Mike
    SELECT ROW_NUMBER() OVER (ORDER BY SJ.JOBID) As [#], SJ.SUBJOBID, SJ.ENTEREDDATE, ST.DESCRIPTION AS [STATUS], SJ.JOBTITLE , JL.QUOTELINETYPE, JL.STOCKCODE, JL.DESCRIPTION, JL.QTY, JL.AVECOST, CASE JL.LINETYPE    WHEN 'Q' THEN   CASE Z.DIRECTRATE WHEN 'Y' THEN CASE JL.QUOTELINETYPE    WHEN 'H' THEN ROUND(ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.FXCOSTAFTERDISCOUNT * ISNULL(COSTFXRATE, 1), Z.SUMDEC)    ELSE ROUND(JL.QTY * JL.FXCOSTAFTERDISCOUNT * ISNULL(COSTFXRATE, 1), Z.SUMDEC) END ELSE CASE JL.QUOTELINETYPE    WHEN 'H' THEN ROUND((ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.FXCOSTAFTERDISCOUNT) / ISNULL(COSTFXRATE, 1), Z.SUMDEC)    ELSE ROUND((JL.QTY * JL.FXCOSTAFTERDISCOUNT) / ISNULL(COSTFXRATE, 1), Z.SUMDEC) END   END    ELSE ROUND(JL.QTY * JL.AVECOST, Z.SUMDEC) END AS [TOTALCOST], JL.OrigSellPr As [ORIGSELLPR], CASE    WHEN  JL.LINETYPE = 'Q' AND  JL.QUOTELINETYPE = 'H' THEN ROUND(ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.ORIGSELLPR * (1 - (JL.LINEDISCOUNT / 100)),Z.SUMDEC)    ELSE ROUND(JL.QTY * JL.ORIGSELLPR * (1 - (JL.LINEDISCOUNT / 100)), Z.SUMDEC) END AS [TOTALSALE], ISNULL(SJ.ACTIVE, 'N') AS ACTIVE, JL.CONTRACTLINESEQNO, JL.U_OM_Contract As [CTC] FROM ENPRISE_JOBCOST_JOBLINES  JL LEFT JOIN OADM Z ON Z.PRICEDEC != -999 LEFT JOIN ENPRISE_JOBCOST_SUBJOB SJ ON SJ.SUBJOBID =  JL.SUBJOBID LEFT JOIN ENPRISE_JOBCOST_JOB J ON J.JOBID = SJ.JOBID LEFT JOIN ENPRISE_JOBCOST_STATUS ST ON ST.SEQNO = SJ.STATUS Where LINETYPE = 'Q' And J.JOBID = 11900

    Hi folks, thanks so much for your replies! I have changed the query as you suggested. Unfortunately, I am still having no success? Could it be the Date format? Is there something special about how SAP handles Dates?
    Appreciate your input,
    Mike
    Code:
    Dim oRecordSet As SAPbobsCOM.Recordset = OMComp.GetBusinessObject(BoObjectTypes.BoRecordset)           
    oRecordSet.DoQuery(sSQL)
    The modified query is:
    SELECT Convert(Int,ROW_NUMBER() Over (Order By SJ.SUBJOBID)) As [ROWNO], SJ.SUBJOBID, Convert(Date,SJ.ENTEREDDATE) As [Entered Date], ST.DESCRIPTION AS [SUBJOB STATUSDESC], SJ.JOBTITLE , JL.QUOTELINETYPE, JL.STOCKCODE, JL.DESCRIPTION, JL.QTY, JL.AVECOST As [Item Cost], CASE JL.LINETYPE    WHEN 'Q' THEN   CASE Z.DIRECTRATE WHEN 'Y' THEN CASE JL.QUOTELINETYPE    WHEN 'H' THEN ROUND(ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.FXCOSTAFTERDISCOUNT * ISNULL(COSTFXRATE, 1), Z.SUMDEC)    ELSE ROUND(JL.QTY * JL.FXCOSTAFTERDISCOUNT * ISNULL(COSTFXRATE, 1), Z.SUMDEC) END ELSE CASE JL.QUOTELINETYPE    WHEN 'H' THEN ROUND((ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.FXCOSTAFTERDISCOUNT) / ISNULL(COSTFXRATE, 1), Z.SUMDEC)    ELSE ROUND((JL.QTY * JL.FXCOSTAFTERDISCOUNT) / ISNULL(COSTFXRATE, 1), Z.SUMDEC) END   END    ELSE ROUND(JL.QTY * JL.AVECOST, Z.SUMDEC) END AS [Total Cost], JL.OrigSellPr As [Unit Price], CASE    WHEN  JL.LINETYPE = 'Q' AND  JL.QUOTELINETYPE = 'H' THEN ROUND(ISNULL(JL.HIRE_PERIODS, 1) * JL.QTY * JL.ORIGSELLPR * (1 - (JL.LINEDISCOUNT / 100)),Z.SUMDEC)    ELSE ROUND(JL.QTY * JL.ORIGSELLPR * (1 - (JL.LINEDISCOUNT / 100)), Z.SUMDEC) END AS [Total Sale], ISNULL(SJ.ACTIVE, 'N') AS SUBJOB_ACTIVE, JL.CONTRACTLINESEQNO, JL.U_OM_Contract As [CTC Flag] FROM ENPRISE_JOBCOST_JOBLINES  JL LEFT JOIN OADM Z ON Z.PRICEDEC != -999 LEFT JOIN ENPRISE_JOBCOST_SUBJOB SJ ON SJ.SUBJOBID =  JL.SUBJOBID LEFT JOIN ENPRISE_JOBCOST_JOB J ON J.JOBID = SJ.JOBID LEFT JOIN ENPRISE_JOBCOST_STATUS ST ON ST.SEQNO = SJ.STATUS Where LINETYPE = 'Q' And J.JOBID = 11900
    Images of errors:

  • Where i will get SAPbobsCOM.dll

    Hi every body
        Iam very new to ERP. Recently i have started working on Making Add-On for SBO using .net. I got a bit good femiliery with UI, But iam stucked at DI.
       I have instaled SDK.  With that i got only SAPbouiCOM.exe. In many samples which i downloaded from net is reffering the SAPbobsCOM.dll.
       Please some body let me know. wether the SDK what i have is older version or what?. Please let me know where i will get SAPbobsCOM.dll
    Thanks in Advance
    regards

    I guess you have more code between
    Public oCompany As SAPbobsCOM.Company
    and
    oRecordSet = oCompany.GetCompanyList
    because it can't work like this. It has to be something like
    Dim oCompany As SAPbobsCOM.Company
    oCompany = New SAPbobsCOM.Company
    oCompany.Server = "(local)"
    oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English
    oCompany.UseTrusted = True
    Dim oRecordSet As SAPbobsCOM.Recordset
    oRecordSet = oCompany.GetCompanyList

  • RecordSet message: Must Declare Table Variable

    Hi
    I am trying to read a table using a RecordSet
    Private oRecordSet As SAPbobsCOM.Recordset
    Dim oSqlString As String = "Select U_tno, U_cpro from @MX_N301"
    Try
            oRecordSet.DoQuery(oSqlString)
    Catch ex As Exception
    And ex receives the next message:[Microsoft][ODBC SQL Server Driver][SQL Server]Must declate table variable "@MX_N301"
    Can anybody tell me why I receive this message and what else do I have to do?
    Thanks a lot

    Hi Alberto,
    for tables with  @ you need brackets !
    "Select U_tno, U_cpro from [@MX_N301]"
    regards
    David

  • Capturing the creation of an invoice by jpeg or PDF.

    Hello all.
    Im trying to write an add on that takes an invoice before it printed and capture the file or image (or pdf) of that invoice by using UI API.
    1. is it possible ?
    2. if not by extracting the data using getdata method how do i know if its draft (112) or invoice (13) cant find that property.
    3. if needed to create my own pdf does the XML should look like this ? and is there a dictionary to understand the tags?
    <?xml version="1.0" encoding="utf-16"?>
    <!-- 
         Item Types Legend
         NullType = 0
         Page Header = 1
         Report Header = 2
         Repetitive Header = 3
         Repetitive Body = 4
         Repetitive Footer = 5
         Report Footer = 6
         Page Footer = 7
         Item = 13
         Content Types Legend
         Text = 1
         Variable = 2
         Database = 3
         Formula = 4
           -->
    <Document>
      <Pages>
        <Page>
          <Area Type="1" Id="F_001">
            <Item Type="13" Id="F_142               " Value="CUST. NO."></Item>
            <Item Type="13" Id="F_137               " Value="INV. DATE"></Item>
            <Item Type="13" Id="F_136               " Value="APPLY TO"></Item>
            <Item Type="13" Id="F_127               " Value="INVOICE NO."></Item>
            <Item Type="13" Id="F_190               " Value="OEC Computers"></Item>
            <Item Type="13" Id="F_100               " Value="C20000"></Item>
            <Item Type="13" Id="F_175               " Value="01/05/2010"></Item>
            <Item Type="13" Id="F_155               " Value=""></Item>
            <Item Type="13" Id="F_010               " Value="89"></Item>
            <Item Type="13" Id="F_189               " Value="1901 Maynesboro Drive&#xD;Suite 200&#xD;New York NY  19065&#xD;USA(610) 768-7465"></Item>
            <Item Type="13" Id="F_177               " Value=""></Item>
            <Item Type="13" Id="F_176               " Value=""></Item>
            <Item Type="13" Id="F_128               " Value="INVOICE"></Item>
            <Item Type="13" Id="F_103               " Value="1"></Item>
            <Item Type="13" Id="F_147               " Value="BO"></Item>
            <Item Type="13" Id="F_141               " Value="WORK ORDER NO."></Item>
            <Item Type="13" Id="F_139               " Value="PAGE NO."></Item>
            <Item Type="13" Id="F_203               " Value="Original"></Item>
            <Item Type="13" Id="F_171               " Value="S H I P  T O"></Item>
            <Item Type="13" Id="F_170               " Value="S O L D  T O"></Item>
            <Item Type="13" Id="F_186               " Value="Ship to"></Item>
            <Item Type="13" Id="F_009               " Value="Norm Thompson"></Item>
            <Item Type="13" Id="F_174               " Value="300 Billings Drive&#xD;Suite 500&#xD;Havertown PA  19083&#xD;USA"></Item>
            <Item Type="13" Id="F_012               " Value="300 Billings Drive&#xD;Suite 500&#xD;Havertown PA  19083&#xD;USA"></Item>
            <Item Type="13" Id="F_113               " Value="TERMS"></Item>
            <Item Type="13" Id="F_112               " Value="F.O.B."></Item>
            <Item Type="13" Id="F_111               " Value="SHIP VIA"></Item>
            <Item Type="13" Id="F_110               " Value="PURCHASE ORDER NO."></Item>
            <Item Type="13" Id="F_109               " Value="DUE DATE"></Item>
            <Item Type="13" Id="F_034               " Value="2P10Net30"></Item>
            <Item Type="13" Id="F_162               " Value=""></Item>
            <Item Type="13" Id="F_108               " Value="UPS Ground"></Item>
            <Item Type="13" Id="F_101               " Value=""></Item>
            <Item Type="13" Id="F_059               " Value="02/04/2010"></Item>
            <Item Type="13" Id="F_118               " Value="TERRITORY"></Item>
            <Item Type="13" Id="F_117               " Value="SALESPERSON"></Item>
            <Item Type="13" Id="F_116               " Value="LOCATION"></Item>
            <Item Type="13" Id="F_115               " Value="DATE REQUESTED"></Item>
            <Item Type="13" Id="F_114               " Value="BUYER"></Item>
            <Item Type="13" Id="F_163               " Value=""></Item>
            <Item Type="13" Id="F_047               " Value="Sales Manager"></Item>
            <Item Type="13" Id="F_164               " Value=""></Item>
            <Item Type="13" Id="F_106               " Value=""></Item>
            <Item Type="13" Id="F_165               " Value="Norm Thompson"></Item>
          </Area>
          <RepetitiveArea index="1">
            <Area Type="3" Id="F_017">
              <Item Type="13" Id="F_124               " Value="EXTENSION"></Item>
              <Item Type="13" Id="F_123               " Value="UNIT PRICE"></Item>
              <Item Type="13" Id="F_223               " Value="Qty Shipped"></Item>
              <Item Type="13" Id="F_224               " Value="Backorder"></Item>
              <Item Type="13" Id="F_121               " Value="QTY ORDER"></Item>
              <Item Type="13" Id="F_120               " Value="Description"></Item>
              <Item Type="13" Id="F_119               " Value="ITEM NO."></Item>
            </Area>
            <Area Type="4" Id="F_022">
              <Rows>
                <Row>
                  <Item Type="13" Id="F_025               " Value="$ 3,000.00"></Item>
                  <Item Type="13" Id="F_198               " Value="$ 600.00"></Item>
                  <Item Type="13" Id="F_225               " Value="5.000"></Item>
                  <Item Type="13" Id="F_226               " Value="0.000"></Item>
                  <Item Type="13" Id="F_191               " Value="5.000"></Item>
                  <Item Type="13" Id="F_023               " Value="IBM Infoprint 1312"></Item>
                  <Item Type="13" Id="F_087               " Value="A00001"></Item>
                </Row>
                <Row>
                  <Item Type="13" Id="F_025               " Value="$ 1,500.00"></Item>
                  <Item Type="13" Id="F_198               " Value="$ 300.00"></Item>
                  <Item Type="13" Id="F_225               " Value="5.000"></Item>
                  <Item Type="13" Id="F_226               " Value="0.000"></Item>
                  <Item Type="13" Id="F_191               " Value="5.000"></Item>
                  <Item Type="13" Id="F_023               " Value="IBM Infoprint 1222"></Item>
                  <Item Type="13" Id="F_087               " Value="A00002"></Item>
                </Row>
                <Row>
                  <Item Type="13" Id="F_025               " Value="$ 2,250.00"></Item>
                  <Item Type="13" Id="F_198               " Value="$ 450.00"></Item>
                  <Item Type="13" Id="F_225               " Value="5.000"></Item>
                  <Item Type="13" Id="F_226               " Value="0.000"></Item>
                  <Item Type="13" Id="F_191               " Value="5.000"></Item>
                  <Item Type="13" Id="F_023               " Value="IBM Infoprint 1226"></Item>
                  <Item Type="13" Id="F_087               " Value="A00003"></Item>
                </Row>
                <Row>
                  <Item Type="13" Id="F_025               " Value="$ 3,750.00"></Item>
                  <Item Type="13" Id="F_198               " Value="$ 750.00"></Item>
                  <Item Type="13" Id="F_225               " Value="5.000"></Item>
                  <Item Type="13" Id="F_226               " Value="0.000"></Item>
                  <Item Type="13" Id="F_191               " Value="5.000"></Item>
                  <Item Type="13" Id="F_023               " Value="HP Color Laser Jet 5"></Item>
                  <Item Type="13" Id="F_087               " Value="A00004"></Item>
                </Row>
                <Row>
                  <Item Type="13" Id="F_025               " Value="$ 3,000.00"></Item>
                  <Item Type="13" Id="F_198               " Value="$ 600.00"></Item>
                  <Item Type="13" Id="F_225               " Value="5.000"></Item>
                  <Item Type="13" Id="F_226               " Value="0.000"></Item>
                  <Item Type="13" Id="F_191               " Value="5.000"></Item>
                  <Item Type="13" Id="F_023               " Value="HP Color Laser Jet 4"></Item>
                  <Item Type="13" Id="F_087               " Value="A00005"></Item>
                </Row>
              </Rows>
            </Area>
            <Area Type="5" Id="F_027"></Area>
          </RepetitiveArea>
          <Area Type="6" Id="F_091">
            <Item Type="13" Id="F_217               " Value="REMARKS"></Item>
            <Item Type="13" Id="F_216               " Value="&quot;� ����� ���� 1."></Item>
          </Area>
          <Area Type="7" Id="F_063">
            <Item Type="13" Id="F_215               " Value="DEPOSIT"></Item>
            <Item Type="13" Id="F_179               " Value="Tax"></Item>
            <Item Type="13" Id="F_180               " Value="DISCOUNT"></Item>
            <Item Type="13" Id="F_178               " Value="SUBTOTAL"></Item>
            <Item Type="13" Id="F_196               " Value="$ 14,310.00"></Item>
            <Item Type="13" Id="F_214               " Value=""></Item>
            <Item Type="13" Id="F_199               " Value="$ 810.00"></Item>
            <Item Type="13" Id="F_200               " Value=""></Item>
            <Item Type="13" Id="F_201               " Value="$ 13,500.00"></Item>
            <Item Type="13" Id="F_168               " Value="PLEASE REMIT THIS AMOUNT"></Item>
            <Item Type="13" Id="F_125               " Value="INVOICE NO."></Item>
            <Item Type="13" Id="F_105               " Value="89"></Item>
          </Area>
        </Page>
      </Pages>
    </Document>
    thanks in advance.

    Hi Guys i am on the my brink of destruction here ....
    i was able to extrct the A/R invoice Data like this.
    query = "SELECT DocEntry FROM OINV WHERE DocNum = 55";
                            rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                            rs.DoQuery(query);
                            Console.WriteLine("aantal regels {0}", rs.RecordCount);
                            if (rs.RecordCount > 0)
                                string tmp = rs.Fields.Item(0).Value.ToString();
                                SAPbobsCOM.Documents oDoc;
                                oDoc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
                                oDoc.GetByKey((int)rs.Fields.Item(0).Value);
                                if (oDoc.Printed == PrintStatusEnum.psNo)
                                    printeventInfo.MarkAsPrinted();
                                    oDoc.SaveToFile(@"C:\Dev\Beehive\Testforsap\SapBusinessOneAdaptor\SapBusinessOneAdaptor\bin\Debug\tmp.xml");
                                    string tmp1 = oDoc.GetAsXML();
    can i use this data to create pdf file with crystal report using the user template of this invoice ?
    some code would be nice
    a smile will be given to the helper
    thanks
    Guy

Maybe you are looking for

  • I connect my iphone to my laptop and my iphone wont open to my itunes HELP!

    i connect my iphone to my laptop, and my iphone wont open to my itunes! help !!!

  • Sql query join with transpose

    i have two tables table A and table B, both these tables are associated with id column . And the table B might have variant properties for each id i.e as shown in the below example id "1" having 4 properties and id "2" having 7 properties and id "3"

  • How can we find out list of patches applied to hyperion products

    Hi, How can we find out list of patches applied to hyperion products like HFM, Essbase, HFR..etc If we can go ahead with Opatch, Can any one please share the procedure of getting list of patches applied using this. Thanks in advance ARSV

  • Problems starting eclipse

    Eclipse does not start.The error message in the .log file is as follows: !SESSION 2006-04-04 18:25:25.469 ----------------------------------------------- eclipse.buildId=I20050627-1435 java.version=1.5.0_06 java.vendor=Sun Microsystems Inc. BootLoade

  • Boolean always returning false;

    Ok so i have this public static boolean testAuth(){           try{                BufferedReader authReader = new BufferedReader(new FileReader("auth.txt"));                String auth = authReader.readLine();                authReader.close();