Query Manager error

Hi guys,
I have the following query
/* SELECT FROM [dbo].[@EPARAMTABLE]  T0 */
declare @FromDate          as DATETIME
declare @ToDate             as DATETIME
/* WHERE */
set @fromDate                 = /* T0.U_fromdate */ '[%0]'
set @toDate       = /* T0.U_todate */ '[%1]'
select
                        'Purchase Invoice' as 'Document Type'
,                       t0.docdate as 'Document Date'
,                       t1.acctcode as 'G/L Account'
,                       t2.acctname as 'G/L Account Description'
,                       t1.ocrcode as 'Profit Centre Code'
,                       t3.prcname as 'Profit Centre Description'
,                       t1.freetxt as 'Freetext'
,                       '' as 'Transaction Code'
,                       t1.vatgroup as 'Tax Code'
,                       t0.docnum as 'Transaction Reference'
--,                       0 as 'Debit'
--,                       0 as 'Credit'
,                       t1.linetotal as 'Deb./Cred. (LC)'
,                       t1.U_eEmpID as 'Employee ID'
,                       t1.U_eVehicleRegNo as 'Vehicle Reg. No.'
,                       t1.U_eMaintAgree as 'Maintenance Agreement'
,                       t1.U_eLeaseAgreement as 'Lease Agreement'
,                       t1.U_ePropertyCodes as 'Property Code'
,                       t1.U_eRBS as 'RBS Code'
,                       t1.U_eE1Links as 'E1 Links'
,                       t1.U_eTel as 'Telephone Code'
,                       t1.U_eFax as 'Fax Code'
,                       t1.U_eDataConn as 'Data Connection Code'
from
                        opch t0 join pch1 t1 on t0.docentry = t1.docentry
                                    left outer join oact t2 on t2.acctcode = t1.acctcode
                                    left outer join oprc t3 on t3.prccode = t1.ocrcode
where
                              (T0.DocDate between @FromDate and @ToDate) OR (t2.acctcode between [%2] and [%3])
UNION ALL
select
                        'Purchase Credit Note'
,                       t0.docdate as 'Document Date'
,                       t1.acctcode as 'G/L Account'
,                       t2.acctname as 'G/L Account Description'
,                       t1.ocrcode as 'Profit Centre Code'
,                       t3.prcname as 'Profit Centre Description'
,                       t1.freetxt as 'Freetext'
,                       '' as 'Transaction Code'
,                       t1.vatgroup as 'Tax Code'
,                       t0.docnum as 'Transaction Reference'
--,                       0  as 'Debit'
--,                       0  as 'Credit'
,                       t1.linetotal as 'Row Total exc. VAT'
,                       t1.U_eEmpID as 'Employee ID'
,                       t1.U_eVehicleRegNo as 'Vehicle Reg. No.'
,                       t1.U_eMaintAgree as 'Maintenance Agreement'
,                       t1.U_eLeaseAgreement as 'Lease Agreement'
,                       t1.U_ePropertyCodes as 'Property Code'
,                       t1.U_eRBS as 'RBS Code'
,                       t1.U_eE1Links as 'E1 Links'
,                       t1.U_eTel as 'Telephone Code'
,                       t1.U_eFax as 'Fax Code'
,                       t1.U_eDataConn as 'Data Connection Code'
from
                        orpc t0 join rpc1 t1 on t0.docentry = t1.docentry
                                    left outer join oact t2 on t2.acctcode = t1.acctcode
                                    left outer join oprc t3 on t3.prccode = t1.ocrcode
where
                              (T0.DocDate between @FromDate and @ToDate) OR (t2.acctcode between [%2] and [%3])
UNION ALL
select
                        'Journal Entry'
,                       t0.refdate as 'Document Date'
,                       t1.account as 'G/L Account'
,                       t2.acctname as 'G/L Account Description'
,                       t1.profitcode as 'Profit Centre Code'
,                       t3.prcname as 'Profit Centre Description'
,                       t0.memo as 'Freetext'
,                       t0.transcode as 'Transaction Code'
,                       t1.vatgroup as 'Tax Code'
,                       t0.transid as 'Transaction Reference'
--,                       t1.debit
--,                       t1.credit
,                              t1.debit - t1.credit as 'Deb./Cred. (LC)'
--,                       0 as 'Row Total exc. VAT'
,                       t1.U_eEmpID as 'Employee ID'
,                       t1.U_eVehicleRegNo as 'Vehicle Reg. No.'
,                       t1.U_eMaintAgree as 'Maintenance Agreement'
,                       t1.U_eLeaseAgr as 'Lease Agreement'
,                       t1.U_eProperty as 'Property Code'
,                       t1.U_eRBS as 'RBS Code'
,                       t1.U_eE1Links as 'E1 Links'
,                       t1.U_eTel as 'Telephone Code'
,                       t1.U_eFax as 'Fax Code'
,                       t1.U_eDataConn as 'Data Connection Code'
from
                        ojdt t0 join jdt1 t1 on t0.transid = t1.transid
                                    left outer join oact t2 on t2.acctcode = t1.account
                                    left outer join oprc t3 on t3.prccode = t1.profitcode
where
                              (t0.transtype = 30) and (T0.RefDate between @FromDate and @ToDate)OR (t2.acctcode between [%2] and [%3])
order by
                              'Document Type'
,                              t0.docnum
The problem is that it is giving me "No matching records found 'Service Contracts' (OCTR)".  when I remove the acctcode part in the WHERE clause, it works fine.
Any idea what it might be please??

You have to add two more parameters on top of the query just like the date parameters. [%2\] and [%3\] will not work here.
Please close the other duplicate thread of yours.
Thanks,
Gordon
Edited by: Paulo Calado on Jun 12, 2009 5:21 PM

Similar Messages

  • Query Manager Input Date Problem

    Dear expert,
    When i paste the following code in query manager,
    error is encountered.
    What is the problem.
    Regards,
    Kit
    Code:
    declare @type int
    declare @opening DateTime
    declare @closing DateTime
    declate @tmp DateTime
    select @type = T0.ItmsGrpCod from [dbo].[oitb] T0 where T0.ItmsGrpNam = '[%0]'
    select distinct @opening = T1.DocDate from [dbo].[oinm] T1 where T1.DocDate ='[%1]'
    select distinct @closing = T2.DocDate from [dbo].[oinm] T2 where T2.DocDate = '[%2]'
    /* swap date */
    if @opening > @clsoing
    begin
    set @tmp = @opening
    set @opeing = @closing
    set @closing = @tmp
    end
    select  ItemCode , BatchNum,
         sum(Opening) as 'Opening',
         sum(InQty) as 'InQty',
         sum(OutQty) as 'OutQty',
         sum(Closing) as 'Closing',
         UnitCost ,
         sum(TotalClosingStock) as 'TotalClosingStock',
         sum(TotalOut) as 'TotalOut'
    from (
    select * from GetMovementReport(@type,@opening,@closing)
    union
    select * from GetSTMovementReport(@type,@opening,@closing)
    ) result
    group by ItemCode , BatchNum, UnitCost

    Hi Chun,
    I can see couple of spelling errors:
    1. declate @tmp DateTime must be: decla<b>r</b>e @tmp DateTime
    2. if @opening > @clsoing should be if @opening > @cl<b>os</b>ing
    3. set @opeing = @closing should be set @ope<b>n</b>ing = @closing
    Hope it helps,
    Adele

  • While Executing the Sp in Query manager Getting Error.

    hi.
    i need a small information.
    I Created a small table in Sql 
    ccode
    varchar
    no
    250
    cname
    varchar
    no
    250
    ctype
    varchar
    no
    250
    My Stored Procedure at  Sql
    i am inserting values in to the temporary table by using below one after passing the parameter
    i am executing the parameter is
    EXEC 'cardcode' ,'cardname' ,'c'
    if i execute the stored procedure in sql values are inserting  same thing i want to do in sap b1 at query maanger
    USE [WCTBRPLDB21-05-2014]
    GO
    /****** Object:  StoredProcedure [dbo].[uspGetAddress1]    Script Date: 8/1/2014 4:07:20 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER Procedure [dbo].[uspGetAddress1]
    @Cuscode varchar(250),
    @customertName VARCHAR(250) ,
    @custype varchar(250)
    As
    Begin
    DECLARE @Cur_Product CURSOR
    set @Cur_Product= cursor for select CardCode,CardName,CardType  from ocrd  where  CardCode =@Cuscode and   CardName= @customertName  and  cardtype =@custype
    open @Cur_Product
           fetch next
           from @Cur_Product into @Cuscode,@customertName,@custype
           while @@FETCH_STATUS = 0
           begin
           insert into custupdate (ccode,cname,ctype) values (@Cuscode,@customertName,@custype)
           fetch next
           from @Cur_Product into @Cuscode,@customertName,@custype
           end
           close @Cur_Product
           deallocate @Cur_Product
        select * from custupdate
    End
    @Cuscode varchar(250),
    @customertName VARCHAR(250) ,
    @custype varchar(250),
    select @Cuscode = T0.CARDCODE from OCRD T0 where T0.CARDCODE = '[%01]' AND
    select @CARDNAME = T0.CARDNAME from OCRD T0 where T0.CARDNAME = '[%02]' AND
    select @CARDTYPE = T0.CARDTYPE from OCRD T0 where T0.CARDTYPE = '[%03]'
    uspGetAddress1 @Cuscode ,@CARDNAME ,@CARDTYPE
    The above one i pasted at query manager.
    if i run it it is asking the parameters
    but after execute it
    i am getting the error that must declare the Scalar variable like that  it is showing.
    but i am all ready giving the scalar variable but it is not running.
    Any information plz update me
    is there any declaration problem in query  manager.....................

    Try below in query generator:
    Declare @Cuscode varchar(250),
    Declare @customertName VARCHAR(250) ,
    Declare @custype varchar(250)
    /*SELECT FROM [dbo].[OCRD] T0*/
    /* WHERE */
    SET @Cuscode = /* T0.CardCode */ '[%0]'
    /*SELECT FROM [dbo].[OCRD] T0*/
    /* WHERE */
    SET @customertName = /* T0.CardName */ '[%1]'
    /*SELECT FROM [dbo].[OCRD] T0*/
    /* WHERE */
    SET @custype = /* T0.CardType */ '[%2]'
    EXEC uspGetAddress1 @Cuscode,@customertName,@custype
    **Don't remove comments
    Thanks
    Navneet

  • What action do I take when this error warning appears? Whilst executing onClick in Media Query Manag

    What action do I take when this error warning appears? Whilst executing onClick in Media Query Manager.htm, the following JavaScript error ocurred: At line 157 of the file "Macintosh HD: Application: Adobe Dreamweaver CS5>5: Configuration Commands: Media Query Manager.js": getDocumentDOM: Argument nember 1 is invalid
    Thank you

    You'll get better answers in teh DW forum...
    Mylenium

  • Pass parameter to sql statement in query manager

    Hai to all,
               I want to pass the percentage  as the parameter into the sql statemnet.i what to execute it in the query manager.
              If i execute that statement then cann't found the tablename error is coming.
             Other than the data in the table (general data)  pass to the parameter in the sql at runtime.
    for example:
    select [%0] *100
    how to pass 10 to that sql statement.
    Please help me...
    Regards,
    Raji.

    Hi Ramya,
    You can create a SP with parameters to accept and then execut this SP from SAP Business One Query Manager by passing the parameter (in your case 10). The result will be as desired.
    Ex:
    Create this Procedure in SQL Management Studio
    create proc Test(@a as int)
    as
    begin
    select (@a*100)
    end
    To Execute the Query use this Query and pass the desired values with parameters
    execute Test 10
    Regards,
    Reno

  • Query Engine Error:

    Post Author: swordfish8
    CA Forum: General
    Hi, Many thank for taking the time to read this thread, the web application work on development box but fails when deployed.
    Please help, the problem is detailed below, cheers, Praveen
    Developed Environment
    Web Application Developed in VS .NET 2002
    Crystal Reports 9.0
    Set Up Package :
    Project Output: Primary Output and Content Files selected
    Merge Modules:        Database_Access.msm
                                           Database_Access_enu.msm
                                 Managed.msm
                                 Regwiz.msm
                                 VC_CRT.msm
                                 VC_STL.msm
    Code:
    mycommand.CommandText = "ASR_STATISTICS"
    mycommand.CommandType = CommandType.StoredProcedure
    With mycommand.Parameters
    .Add(New SqlParameter("@WeekStartDate", SqlDbType.DateTime)).Value =    _CDate(Me.txtDate.Text.Trim)
    .Add(New SqlParameter("@WeekEndDate", SqlDbType.DateTime)).Value = _
      CDate(Me.txtEndDate.Text.Trim)
    .Add(New SqlParameter("@Customer", SqlDbType.VarChar)).Value = _
               (Me.lstCustomer.SelectedItem.Value.Trim)
    End With
    Dim myDA As New SqlClient.SqlDataAdapter()
    myDA.SelectCommand = mycommand
    Dim myds As New Dataset1()
    myDA.Fill(myds, "ASR_STATISTICS")
    Dim oRpt As New crptStatistics()
    oRpt.SetDataSource(myds)
    Me.CrystalReportViewer.ReportSource = oRpt
    Installed the web application on the server
    Operating System: Windows Server 2003
    ERROR
    Server Error in '/ASDReports' Application.
    Query Engine Error: 'C:\WINDOWS\TEMP\temp_dff30854-29f4-4c4e-8fe0-66dbea4cd19b.rpt'
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: CrystalDecisions.CrystalReports.Engine.DataSourceException: Query Engine Error: 'C:\WINDOWS\TEMP\temp_dff30854-29f4-4c4e-8fe0-66dbea4cd19b.rpt'Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
    &#91;DataSourceException: Query Engine Error: 'C:\WINDOWS\TEMP\temp_dff30854-29f4-4c4e-8fe0-66dbea4cd19b.rpt'&#93;
        . K(String 
    , EngineExceptionErrorID   ) +514
        . F(Int16   , Int32   ) +493
       CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext) +462
       CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext) +201
       CrystalDecisions.Web.ReportAgent.v(Boolean  `) +137
       CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e) +99
       System.Web.UI.Control.PreRenderRecursiveInternal() +77
       System.Web.UI.Control.PreRenderRecursiveInternal() +161
       System.Web.UI.Control.PreRenderRecursiveInternal() +161
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
    Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

    Post Author: Bandit07
    CA Forum: Upgrading and Licensing
    I would go through and add in each criteria 1 at a time to see which one is causing the error. 

  • How to set paramters through Query manager.

    Hi,
    I need to get Parameters when we are executing SQL Query through Query Manager.
    In Query manager how to set prompt window for parameters.
    Below I applied parameters for from date and to date but its showing error. How to set parameters prompt window.
    SELECT     OJDT.TransId, OJDT.Number,NNM1.SeriesName,ojdt.baseref as BaseRefNumber, JDT1.Account,JDT1.StornoAcc,OACT.AcctName,jdt1.credit,jdt1.debit, jdt1.profitcode as [Customer/Vendor],JDT1.OcrCode2 as [Region/Location] , JDT1.OcrCode3 as  Department,
                          JDT1.OcrCode4 as [Core/Deputees/DailyWage/General], JDT1.OcrCode5 as [SubAccofCA&CL],OJDT.RefDate, OJDT.Project,jdt1.project
    FROM         OJDT
    INNER JOIN JDT1 ON OJDT.TransId = JDT1.TransId
    INNER  JOIN OACT on OACT.AcctCode=JDT1.Account
    INNER JOIN NNM1 ON OJDT.Series = NNM1.Series
    where ojdt.transType=30 and  ojdt.refdate >= '[%0]' AND ojdt.refdate <= '[%1]'
    Please guide me.
    Regds,
    Sampath kumar devunuri.

    hi sampath,
    Try this query
    SELECT T0.TransId, T0.Number,T3.SeriesName,T0.baseref as BaseRefNumber, T1.Account,T1.StornoAcc,T2.AcctName,T1.credit,T1.debit, T1.profitcode as CustomerVendor,T1.OcrCode2 as RegionLocation , T1.OcrCode3 as Department,
    T1.OcrCode4 as CoreDeputeesDailyWageGeneral, T1.OcrCode5 as SubAccofCACL,T0.RefDate, T0.Project,T1.project
    FROM dbo.OJDT T0
    INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId
    INNER JOIN OACT T2 on T2.AcctCode=T1.Account
    INNER JOIN NNM1 T3 ON T0.Series = T3.Series
    where
    T0.transType='30' and CAST(T0.refdate AS datetime) BETWEEN '[%0]' AND '[%1]'
    Jeyakanthan

  • Query Manager Issue

    Hello everybody.
    I'm having a problem with the Query Manager.
    If i put this query on the manager:
    Select * from [dbo].[OITM] where itemname = '[%0]'
    the variable don't show any imput box, and an error message appear on the StatusBar. The error haven't message.
    Thx,
    Sergio Alejandro Masolini

    Thx for the help, but i still having the error.
    The real query is:
    select * from (SELECT
    A.DOCENTRY as NroDocumento,
    max(A.DOCDATE) AS FECHA,
    max(CASE WHEN A.U_TGV_FLETTER = 'A' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '1'
    WHEN A.U_TGV_FLETTER = 'B' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '6'
    WHEN A.U_TGV_FLETTER = 'C' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '11'
    WHEN A.U_TGV_FLETTER = 'E' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '19'
    WHEN A.U_TGV_FLETTER = 'M' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '51'
    WHEN A.U_TGV_FLETTER = 'A' AND A.U_TGV_ACC_ORD_FLAC = 1 THEN '60'
    WHEN A.U_TGV_FLETTER = 'B' AND A.U_TGV_ACC_ORD_FLAC = 1 THEN '61'
    WHEN A.U_TGV_FLETTER = 'C' AND A.U_TGV_ACC_ORD_FLAC = 1 THEN '62' ELSE 'NA'
    END) AS TIPOCOMP,
    max(isnull(Convert(varchar,isnull(A.U_TGV_FOLIO_PREFIX,'0')) + '-' + Convert(varchar,A.folionum),'')) AS NUMCOMP,
    max(isnull(A.CARDNAME, '')) AS RAZONSOCIAL,
    max(Replace(LICTRADNUM,'-','')) AS CUIT,
    round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then 0 else case when b.vatprcnt = 0 then b.linetotal else 0 end end), 4) as NOGRAVEXCENTO,
    round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
    max(b.vatprcnt) as ALICUOTA,
    round(sum(b.vatsum),4) as IVA,
    round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
    max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
    max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
    '1' AS CONSULTA
    FROM [dbo].[OPCH]  A
    INNER JOIN [dbo].[PCH1]  B ON A.DOCENTRY = B.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
                                       group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
                                       group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
    INNER JOIN [dbo].[OITM] I on  b.ItemCode = I.ItemCode
    Where I.U_TGV_PERCEP_FLAG = 0
    group by a.DOCENTRY,  b.taxcode
    UNION ALL
    SELECT
    A.DOCENTRY as NroDocumento,
    max(A.DOCDATE) AS FECHA,
    max(CASE WHEN A.U_TGV_FLETTER = 'A' THEN '3'
    WHEN A.U_TGV_FLETTER = 'B' THEN '8'
    WHEN A.U_TGV_FLETTER = 'C' THEN '13'
    WHEN A.U_TGV_FLETTER = 'M' THEN '53'
    ELSE 'NA'
    END) AS TIPOCOMP,
    max(isnull(Convert(varchar,isnull(A.U_TGV_FOLIO_PREFIX,'0')) + '-' + Convert(varchar,A.folionum),'')) AS NUMCOMP,
    max(isnull(A.CARDNAME, '')) AS RAZONSOCIAL,
    max(Replace(LICTRADNUM,'-','')) AS CUIT,
    round(sum(case when b.vatprcnt = 0 then b.linetotal else 0 end), 4) as NOGRAVEXCENTO,
    round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
    max(b.vatprcnt) as ALICUOTA,
    round(sum(b.vatsum),4) as IVA,
    round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
    max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
    max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
    '1' AS CONSULTA
    FROM [dbo].[ORPC] A
    INNER JOIN [dbo].[RPC1] B ON A.DOCENTRY = B.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
                                       group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
                                       group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
    INNER JOIN [dbo].[OITM] I on  b.ItemCode = I.ItemCode
    Where I.U_TGV_PERCEP_FLAG = 0
    group by a.DOCENTRY,  b.taxcode
    UNION ALL
    SELECT max(TOT.C1) as NroDocumento,max(TOT.C2) as Fecha, max(TOT.C3), max(TOT.C4), max(TOT.C5),max(TOT.C6),sum(TOT.NOGRAVEXCENTO),sum(TOT.IMPGRAVADO),max(TOT.ALICUOTA),sum(TOT.IVA),sum(TOT.OPEXENTA),max(TOT.PERCIVA),max(TOT.PERCIIBB),max(TOT.CONSULTA) FROM
    SELECT
    '' AS C1,
    '' AS C2,
    '' AS C3,
    '' AS C4,
    '' AS C5,
    '' AS C6,
    round(sum(case when b.vatprcnt = 0 then b.linetotal else 0 end), 4) as NOGRAVEXCENTO,
    round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
    max(b.vatprcnt) as ALICUOTA,
    round(sum(b.vatsum),4) as IVA,
    round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
    max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
    max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
    '2' AS CONSULTA
    FROM [dbo].[OPCH] A
    INNER JOIN [dbo].[PCH1] B ON A.DOCENTRY = B.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
                                       group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
                                       group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
    INNER JOIN [dbo].[OITM] I on  b.ItemCode = I.ItemCode
    Where I.U_TGV_PERCEP_FLAG = 0
    group by b.taxcode
    UNION ALL
    SELECT
    '' AS C1,
    '' AS C2,
    '' AS C3,
    '' AS C4,
    '' AS C5,
    '' AS C6,
    round(sum(case when b.vatprcnt = 0 then b.linetotal else 0 end), 4) as NOGRAVEXCENTO,
    round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
    max(b.vatprcnt) as ALICUOTA,
    round(sum(b.vatsum),4) as IVA,
    round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
    max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
    max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
    '2' AS CONSULTA
    FROM [dbo].[ORPC] A
    INNER JOIN RPC1 AS B ON A.DOCENTRY = B.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
                                       group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
    LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
                                       INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
                                       INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
                                       WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
                                       group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
    INNER JOIN [dbo].[OITM] I on  b.ItemCode = I.ItemCode
    Where I.U_TGV_PERCEP_FLAG = 0
    group by b.taxcode
    ) TOT
    group by TOT.ALICUOTA) TOTGEN
    where TOTGEN.FECHA between '[%0]' and '[%0]'
    order by TOTGEN.consulta, TOTGEN.fecha, TOTGEN.nrodocumento
    someone can see the error?
    Edited by: Sergio Alejandro Masolini on Oct 22, 2008 8:31 PM

  • Query Manager SQL DateDiff and Parameter Problem

    I’m having trouble with a date calculation in the Query Manager.   I’m wondering if anyone has run into something similar.
    I am trying to write a query that returns records that are X days old, where X is a parameter input by the user.
    Here’s an example – you can paste this into your system and duplicate the issue:
    <b>SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where datediff(dd, T0.DocDueDate, getdate()) <= [%0]</b>
    Returns a date error code if you try to input an integer (e.g. the "Define Survey Variables" dialog is looking only for date values)
    However
    <b>SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where datediff(dd, T0.DocDueDate, getdate()) <= 30</b>
    Works just fine.
    Any ideas?

    > I tried your query and it's working perfection for
    > me.  I'm using  SBO B1 2005 A.
    >
    > The [%0] in your case is looking for the type of the
    > critary and because it sees T0.DocDueDate it thinks
    > you should give the query with a date and not a
    > numeric.  Maybe you cshould try to add a casting
    > function to return a numeric ?
    Merci Daniel,
    I too am using SBO B1 2005 A (PL 22)
    I should have expanded on my original problem.  I have tried using CAST and CONVERT in the following ways:
    <b>SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where datediff(dd, T0.DocDueDate, getdate()) <= CAST([%0] as Integer)
    SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where cast(datediff(dd, T0.DocDueDate, getdate())as Integer) <= [%0]
    </b>
    also
    <b>SELECT T0.DocNum, T0.DocDueDate, cast(datediff(dd, T0.DocDueDate, getdate())as Integer) as Date FROM ORDR T0 where Date <= [%1]</b>
    Nothing seems to work (although I could be getting the syntax wrong)

  • Procedure handle in Query  manager

    Sir,
    I want to execute the user stored procedure in query manager with the following statement
    " exec [Pr_AgingReport_NewN] '04/01/2009' , '03/27/2010','XYZ', null,'C',null "
    i am getting SAP Message & error as follow
    " 1).[Microsoft][SQL Native Client] Invalid cursor state "
    Thanks
    Rajesh B K

    Hi Rajesh,
    Try this,
    Select dbo.storedProcedure (parameters, if applicable)
    For example
    Select dbo.NumToWords (2152.00)
    Regards,
    Bala

  • Add parameters in store proc + query manager

    hello, i have a store procedure with 2 date parameter(begin and end), from addon tables. I want to execute from query manager, but, i have errors. I tried with :
    /* SELECT FROM dbo.beas_arbzeit T0 */
    DECLARE @FechaInicio AS datetime -- also date
    DECLARE @FechaFinal AS datetime -- also date
    /* WHERE */
    SET @FechaInicio = /* T0.anfZeit */ '[%0]'
    SET @FechaFinal = /* T0.anfZeit */ '[%1]'
    exec dbo.MyProcedureTest @FechaInicio, @FechaFinal
    -- FAILED. Error message:  'Document' (RDOC)
    Can you help me ? thanks.

    Hi,
    How did you store initial and final time on same field?
    SET @FechaInicio = /* T0.anfZeit */ '[%0]'
    SET @FechaFinal = /* T0.anfZeit */ '[%1]

  • Can not refresh server manager Error:0x8007045b

    OS: Windows 2012 R2 Core
    Services: Hyper V
    I was trying to remote reboot and the session hung. No worries I decided I could just reboot the next morning. So I rebooted the next day but when I go into server manager I get
    an errror can not refresh server manager Error:0x8007045b. Did some research found suggestions to fix it using a DISM.exe /Online /Cleanup-image /Restorehealth.
    But then I get an error 1115 A system Shutdown is in progress. I attempt to fix this issue using pskill winlogon but the issue pursistest. I have restarted the server several times now. Not sure how to fix this.
    Thanks in advance,
    Jake

    Hi,
    In addition to the above information,
    Checkout the below thread for similar discussion,
    http://social.technet.microsoft.com/forums/windowsserver/en-US/a700e9f6-4491-4c70-8bd0-d9d3111e2f70/windows-reboot-error
    Regards,
    Gopi
    JiJi
    Technologies

  • WIndows Server 2012 - Server Manager Error CLR20r3

    WIndows Server 2012 - Server Manager Error CLR20r3
    I have just experienced this error of ( CLR20r3) when trying to add or remove server roles.
    Server Manager crashes when trying to go into the Add/ Or Remove server roles
    What I have tried.
    .NET Diag
    .NET Fix
    Lots of research, and didn't find any resolution.
    Apparently this is not strictly tied to Windows Server 2012, as I see that Windows Server 2008 R2 , and even Windows desktop users have experienced this issue. With no direct resolution.
    Here is a screen shot for reference.......
    If anyone should obtain the MS Fix or hear of it, please post so that others who are experiencing this issue can find peace in their day.
    I have given up, ended up performing a reinstall. ( sadly)
    RF

    Hi RF,
    Based on your description, would you please refer to following operations and troubleshoot this issue?
    Please use
    Sytem File Checker tool to scan all protected system files.
    Please
    perform a clean boot to check if some third-party services affected.
    Please backup the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Ole. Then delete following two registry key (if exist): LeagcyImepersonationLevel and LegacyauthenticationLevel
    Then log off and logon and monitor the result.
    In addition, please navigate to %windir%\logs and check ServerManager and CBS log file if you can find some
    relevant errors.
    If any update, please feel free to let me know.
    Hope this helps.
    Best regards,
    Justin Gu

  • Log On to null  and  Plugin Manager error

    After installing BOE XI 3.1 Update and SAP Integration Kit 3.1, when attempting to log on to InfoView get a Log On to null showing up in the upper corner and when attempting to use SAP Authentication get:
    Account information not recognized: Plugin Manager error: Unable to locate the requested plugin secSAPR3 on the server. (FWB 00006)
    SAP Authentication doesn't show up in CMC either. Any ideas? Already checked SAP Java Connector.

    Here is the "README":
    wdeploy: Business Objects Deployment tool
    Objective: To deploy Business Objects web applications.
    Location of online deployment guides:
    BusinessObjects Enterprise XI 3.1 Web Application Deployment Guide for Windows
    BusinessObjects Enterprise XI 3.1 Web Application Deployment Guide for UNIX
    1. Go to http://help.sap.com
    2. Click on tab "Business Objects"
    Please note that you will need your SAP Service Marketplace USER ID and PASSWORD to access this material.
    If you do not have the necessary credentials contact your SAP support center.

  • See my query and error, see my query and error

    hi master
    sir i use inner query but not run
    please see my query with error
    query :==========
    select accid as acccode,fstatus, case when fstatus=1 then
    (select sum(drbal) from accbal where substr(accbal.accid,1,length(acccode))=acccode)
    end what
    from chartofacc
    error :========
    SQL> /
    (select sum(drbal) from accbal where substr(accbal.accid,1,length(acccode))=acccode)
    ERROR at line 2:
    ORA-00904: "ACCCODE": invalid identifier
    please sir give me any idea *

    Does this column ACCCODE exist in your table accbal?
    The columns in the outer query will not be visible in the inner query but the vise versa is true.

Maybe you are looking for

  • How do I add multiple faces to a slideshow on appleTV?

    I have had appleTV for about 2 years. Mainly use it for playing iTunes library from TV. I have always had a photo slideshow for a screen saver while playing tunes. Now that I have two children, I would like to add pictures of our recent addition usin

  • How do I get news stories I click from my Yahoo home page to open in a new tab?

    At one point, whenever I clicked on a news story on my Yahoo home page the story would open in a new tab, leaving the home page unchanged. When I updated Firefox, this feature was eliminated. Is there a way to turn it back on?

  • Help on invokelater and invokeandwait

    Hello, i am developing an application using swing API. in this application i have to read ceratin data from the database. and do operation on the data. what i want to do is to fetch data based on a query and display the data to the user in a JTable o

  • How to synchronize NI PXI-6534 and NI PXI-6259?

    Hi, I am trying to output a continuous analog waveform (sine, dc, ramp, etc) using an AIO card (6259) and a DO pulse (using the PXI DIO 6534 card) with a customizable Duty cycle in each period of the AO signal. I need them to be in sync. Both cards r

  • Client proxy.. passing internal table to output.

    Hi friends, I have created a proxy-JDBC scnario.. For this i created a datatype with 2 fields.. DT_Proxy_Outbound as complex type and 2 elements..and after that i have created a proxy class ZCO_MI_PROXY_OUTBOUND (Proxy class)   ZMT_PROXY_OUTBOUND(str