Query Generator

The thing is When we Generate a Query we get a result in the form of values assigned in '-' neagtive form,i.e., instead of branch name we get the result in Numbers and in these some are defined with negative values. Why is it so? P.S.the company was a demo one. is it because of that? and if so where are these values defined and how?

Hi Neel
If I understand your problem correctly then the negative no's you are getting when executing the query could be a no when no branch is defined for that row.
If you run a query on Sales Employees - Select * from OSLP you will note that the value -1 is for -No Sales Employee-.
To get the branch name instead of a no you must create a join between the tables. and use branch name instead of branch code.
Daan

Similar Messages

  • CAN WE HAVE IF CONDITION IN QUERY GENERATOR

    Hi friends,
    am, trying to make use of if condition to obtain a set of values in query generator.  Its possible to retrieve the required result set using query analyser but not in query generator.  am trying to execute the following query
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 1 and owor.itemcode = '100-100')
    begin
                    select itt1.u_reactor1 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 2 and owor.itemcode = '100-100')
    begin
         select itt1.u_reac_23 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 3 and owor.itemcode = '100-100')
    begin
         select itt1.u_reactor4 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    if it is not possible to write such query in query generator  can someone help me with a workaround solution.
    Thank u
    Vaitheeswaran

    Hi,
    I dont think Nested IF Statements are allowed in PLD. The reason that u get the result in Query analyser and not in Query Generator is that SAP supports Transact SQL and many SQL Server 2000 functions are not supported.
    However there is a work around in Print Layout Designer for using IF condition by having Linked Objects. Kindly see some tutorials regarding Linked fields available on SDN site and think of some other way of implementing this nested IF query.
    Regards
    Rizwan Hafeez
    Team Lead
    SAP Addon Development Section
    Abacus Consulting - Pakistan

  • How to do this in Query Generator?

    Dear Experts,
    Please check my following query I've written in Query Generator.
    /* select from dbo.OCRD t0 */
    declare @BP nvarchar(20)
    set @BP=/* t0.CardName */ '[%0]'
    declare @Dt1 datetime
    declare @Dt2 datetime
    set @Dt1=/* Start Date */ [%1]
    set Dt2=[%2]
    select distinct t1.po, Max(t1.supplier) Supplier,Max(t1.process) Process, Max(t1.OrderNo) OrderNo,Max(t1.Date) Date,
    isnull((select sum(t2.Quantity) from dbo.ir t2 where t2.po=t1.po and t2.TType<0),0) Issued,
    isnull((select sum(t3.Quantity) from dbo.ir t3 where t3.po=t1.po and t3.TType>0),0) Received,
    isnull((select sum(t2.Quantity) from dbo.ir t2 where t2.po=t1.po and t2.TType<0),0)-isnull((select sum(t3.Quantity) from dbo.ir t3 where t3.po=t1.po and t3.TType>0),0) Balance
    from dbo.ir t1 where t1.Supplier=@BP and (t1.Date>=@Dt1 and t1.Date<=@Dt2) group by t1.po
    The Query works well. But for the the lines
    set @Dt1=/* Start Date */ [%1]
    set Dt2=[%2]
    it displays BP Code as the prompt next the text boxes meant for inputting dates. I would like to display 'Start Date' and 'End Date' respectively for Dt1 and Dt2.
    Please explain me how to go about it.
    Thanks in advance.
    Regards
    Anand

    declare @Dt1 datetime
    set @Dt1=/* Start Date */ [%0]
    declare @Dt2 datetime
    set @Dt2=/* End Date */ [%1]
    /* select from dbo.OCRD t0 */
    declare @BP nvarchar(20)
    set @BP=/* t0.CardName */ '[%2]'
    I've changed. When I run the query the input box does not appear, the query shows only a blank table.
    Thanks
    Anand

  • Difference in Query generated by OBIEE for same report

    Hi,
    I am using a a report(X) in a filter condition.
    I am seeing a peculiar issue with OBIEE server. When i am running a report(X) alone, the query generated is different. But when i am using the same report in filter condition of other report(Y), the same report is generating some other query. The first report(X) is running fine but the second(Y) is not running at all.
    Case 1(Report X) Query: The report is breaking into 3 parts for different fact tables and combining the data to give result.
    Case 2(Report Y): A single query is being formed and within it is fecthing the data from different fact tables using subqueries.
    Case2 is creating a lot of problem as the performance is totally poor.
    Any suggesstions??
    Thanks
    Tataji

    Hi, we haven't debugged the application or traced the query against the production server (it's in our customer's office) buy I think there's no difference since the query itself has been tested using sqldeveloper against both servers (XE 11.2 and Enterprise 11.1) and the behavior is consistent. By consistent I mean:
    - The query executed via sqldeveloper against Oracle XE 11.2 runs ok and so does the application.
    - The query executed via sqldeveloper against Oracle Enterprise 11.1 fails with an ORA-01790 error, and so does the application (exceptions are being logged in the Event Log).
    To sum up: the same query runs ok in Oracle XE 11.2 and fails in Oracle Enterprise 11.1.
    Additional information: we have tried explicit casting the NULL literals to the corresponding data types (in the UNION ALLs) and the query works fine in both versions. ¿Is there an option in ODAC to tell the query generator to write this explicit castings?
    Regarding the DB schema and the LINQ query, I'll be sending them asap.
    Regards,
    Ernesto.

  • How to define the PLD of a Query generator report

    Hi All,
    I want to define the PLD of a Query Report. Currently I am Convertning it to Excel format. But my client wants it in PLD format.  so please tell me the process of defining the PLD for a Query generator Report.
    Thanks & Regards
    Pankaj Sharma.

    Hi,
    When u wrote yr query at that time save yr query
    Now yr query is save in "Query Manager"
    Open Query Manager > select yr query
    There is a button "Create Report"
    Create USer Report Window is display "define yr name" and select "Base Temple"
    once u save it double click and edit yr PLD....
    Hope it a best way to create uer PLD
    Thanks
    Kevin

  • Error in Query generator

    Dear all,
    I face an issue in Query generator.
    When i execute the query in query generator, the error is like this
    1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
    'Service Contracts' (OCTR)
    My query is like this
    Declare @StartYear as char(4)
    Declare @EndYear as char(4)
    Declare @Dept as char(3)
    Declare @UnitBusiness as char(3)
    Begin
    set @StartYear = (Select   YEAR(T0.[RefDate]) from JDT1 T0 where T0.[RefDate] = [%0] )
    set @EndYear =  (Select YEAR(T1.[RefDate]) from JDT1 T1 where T1.[RefDate] = [%1])
    set @Dept =  (Select T2.[Name] from OASC T2 where T2.[Name] = [%2])
    set @UnitBusiness = (Select   distinct SUBSTRING(T3.[Segment_0],10,2)  from OACT T3 where ( T3.[Segment_0] = [%3] OR ( 1 = (CASE WHEN [%3]  = 'All'  THEN 1 ELSE 2 END) ) ))
    Exec NEC_RPT_FinanceReport @StartYear,@EndYear,@Dept,@UnitBusiness
    End
    The problem is i can not show the input screen after i execute the query generator.
    If i remove the the Variable @Dept and replace with the value it runs well.
    Does any one know where is the problem ?
    Thanks in advance
    Regards
    Bodhi86

    HI Neetu, i have change the query without using store procedure
    my query is like this
    Declare @StartYear as char(4)
    Declare @EndYear as char(4)
    Declare @Dept as char(3)
    Declare @UnitBusiness as char(3)
    Begin
    set @StartYear = (Select   YEAR(T0.[RefDate]) from JDT1 T0 where T0.[RefDate] = [%0] )
    set @EndYear =  (Select YEAR(T1.[RefDate]) from JDT1 T1 where T1.[RefDate] = [%1])
    set @Dept =  (Select T2.[Name] from OASC T2 where T2.[Name] = [%2])
    set @UnitBusiness = (Select   distinct SUBSTRING(T3.[Segment_0],10,2)  from OACT T3 where ( T3.[Segment_0] = [%3] OR ( 1 = (CASE WHEN [%3]  = 'All'  THEN 1 ELSE 2 END) ) ))
    Select @StartYear,@EndYear,@Dept,@UnitBusiness
    The error is like this
    1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from.
    2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared.
    Can you help me
    Thanks in advance

  • Decimal places in Query generator

    Hi All,
    I am observing a weird behavior in Query generator's execution of a simple sql query. the query is :
    Select 0.002834
    now, in the general settings - display - amounts , I put the decimal value as 4 or 6,  then only it prints 0.0028 or 0.002834.
    else it prints 0.00 (if the decimal place is 2). it should ideally have nothing to do with the display of amount. any idea?
    (the effect is shown only after you change the decimal display, update it and close and reopen the SAP application.
    Thanks,
    Binita
    Edited by: Binita  Joshi on Apr 12, 2010 4:03 PM

    Hello Binita,
    >I have tried converting it to numeric(19,4) and numeric(19,6) but still the result was same.
    Check your decimal places settings in
    \Administration\System Initialization\General Settings\Display tab
    Check the following values:
    - Units (For meaurement)
    - Decimals in Query
    Now let' s say,
    - Unit set to 6 decimal places
    - Decimals in Query set to 2
    run the following query in query generator:
    select cast(0.000245 as decimal(19,6))
    result will be
    0.00
    run the same query as FMS on item master data in any measurement field (lenght)
    select cast(0.000245 as decimal(19,6))
    result will be
    0.000245
    Now set the - Decimals in Query set to 6 on  \Administration\System Initialization\General Settings\Display tab
    run the following query in query generator:
    select cast(0.000245 as decimal(19,6))
    result will be
    0.000245
    This is a normal habit of SAP B1 rounding engine / displaying engine.
    Regards
    J.

  • RUN Time error while use filter table in query generator

    Hai..
                   I have 2 Functions under "Scalar valued functions" in SQL Server,i try to call this functions in Query generator its working fine,result also display correctly, but i click filter table system showing  Error Message " Run Time Error,Abnormal program termination" then SAP is get closed,i tested this scenario in 3 Database am getting same error , Is this BUG in SAP B1?There is no error number in error message

    This is my function
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    -- =============================================
    -- Author:          <Author,,Name>
    -- Create date: <Create Date, ,>
    -- Description:     <Description, ,>
    -- =============================================
    ALTER function [dbo].[Get_TransObjName](@Obj_type NUMERIC(20,5))
    returns varchar(500) as
    BEGIN
    DECLARE @Obj_type_Name varchar(100)
    select @Obj_type_Name =
    case @Obj_type
    when     -2     then     'Opening Balance'
    when     -3     then     'Closing Balance'
    when     1     then     'oChartOfAccounts'
    when     2     then     'oBusinessPartners'
    when     3     then     'oBanks'
    when     4     then     'oItems'
    when     5     then     'oVatGroups'
    when     6     then     'oPriceLists'
    when     7     then     'oSpecialPrices'
    when     8     then     'oItemProperties'
    when     12     then     'oUsers'
    when     13     then     'A/R Invoices'
    when     14     then     'A/R Credit Memo'
    when     15     then     'A/R DeliveryNotes'
    when     16     then     'A/R Returns'
    when     17     then     'oOrders'
    when     18     then     'A/P Invoice'
    when     19     then     'A/P Credit Memo'
    when     20     then     'Goods Receipt PO'
    when     21     then     'Goods Returns'
    when     22     then     'PurchaseOrders'
    when     23     then     'Quotations'
    when     24     then     'IncomingPayments'
    when     25     then     'Deposit'
    when     28     then     'oJournalVouchers'
    when     30     then     'JournalEntries'
    when     31     then     'oStockTakings'
    when     33     then     'oContacts'
    when     36     then     'oCreditCards'
    when     37     then     'oCurrencyCodes'
    when     40     then     'oPaymentTermsTypes'
    when     42     then     'oBankPages'
    when     43     then     'oManufacturers'
    when     46     then     'VendorPayments'
    when     48     then     'oLandedCostsCodes'
    when     49     then     'oShippingTypes'
    when     50     then     'oLengthMeasures'
    when     51     then     'oWeightMeasures'
    when     52     then     'oItemGroups'
    when     53     then     'oSalesPersons'
    when     56     then     'oCustomsGroups'
    when     57     then     'ChecksforPayment'
    when     58     then     'Stock List'
    when     59     then     'Goods Receipt'
    when     60     then     'Goods Issue'
    when     64     then     'oWarehouses'
    when     65     then     'oCommissionGroups'
    when     66     then     'oProductTrees'
    when     67     then     'Inventory Transfers'
    when     68     then     'oWorkOrders'
    when     69     then     'Landed Costs'
    when     70     then     'oCreditPaymentMethods'
    when     71     then     'oCreditCardPayments'
    when     73     then     'oAlternateCatNum'
    when     76     then     'Postdated Deposit'
    when     77     then     'oBudget'
    when     78     then     'oBudgetDistribution'
    when     81     then     'oMessages'
    when     91     then     'oBudgetScenarios'
    when     97     then     'oSalesOpportunities'
    when     93     then     'oUserDefaultGroups'
    when     101     then     'oSalesStages'
    when     103     then     'oActivityTypes'
    when     104     then     'oActivityLocations'
    when     112     then     'oDrafts'
    when     116     then     'oDeductionTaxHierarchies'
    when     117     then     'oDeductionTaxGroups'
    when     125     then     'oAdditionalExpenses'
    when     126     then     'oSalesTaxAuthorities'
    when     127     then     'oSalesTaxAuthoritiesTypes'
    when     128     then     'oSalesTaxCodes'
    when     134     then     'oQueryCategories'
    when     138     then     'oFactoringIndicators'
    when     140     then     'oPaymentsDrafts'
    when     142     then     'oAccountSegmentations'
    when     143     then     'oAccountSegmentationCategories'
    when     144     then     'oWarehouseLocations'
    when     145     then     'oForms1099'
    when     146     then     'oInventoryCycles'
    when     147     then     'oWizardPaymentMethods'
    when     150     then     'oBPPriorities'
    when     151     then     'oDunningLetters'
    when     152     then     'oUserFields'
    when     153     then     'oUserTables'
    when     156     then     'oPickLists'
    when     158     then     'oPaymentRunExport'
    when     160     then     'oUserQueries'
    when     162     then     'Inventory Valuation'
    when     163     then     'oCorrectionPurchaseInvoice'
    when     164     then     'oCorrectionPurchaseInvoiceReversal'
    when     165     then     'oCorrectionInvoice'
    when     166     then     'oCorrectionInvoiceReversal'
    when     170     then     'oContractTemplates'
    when     171     then     'oEmployeesInfo'
    when     176     then     'oCustomerEquipmentCards'
    when     178     then     'oWithholdingTaxCodes'
    when     182     then     'oBillOfExchangeTransactions'
    when     189     then     'oKnowledgeBaseSolutions'
    when     190     then     'oServiceContracts'
    when     191     then     'oServiceCalls'
    when     193     then     'oUserKeys'
    when     194     then     'oQueue'
    when     198     then     'oSalesForecast'
    when     200     then     'oTerritories'
    when     201     then     'oIndustries'
    when     202     then     'oProductionOrders'
    when     203     then    'A/R Down Payment'
    when     204     then    'A/P Down Payment'
    when     205     then     'oPackagesTypes'
    when     206     then     'oUserObjectsMD'
    when     211     then     'oTeams'
    when     212     then     'oRelationships'
    when     214     then     'oUserPermissionTree'
    when     217     then     'oActivityStatus'
    when     218     then     'oChooseFromList'
    when     219     then     'oFormattedSearches'
    when     221     then     'oAttachments2'
    when     223     then     'oUserLanguages'
    when     224     then     'oMultiLanguageTranslations'
    when     229     then     'oDynamicSystemStrings'
    when     231     then     'oHouseBankAccounts'
    when     247     then     'oBusinessPlaces'
    when     250     then     'oLocalEra'
    when     280     then     'oSalesTaxInvoice'
    when     281     then     'oPurchaseTaxInvoice'
    when     300     then     'BoRecordset'
    when     305     then     'BoBridge'
    when     260     then     'oNotaFiscalUsage'
    when     258     then     'oNotaFiscalCFOP'
    when     259     then     'oNotaFiscalCST'
    when     261     then     'oClosingDateProcedure'
    when     10     then     'oBusinessPartnerGroups'
    when     278     then     'oBPFiscalRegistryID'
    else cast(@Obj_type as char(20)) end
    return @Obj_type_Name
    END

  • Query Generator Problem

    Hi, I'm having sounds like silly problem using Query Generator, if I execute this query it does not give me the 'selection list' for Fiscal Year. I'm using v8.8 PL10 but in v2007 it's working fine. If I use other table like OITM w/ fieldX =N'[%0]', its working in v8.8.
    SELECT T0.[Code], T0.[Name] FROM [dbo].[@BA_OAMD2]  T0 WHERE T0.[U_FisYear] =N'[%0]'
    thanks,
    Edited by: Jojo on Jan 8, 2011 4:55 PM
    Edited by: Jojo on Jan 8, 2011 4:56 PM

    Hi, I think the problem has nothing to do w/ the SQL, because if I run it in v2007 it works but not in v8.8.
    SELECT T0.[Code], T0.[Name] FROM [dbo].[@BA_OAMD2]  T0 WHERE T0.[U_FisYear] =[%0]
    creating inner join w/ OFPR and make where condition in OFPR.[Code] is   the alternative solution, but I want to use only the code above and let me have 'list selection'
    SELECT T0.* FROM [dbo].[@BA_OAMD2]  T0
    inner join OFPR T1 on T0.[U_FisYear] =T1.Code WHERE T1.[Code] =[%0]
    I have noticed that if I use UDT in my SQL w/ variable selection the option for 'list selection' and right click on selection criteria 'List of Items' is not working. I'm using v8.8 PL10, is it a bug?
    Edited by: Jojo on Jan 9, 2011 4:22 PM

  • Copy and Paste from SQL server to Query Generator eliminate spaces

    Hi:
    My query is run perfectly on SQL server.
    However, when I copied it to Query Generator in SAP B1, it can not be run. When I look closely I see that some spaces have been truncated for example between the fieldname and key words like FROM, LEFT OUTER JOIN. I have to then going through the Query Generator in SAP B1 to put in the spaces in appropriate places. This process took long time and require very close attention and did not make any sense to me, since my query already work in SQL server query manager.
    Is there any way that we can make Query Generator in SAP B1 keeping the same format (ie. not eliminate the spaces) as in SQL server Query Manager?
    Best Regards,
    Phong Nguyen.

    Here is what I mean:
    SELECT YEAR(T1.DocDate) YEAR_NO, DATEPART(wk,T1.DocDate) WEEK_NO,SUM(T1.LineTotal) TotalShrinkage_Sales, (SUM(T1.LineTotal)/SUM(T1.Total_Sales)) Percent_Shrinkage, SUM(T1.Total_Sales) Total_Sales,COUNT(DISTINCT T1.Shrinkage_No) Shrinkage_Volume, SUM(T1.TotalCost) TotalShrinkage_CostFROM (SELECT V0.ITEMCODE, V0.DocEntry Shrinkage_No, V0.DocDate, V0.LineTotal, 0 Total_Sales,  V0.TotalCostFROM dbo.V_SHRINKAGE_TOTAL V0 WHERE V0.TransType='Shrinkage'UNION ALLSELECT V1.ITEMCODE, null Shrinkage_No, V1.DocDate, 0 LineTotal, V1.LineTotal Total_Sales, 0 TotalCostFROM dbo.V_Sales_Invoice V1UNION ALLSELECT V2.ITEMCODE, null Shrinkage_No, V2.DocDate,0 LineTotal, V2.LineTotal Total_Sales, 0 TotalCost FROM dbo.V_Credit_Note V2) T1WHERE DATEDIFF(wk,T1.DocDate,getdate())<=12GROUP BY YEAR(T1.DocDate), DATEPART(wk,T1.DocDate)ORDER BY YEAR(T1.DocDate) ASC,DATEPART(wk,T1.DocDate) ASC
    You can see the the third line (top down) the space between the field TotalShrinkage_Cost and FROM has been eliminated.
    Also you can see that on the 4th line (top down) the space between the field  V0.TotalCost and FROM has been eliminated.
    Also in the 5th line (top down) you can see: V0.TransType='Shrinkage'UNION ALLSELECT --- spaces have been eliminated between 'Shrinkage" and UNION and ALL and SELECT
    The list can go on.
    Can you help there?
    Thanks,
    Phong Nguyen.

  • Update multiple UDF from one query generator

    Hi All,
    I have Form1 with multiple UDF1 which have been key in by users
    And another Form2 with multiple UDF2 which exactly same with Form1 UDF1
    Is there a way that I can copy multiple UDF at Form2UDF2 from Form1UDF1 instead of creating query for each individual UDF, where in query generator I can select more the one column but only first column will be insert to the single UDF.
    Thanks

    Hi Firos,
    I mean I have 7UDF in the Payment Form where the information to this UDF are come from 7UDF in the invoice form which already created previously so I would like to copy those UDF from invoice to UDF in payment by using single query to capture all the UDF information by doing:
    SELECT T0.[DocNum], T0.[UDF1], T0.[UDF2], T0.[UDF3], T0.[UDF4], T0.[UDF5], T0.[UDF6], T0.[UDF7]
    FROM OINV T0 WHERE T0.[CardCode] = $[ORCT.CardCode]
    From above query can I pass the result directly to UDF in Payment Form? or I need to create one query for each individual UDF.
    Thanks

  • Using Variables in Query generator

    I'm using the following query to pull a report together later to be used in a query print layout. When i specify the specific part number and customer code it returns what i expect but as soon as i add a variable it says "Must specify table"!
    SELECT T0.U_ACI_CAPT, T0.U_ACI_VDS1, T0.U_ACI_VDE1, T0.U_ACI_VSS1, T0.U_ACI_VSE1, T0.U_ACI_VDS2, T0.U_ACI_VDE2, T0.U_ACI_VSS2, T0.U_ACI_VSE2, T0.U_ACI_KWT1, T0.U_ACI_KWT2, T0.U_ACI_SPD1, T0.U_ACI_SPD2, T0.U_ACI_RNC1, T0.U_ACI_RNC2, T0.U_ACI_RNC3, T0.U_ACI_RNC4, T1.ItemCode, T1.Substitute, T0.U_ACI_VDS3, T0.U_ACI_VDE3, T0.U_ACI_VSS3, T0.U_ACI_VSE3, T0.U_ACI_KWT3, T0.U_ACI_SPD3, T0.U_ACI_RNC5, T0.U_ACI_RNC6, T0.U_ACI_ACDC, T0.U_ACI_PHSE, T0.U_ACI_50HZ, T0.U_ACI_60HZ, T0.U_ACI_OFRQ
    FROM   ((OSCN T1 INNER JOIN ITT1 T2 ON T1.ItemCode = T2.Father) INNER JOIN ITT1 T3 ON T2.Code = T3.Father) INNER JOIN "@ACI_MRBK" T0 ON T3.Code = T0.U_ItemCode
    WHERE T1.ItemCode = '[%0]' AND T1.CardCode = '[%1]'
    Anyone know how to get these things working?

    Hi,
    if your problem is similar with this symptom :
    Using SAP Business One Survey Variables (parameters) in a 'Set' SQL Statement can give an error in the Query Generator.
    here the solution I've got from SAP notes:
    In such cases you need to put in an SQL remark statement a reference field in the DB for the Survey Variable (any field).
    For Example: (to make the above query work)
    Declare @Num as numeric(2)
    Set @Num = /* T0.DocNum */ [%0]
    Select T0.DocNum
    From ORDR T0
    Where docnum = @Num
    Good luck
    Rgds,,

  • SQL Statement needed for Query Generator

    Dear Experts,
    My view has the following three columns.
    1, Start Date
    2. End Date
    3. Balance.
    I need an SQL statement to write in query generator, which has to check if EndDate is less than the Current date and balance is above zero. If so, it assumes the last date of the job is already over, outstanding materials not yet been returned. Hence it has to return 'Pending'. If EndDate is greater than current date, it means final date for completion of the process is yet to come. So the task is in progress, hence it has to return 'Progress'. If the balance is Zero, all materials connected with the task have been received either as a FG or as Raw Materials. So it has to return, 'Completed'. I need a singe SQL Statement for this.
    Please help me.
    Thanks in advance.
    Regards
    Anand

    Dear Anand,
    Try this one:
    CASE balance WHEN 0 THEN 'Completed' ELSE CASE WHEN DATEDIFF(DD, EndDate, GetDate()) >= 0 THEN 'Progress' ELSE 'Pending' END END
    I have assumed you don't have negative balance.  It that is not true, give me the complete case.
    Thanks,
    Gordon
    Thanks,
    Gordon

  • Declarations in SAP QUERY generated ABAP Programs

    hi,
    i had created a ABAP Program through ABAP Query (SQ01,SQ02,SQ03) but i have a issue that when i transport it to the PRD server i got the run time error. The Z program which i had created is the copy of the SQ01 generated program and i had done all the includes declarations in this program. but there is a problem that it is consist of the declarations of the structures,quries .
    I want to know is it necessary to always transport the Infoset and user group and the structure which is present in the program generated .
    Please provide me guidelines for this problem  .
    Edited by: ricx .s on Jul 6, 2009 5:31 AM
    Edited by: ricx .s on Jul 6, 2009 8:07 AM

    hi,
    i had copied the program bcoz i want to chekc that it is really necessary to transport the user group and infoset so that it can achieve functionality similar to the SAP QUERY.
    is there any other way without whichi can ahieve the functionality of SAP QUERY generated program and take it into the ABAP Porgram?

  • Qyery problem in query generator

    Hi friends,
    I have one problem regarding query generator.
    I want to take the field value from the active form for query generator. I got in the demo that u have to use $[table.field]. But still I got the error.
    Query which I tried.
    SELECT 'TRUE' FROM OCRD T0 WHERE $[OCRD.CardCode] = '[%0]'
    any one who take the value from active form as a parameter and pass to the query in the query generator please send my the sample query.
    Thanks in advance.

    hi,
    Thanks for your reply.
    When I try to execute the first query from the query generator I got the error.
    Error :-
    Incorrect syntax near $4.0.0
    statement 'Received Alerts' could not be prepared.
    When I try to execute the second query from the query generator I got the error.
    Error :-
    Incorrect syntax near 'Ocrd.cardcode'
    Statement 'Search function (CSHS)' could not bne prepared.
    What would be the reason.
    Please help me in solving this problem.

  • Must specift the table to select from error in query generator.

    SELECT OPCH.CardCode,OPCH.CardName, DateName(month,OPCH.TaxDate) + '-' + DateName(year,OPCH.TaxDate) As [Year],OPCH.TransId as [JE Ref],'IN' As [DocType]
    ,OPCH.DocEntry As [Base DocEntry],OPCH.WTSUM As [Recieved Amount],((OPCH.WTSUM/110.3) * 100 ) As [Invoice Amount],((OPCH.WTSUM/110.3) * 100 * 0.1) As [Service Tax]
    ,((OPCH.WTSUM/110.3) * 100 * 0.002) As [Edu.Cess],((OPCH.WTSUM/110.3) * 100 * 0.001) As [S.H.Cess]
    ,((OPCH.WTSUM/110.3) * 100 * 0.1) + ((OPCH.WTSUM/110.3) * 100 * 0.002) + ((OPCH.WTSUM/110.3) * 100 * 0.001) As [Total Service Tax]
    FROM OPCH,PCH1
    WHERE OPCH.DocEntry = PCH1.DocEntry
    AND OPCH.WTSUM > 0
    And PCH1.TargetType <> '19'
    AND OPCH.DocDate >= [%0]
    AND OPCH.DocDate <= [%1]
    When i try to run this query in query generator system gives me error msg  as "Must specify table to select from" if i remove the last two lines
    " AND OPCH.DocDate >= [%0]
    AND OPCH.DocDate <= [%1] "
    it works fine in the query generator.
    can any one help in this regards,
    thanks,
    praveen

    Hai Praveen!
    This problem is because of [%0] in query.
    Declare @FromDate as datetime
    Declare @ToDate as datetime
    set @FromDate = (select min(opch.docdate) from opch where opch.docdate >= '[%0]')
    set @ToDate = (select max(opch.docdate) from opch where opch.docdate <= '[%1]')
    Use this query in first lines of ur query and write your query.
    SELECT OPCH.CardCode,OPCH.CardName, DateName(month,OPCH.TaxDate) + '-' + DateName(year,OPCH.TaxDate) As Year,OPCH.TransId as JE Ref,'IN' As DocType
    ,OPCH.DocEntry As Base DocEntry,OPCH.WTSUM As Recieved Amount,((OPCH.WTSUM/110.3) * 100 ) As Invoice Amount,((OPCH.WTSUM/110.3) * 100 * 0.1) As Service Tax
    ,((OPCH.WTSUM/110.3) * 100 * 0.002) As http://Edu.Cess,((OPCH.WTSUM/110.3) * 100 * 0.001) As http://S.H.Cess
    ,((OPCH.WTSUM/110.3) * 100 * 0.1) + ((OPCH.WTSUM/110.3) * 100 * 0.002) + ((OPCH.WTSUM/110.3) * 100 * 0.001) As Total Service Tax
    FROM OPCH,PCH1
    WHERE OPCH.DocEntry = PCH1.DocEntry
    AND OPCH.WTSUM > 0
    And PCH1.TargetType '19'
    AND OPCH.DocDate >= @FromDate
    AND OPCH.DocDate <= @ToDate
    Regards,
    Thanga Raj.K

Maybe you are looking for

  • How to use Final Cut pro with external hard drive?

    I have too little space on my computer so I have to use final cut pro x with an external hard drive, but whenever I have the hard drive plugged in and Final cut going, my computer goes very slow. I just upgraded to 16gb ram... but can't seem to run F

  • Error while calling FM : Function parameter "PE_LFA1" is unknown

    Dear Experts, I am trying to call a FM in my code, but somehow I am getting the following error .Please help ! My code is : DATA :  VENDOR_NO TYPE WSRS_SHVDST_RES-VENDOR_NO,         PE_LFA2 TYPE LFA1,         PE_ADDR2 TYPE BAPIADDR1,         PE_ADRPR

  • In which jar com.evermind.sql.DriverManagerDataSource located??

    in data-sources.xml when i changed the class from com.evermind.sql.DriverManagerDataSource to oracle.jdbc.pool.OracleDataSource i didnt get any exception in std_err log and also it didnt create any spy.log; when i put class="com.evermind.sql.DriverMa

  • Oracle 11g - ALU32UTF8 - Application Issue

    I currently migrated to 11g - and chose to use AL32UTF8 multibyte character set. This is a challange when the application using this DB is comunication with a third party application through MQ and flat files. Senacrio: A Column in a table in my DB i

  • Again FRM-41213: Unable to connect to Report Server

    Hi all I've been fighting with this problem a week, but I can not understand why my form, which works fine in the Oracle DS Report Server, can not run the report in the Oracle AS. I'm using the Oracle AS 10g. All forms and reports are done in the DS