Query for Deliveries by State

I have created the following query to list delivery line items by state.  It is working well but it is duplicating some of the line items.  Can anyone tell me why certain line items would be duplicated when running this query?
Thanks
SELECT 'Delivery' AS 'Type', T0.[CardCode] AS 'Business Partner Code', T0.[CardName] AS 'Business Partner Name', t6.[groupname],T5.[State], T0.[DocNum], T0.[DocDate], t1.[Quantity], T1.[ItemCode], t4.[itemname], T1.[LineTotal]  FROM ODLN T0  INNER JOIN DLN1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN OCRD T2 ON T0.CardCode = T2.CardCode LEFT OUTER JOIN OSLP T3 ON T2.SlpCode = T3.SlpCode inner join OITM T4 on T1.itemcode = t4.itemcode inner join crd1 t5 on t5.cardcode = t0.cardcode inner join ocrg t6 on t6.groupcode = t2.groupcode WHERE T0.[DocDate] >=[%0] AND  T0.[DocDate] <=[%1] and t5.[state] = '[%2]'
UNION ALL
SELECT 'Return' AS 'Type', T0.[CardCode], T0.[CardName], t6.[groupname], T5.[State], T0.[DocNum], T0.[DocDate], t1.[Quantity], T1.[ItemCode], t4.[itemname], T1.[LineTotal] FROM ORDN T0  INNER JOIN RDN1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN OCRD T2 ON T0.CardCode = T2.CardCode LEFT OUTER JOIN OSLP T3 ON T2.SlpCode = T3.SlpCode inner join oitm t4 on t1.itemcode = t4.itemcode inner join crd1 t5 on t5.cardcode = t0.cardcode inner join ocrg t6 on t6.groupcode = t2.groupcode WHERE T0.[DocDate] >=[%0] AND  T0.[DocDate] <=[%1]  and t5.[state] = '[%2]'

Hi,
Try this:
SELECT Distinct 'Delivery' AS 'Type', T0.CardCode AS 'Business Partner Code', T0.CardName AS 'Business Partner Name',
t6.groupname,T5.State, T0.DocNum, T0.DocDate, t1.Quantity, T1.ItemCode, t4.itemname, T1.LineTotal
FROM ODLN T0
INNER JOIN DLN1 T1 ON T0.DocEntry = T1.DocEntry
LEFT OUTER JOIN OCRD T2 ON T0.CardCode = T2.CardCode
LEFT OUTER JOIN OSLP T3 ON T2.SlpCode = T3.SlpCode
inner join OITM T4 on T1.itemcode = t4.itemcode
inner join crd1 t5 on t5.cardcode = t0.cardcode
inner join ocrg t6 on t6.groupcode = t2.groupcode
WHERE T0.DocDate >=[%0] AND T0.DocDate <=[%1] and t5.state = '[%2]'
Thanks,
Gordon

Similar Messages

  • Queries for deliveries

    Hi,
    I create a query for deliveries. And i would like when i display the list off deliveries i can display a specific delivery with a click in the delivery.
    How it's possible.
    Thanks.

    Hi Anil,
    The head count and termination count definition may change from organization to organization based on their rules. Please find below sample script which can give you an idea of the tables and you can design your based on client requirement.
    1. Employee joined between two dates
    select
    b.full_name,
    b.applicant_number,
    a.current_employer,
    d.name job,
    e.date_start Actual_DOJ,
    b.business_group_id
    from
    per_applications a,
    per_all_people_f b,
    per_all_assignments_f c,
    per_jobs d,
    per_periods_of_service e
    where 1=1
    and a.person_id(+) = b.person_id
    and b.person_id = c.person_id
    and trunc(sysdate) between b.effective_start_date and b.effective_end_date
    and trunc(sysdate) between c.effective_start_date and c.effective_end_date
    and C.JOB_ID = D.JOB_ID(+)
    and E.PERSON_ID = B.PERSON_ID
    and e.date_start between to_date('01-JAN-2013','DD-MON-YYYY') and to_date('31-JAN-2013','DD-MON-YYYY')
    2. Employees left between two dates
    select
    b.full_name,
    b.applicant_number,
    a.current_employer,
    d.name job,
    e.date_start Actual_DOJ,
    b.business_group_id
    from
    per_applications a,
    per_all_people_f b,
    per_all_assignments_f c,
    per_jobs d,
    per_periods_of_service e
    where 1=1
    and a.person_id(+) = b.person_id
    and b.person_id = c.person_id
    and trunc(sysdate) between b.effective_start_date and b.effective_end_date
    and trunc(sysdate) between c.effective_start_date and c.effective_end_date
    and C.JOB_ID = D.JOB_ID(+)
    and E.PERSON_ID = B.PERSON_ID
    and e.date_start between to_date('01-JAN-2013','DD-MON-YYYY') and to_date('31-JAN-2013','DD-MON-YYYY')
    Hope this helps you.
    Thanks,
    Sanjay

  • Re:Query for Stock Statement for a particular item..!!!!

    Dear SAP Experts,
    I need a stock statement query  for a particular item which contains:
    1.ItemCode
    2.Item Description
    3.Item Price
    4.Opening
    5.Receipts
    6.Issues
    7.Closing
    8. Value
    The selection criteria are:
    1.Warehouse code
    2.Item Name
    3.Posting Date
    Plz give me a good solution for this issue.
    With Regards,
    Revathy

    Check this
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    set @FromDate =
        (Select min(S0.Docdate) from OINM S0 where S0.Docdate >='[%0]')
    set @ToDate =
        (Select max(S1.Docdate) from OINM S1 where S1.Docdate <='[%1]')
    select * from
        SELECT T0.itemcode,
        min(T0.Dscription) as 'Item Description',
        min(B1.ItmsGrpNam) as 'Item Group', W1.Whscode, C1.Location,
        (isnull((
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate<@FromDate ),0)-
        isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate<@FromDate),0)
        ) as [Opening Stock],
        isnull((
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate
            and O1.docdate<=@ToDate and O1.inqty>0
            and O1.transtype in (20,18)),0
        ) as [Purchase Quantity],
        isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate and O1.docdate<=@ToDate
            and O1.outqty>0 and O1.transtype in (21,19)),0
        ) as [Purchase Return Quantity],
       isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.outqty>0
            and O1.transtype in (13,15)),0
        ) as [sale Quatity],
        (isnull
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate<=@ToDate),0
            isnull((
                Select sum(isnull(outqty,0))
                from OINM O1
                where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
                and O1.docdate<=@ToDate),0)
        ) as [Closing Stock]
        FROM OINM T0
        INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
        INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode
        INNER JOIN OITB B1 ON T1.ItmsGrpCod=B1.ItmsGrpCod
        INNER JOIN OWHS W1 ON T2.WhsCode = W1.WhsCode
        INNER JOIN OLCT C1 ON W1.Location=C1.Code
        Group by T1.itemcode, T0.Itemcode, W1.WhsCode, C1.Location
    ) a
    where (a.[Opening Stock]
            +a.[Purchase Quantity]
            + a.[Purchase Return Quantity]
            +a.[sale Quatity]+a.[Closing Stock]
           ) !=0
    Regards,
    Bala

  • How to query using CGI path for 'IN' sql statement

    Some problems that requires help:
    I have a report that requires a query which has 'IN' statement in SQL query. For example: SELECT EMP_ADDRESS1 FROM EMPLOYEE WHERE EMP_NO IN (:EMP_NO).
    I am going to query the result of this query using CGI. My peoblem starts here - I can't be passing a list of parameter for ':EMP_NO' because the path does not accept escape characters. I can't be put a query path below:
    <HTML>http://172.188.2.7/dev60cgi/rwcgi60.exe?server=9iAS&mode=default&destype=localfile&desformat=\\pri_wnt\generic&report=gcgd1.rdf&userid=comm/comm@employee<B>&emp_no='A','B','C'<B></HTML>
    What I am doing is that I will have a front end written in JAVA and display a listing of Employee available in the company. The user will be able to choose whatever employee on the front end. Then, I will call the CGI path to display the result to the user.
    Pls help. Kindly email personally([email protected]) or reply here.
    Thank you

    You'll need to escape your single quotes using %XX where XX is the hex code corresponding to the special character you want to use. I'm not sure what the escape code is for quotes. I know that if you wanted to have a space, this:
    ....../rwcgi60.exe?key+P_city='San Francisco'+....
    would need to look like:
    .../rwcgi60.exe?key+p_city=San%20Francisco+...
    You'll need to find out what the number for quote is. HOpe that helps a bit.
    Toby

  • What is the sql query for the real time reports Resource Stats?

    Does anyone know what the query is that the real time report tool uses for the Resource Stats page?  Trying to develop a custom report that displays similar information that is updated regularly.

    Hi,
    009 wrote:
    Hi Frank,
    Just wanted your opinion on the above given SQLI'm not sure I understand it.
    I added some more formatting to help me read it:
    SELECT      A
    ,     CASE WHEN LAG(A,1) OVER (ORDER BY A) IS NULL
              OR A=LAG(A,1) OVER (ORDER BY A)
              THEN LAG(B,1) OVER (ORDER BY A)
         END B_LAG
    ,     B
    FROM     (
         SELECT A, B
         FROM
              SELECT '1'A,'Apple' B FROM DUAL UNION ALL
              SELECT '1'A,'cat'B FROM DUAL UNION ALL
              SELECT '2'A,'bat'B FROM DUAL UNION ALL
              SELECT '3'A,'rat'B FROM DUAL UNION ALL
              SELECT '2'A,'yellow'B FROM DUAL UNION ALL
              SELECT '1'A,'pin'B FROM DUAL
         CONNECT BY PRIOR A=B
         ORDER BY A
    );What is the purpose of the CONNECT BY in what you have so far?
    Is the idea that you will add another CONNECT BY query, using
    CONNECT BY  b_lag  = PRIOR b?
    Do you think that will be better than using ROW_NUMBER?
    Will it work if (a, b) is not unique?

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • Return Code - Query for Multiple Rows as XML

    Hi,
    I'm executing an MSSQL stored procedure through the "Query for Multiple Rows as XML" activity in LiveCycle ES. I do this through a call statement such as this:
    { call MyStoredProc(?) }
    This works great, the stored procedure always returns a record set (with or without records). I use this activity rather than "Call Stored Procedure" because I can transform the record set into XML right away within this activity. Unfortunately any exception arising from invoking this stored procedure cannot be handled within the workflow as this activity does not have an exception handler (lightning bolt). In an attempt to handle at least some exceptions we have decided to use try/catches within the stored procedures and return different error codes. Now the problem I am faced with is that there is no way to retrieve the returned code within any of the SQL activities. We don't want to have to write an execute script for each of these SQL calls. Is there any way to do this? Seems like I'm 95% there.
    Thanks
    Nic

    Thanks for the offer, unfortunately we would need something certified by Adobe.
    Nic

  • Problem with query for Oracle

    Hello Experts,
    I'm tryng to develop my first application for EP (v7 SP12) with NWDS (without NWDI).
    This application has to read and write data in the EP DB (oracle v10).
    I'm using:
    <u>a Dictionary Project</u> (define the DB Tables)
    <u>a Java Project</u> (define class as DAO, DBManager etc)
    <u>a Library Project</u>
    <u>an EJB Project</u>
    <u>an EAR Project</u>
    With these projects I can deploy a <u>webService</u> in my EP server.
    BUT I have some problem with a query that I'm tryng to sent to my DB through a DAO Class called by my WebService.
    The query is simple and correct but it does not work...
    This is the error message returned (the query id in bold)
    (column names: GIORNO, NOMEDITTA, NOMEAREA, NOMESETTORE)
    <i>HTTP/1.1 500 Internal Server Error
    Connection: close
    Server: SAP J2EE Engine/7.00
    Content-Type: text/xml; charset=UTF-8
    Date: Fri, 21 Sep 2007 14:29:57 GMT
    Set-Cookie: <value is hidden>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>java.sql.SQLException: com.sap.sql.log.OpenSQLException: The SQL statement <b>"SELECT NOMESETTORE, MIN(? - "GIORNO") AS GIORNI FROM SRS_DATEINFORTUNI WHERE NOMEDITTA = ? AND NOMEAREA= ? GROUP BY NOMESETTORE ORDER BY NOMESETTORE"</b> <u>contains the syntax error[s]: - 1:25 - the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</u></faultstring><detail><ns1:getGiorniSettori_com.akhela.giorniSenzaInfortuni.ejb.exception.GiorniSenzaInfortuniException xmlns:ns1='urn:GiorniSenzaInfortuniWSWsd/GiorniSenzaInfortuniWSVi'></ns1:getGiorniSettori_com.akhela.giorniSenzaInfortuni.ejb.exception.GiorniSenzaInfortuniException></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope></i>
    The variable '?' is the today date, the difference <b>"(?-GIORNO)"</b> is an int..
    Moreover in my DAO class the query is <b>"SELECT NOMESETTORE, MIN(? - GIORNO) AS GIORNI FROM SRS_DATEINFORTUNI WHERE NOMEDITTA = ? AND NOMEAREA= ? GROUP BY NOMESETTORE ORDER BY NOMESETTORE</b>", instead in the error message is reported <b>MIN(? - "GIORNO")</b>...
    We have tryed also with alternative query, for example we used <b>"MIN(SYSDATA - GIORNO)"</b> but <b>SYSDATA</b> was interpreted as column name and  not found....
    Any help???
    Best Regards

    Hi, I found something about the Host Variable (http://help.sap.com/saphelp_nw70/helpdata/en/ed/dbf8b7823b084f80a6eb7ad43bdbb9/content.htm), there explain that if you want to use an host variable you have to put ':' as prefix..
    My problem is that <u>I need to extract the minimum of the subtraction between two dates:</u>
    Query <b>MIN(? - GIORNO)</b> --> <i>Error: the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</i>
    So I tried to use the ':' as indicated in the manual..
    <b>MIN:(? - GIORNO)</b> --> - <i>SQL syntax error: the token ":" was not expected here
                   - expecting LPAREN, found ':'</i>
    <b>MIN(:(? - GIORNO))</b> --> <i>- 1:25 - Open SQL syntax error: :PARAMETER not allowed
                   - 1:26 - SQL syntax error: the token "(" was not expected here
                   - 1:26 - expecting ID, found '('</i>
    Then I tried to avoid the MIN() function and I tried to do just the subtraction:
    <b>? - GIORNO</b> --><i> - 1:21 - the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</i>
    <b>:(? - GIORNO)</b> --> <i>- 1:21 - Open SQL syntax error: :PARAMETER not allowed
                - 1:22 - SQL syntax error: the token "(" was not expected here
                - 1:22 - expecting ID, found '('</i>
    <b>'2007-09-24' - GIORNO</b> --> <i>- 1:34 - SQL syntax error: first argument of operator "-" must be a number, date/time or interval
                     - 1:43 - SQL syntax error: arguments of operator "-" do not have correct types
                     - 1:43 - SQL syntax error: derived columns in SELECT list with AS must be values</i>
    <b>GIORNO - GIORNO</b> --> <i>- 1:21 - the group by list and the select list are inconsistent: the column >>"GIORNO"<< is neither grouped nor aggregated
                  - 1:30 - the group by list and the select list are inconsistent: the column >>"GIORNO"<< is neither grouped nor aggregated</i>
    Why these parts of query are not accepted???
    I don't understand why... I hope you can help me.
    Best Regards
    Alessandro

  • SAP Query for AR Aging Report

    Hello Gurus-
    I am trying to build a query for Aging report, and would like to include something like this:
    Customer-Reference-Payment terms-Due date-Current-31-60days-61-90days-91-120days-over120days-toatal amount.
    I have an infoset which includes BSID, KNA1, KNB1. I have maintained local fields:
    Due Date  =     Baseline date + cash discount days
    Statement Date = My input date.
    Current    = Condition (DUEDTE >= STATDTE - 30) formula (Amount)
    31 - 60 Days = Condition (DUEDTE >= STATDTE - 60 AND DUEDTE < STATDTE - 30) formula (Amount)
    61 - 90 Days = similar to above
    91 - 120 Days = similar to above
    Amount  = - 1 * (If Debit credit indicator = "H" then "Amount in local currency") otherwise "Amt in Loc.Cur"
    Over 120 Days = similar to above
    When I enter a statement date of today it works hunky dory...it all looks good...my current column looks good and do the rest. When i want to run this query as of couple of months ago (if today is 12/19/08 and i wanted to run my aging report for 10/31/08) it should give me aging as of my statement date 10/31/08 but it does not. It calculates the total amount as of today. I know because of local field "Amount" where i gave amount in local currency, but how would I tell that it should pick up amount in local currency till the statement date?
    Any input in this regards is highly helpful.
    Thanks,
    RNarayan

    Hi Ram,
    On your aging report you want to see invoices which are still not paid (or still open) as of a certain date. This date is "key date". You need to define a variable for key date (which is normally system date if you run today) but it could be a past date.
    So key date is let us say Oct 31st (X) and the system date is Dec 19th. When you run the report as of Oct 31st all invoices that are posted prior to Oct 31st (posting date less than X) and are still in BSID will show on your report. There is no issue here.
    Let us say an invoice was created on Oct 25th (Y) and was paid on Nov 15th (Z). The clearing date is Z. That means if you run the aging report today this invoice will not show.
    But you want to run the report on Oct 31st. This means X is greater than Y but is less than Z.
    Clearing date and posting date are part of BSAD. Report run date is the user input and is a variable.
    With the above concept and with the help of an ABAP programmer you should be able to solve the problem.
    Regards
    Sharabh

  • Query for details of  Sale order , Invoice and COGS

    I Need the report cointing following based on month & Business partner
    Sale order, Sale Amount, Due date, Invoice Amount, Last Invoice date, COGS amount

    Hi Anantha,
    Please check below link and modify according to your requirement.
    Sales Order Query for  in SAP B1
    Query - Sales Orders linked to Deliveries
    My Top SQL Queries for SAP Business One
    Hope this helps
    Regards::::
    Atul Chakraborty

  • Operations manager failed to run a wmi query for wmi events (0x800706ba)

    Hi everyone,
    I've been working on this issue for a while and I am still no closer to finding out what the problem is.  If anybody can offer any other advice or things to check, I'm all ears.
    I'm running SCOM 2012 R2 with UR2, and the Cluster Management Pack v6.0.7063.0
    My problem is on one particular batch of cluster servers where I am getting the following error.
    Name: Operations Manager failed to run a WMI query for WMI events
    Alert Description:
    Module was unable to enumerate the WMI data
    Error: 0x800706ba
    Details: The RPC server is unavailable
    Workflow name: Microsoft.Windows.Cluster.Node.StateMonitoring
    Instance Name: servername.domain.local
    Instance ID: {instance_id}
    Management group: SCOM_Management_Grp_Name
    I am getting this alert regardless of whether I run the Windows Cluster Action Account as Local System, or as a domain user with full local admin privileges on all the cluster nodes.
    When looking at the management pack and the workflow in particular (Microsoft.Windows.Cluster.Node.StateMonitoring), I can see that it's trying to access
    MSCluster_Node in the root\MSCLUSTER WMI namespace.
    This is the workflow for your information...
    <UnitMonitor> ID="Microsoft.Windows.Cluster.Node.StateMonitoring" Accessibility="Public" Enabled="onEssentialMonitoring" Target="ClusLibrary!Microsoft.Windows.Cluster.Node" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="ClusLibrary!Microsoft.Windows.Cluster.CheckState" ConfirmDelivery="false">
    <Category>AvailabilityHealth</Category>
    <AlertSettings AlertMessage="Microsoft.Windows.Cluster.Node.StateMonitoring.AlertMessage">
    <AlertOnState>Warning</AlertOnState>
    <AutoResolve>true</AutoResolve>
    <AlertPriority>Normal</AlertPriority>
    <AlertSeverity>MatchMonitorHealth</AlertSeverity>
    <AlertParameters>
    <AlertParameter1>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter1>
    <AlertParameter2>$Target/Property[Type="ClusLibrary!Microsoft.Windows.Cluster.Node"]/ClusterName$</AlertParameter2>
    </AlertParameters>
    </AlertSettings>
    <OperationalStates>
    <OperationalState ID="Success" MonitorTypeStateID="Online" HealthState="Success" />
    <OperationalState ID="Warning" MonitorTypeStateID="Partial" HealthState="Warning" />
    <OperationalState ID="Error" MonitorTypeStateID="NotOnline" HealthState="Error" />
    </OperationalStates>
    <Configuration>
    <ClusterObjectName>$Target/Property[Type='ClusLibrary!Microsoft.Windows.Cluster.Node']/NodeName$</ClusterObjectName>
    <PollInterval>60</PollInterval>
    <ClusterObjectClass>MSCLUSTER_Node</ClusterObjectClass>
    <OnlineExpression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='EventNewState']</XPathQuery>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
    <Value Type="String">0</Value>
    </ValueExpression>
    </SimpleExpression>
    </OnlineExpression>
    <OnlineExpressionOnDemand>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='State']</XPathQuery>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
    <Value Type="String">0</Value>
    </ValueExpression>
    </SimpleExpression>
    </OnlineExpressionOnDemand>
    <PartialExpression>
    <Or>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='EventNewState']</XPathQuery>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
    <Value Type="String">2</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='EventNewState']</XPathQuery>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
    <Value Type="String">3</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    </Or>
    </PartialExpression>
    <PartialExpressionOnDemand>
    <Or>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='State']</XPathQuery>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
    <Value Type="String">2</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='State']</XPathQuery>
    </ValueExpression>
    <Operator>Equal</Operator>
    <ValueExpression>
    <Value Type="String">3</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    </Or>
    </PartialExpressionOnDemand>
    <NotOnlineExpression>
    <And>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='EventNewState']</XPathQuery>
    </ValueExpression>
    <Operator>NotEqual</Operator>
    <ValueExpression>
    <Value Type="String">0</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='EventNewState']</XPathQuery>
    </ValueExpression>
    <Operator>NotEqual</Operator>
    <ValueExpression>
    <Value Type="String">2</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='EventNewState']</XPathQuery>
    </ValueExpression>
    <Operator>NotEqual</Operator>
    <ValueExpression>
    <Value Type="String">3</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    </And>
    </NotOnlineExpression>
    <NotOnlineExpressionOnDemand>
    <And>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='State']</XPathQuery>
    </ValueExpression>
    <Operator>NotEqual</Operator>
    <ValueExpression>
    <Value Type="String">0</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='State']</XPathQuery>
    </ValueExpression>
    <Operator>NotEqual</Operator>
    <ValueExpression>
    <Value Type="String">2</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    <Expression>
    <SimpleExpression>
    <ValueExpression>
    <XPathQuery Type="String">Property[@Name='State']</XPathQuery>
    </ValueExpression>
    <Operator>NotEqual</Operator>
    <ValueExpression>
    <Value Type="String">3</Value>
    </ValueExpression>
    </SimpleExpression>
    </Expression>
    </And>
    </NotOnlineExpressionOnDemand>
    <WMIFields>Name, State</WMIFields>
    </Configuration>
    </UnitMonitor>
    I can confirm that I am able to browse the MSCluster_Node class locally, as well as remotely using WMIEXPLORER and WBEMTEST,
    however it only works when I set the Authentication Level to
    Packet Privacy.  If I do not select Packet Privacy, a WMI event log error 5605 is logged on the remote servers application log that says...
    The root\mscluster namespace is marked with the RequiresEncryption flag.  Access to this namespace might be denied if the script or application does not have the appropriate authentication level.  Change the authentication level to Pkt_Privacy
    and run the script or application again.
    I can confirm that all firewalls are turned off, and there are no firewalls between the management servers and the agents in question.  AV exclusions have been done and appear to be in place.  The nodes are all Windows 2008 R2 with SP1.  As
    far as I can tell there is plenty of memory available on each of the nodes in question (50%+) of RAM is available. 
    If I manually run the "Discover the Windows Server 2008 R2 Cluster Components" task in the Cluster Service State section of the management pack in the Monitoring Pane in the console, on the nodes in question - the discovery runs successfully.
    Does anybody have any other ideas or suggestions I could try?
    Many thanks in advance,
    Noel.
    http://www.dreamension.net

    Hi,
    Common causes of RPC errors include:
    Errors resolving a DNS or NetBIOS name.
    The RPC service or related services may not be running.
    Problems with network connectivity.
    File and printer sharing is not enabled.
    For more information, please review the link below:
    Windows Server Troubleshooting: "The RPC server is unavailable"
    http://social.technet.microsoft.com/wiki/contents/articles/4494.windows-server-troubleshooting-the-rpc-server-is-unavailable.aspx#Identify
    Troubleshooting RPC Errors
    http://technet.microsoft.com/en-us/magazine/2007.07.howitworks.aspx
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Count() function throws error in EQL query for metric

    Hi
    I am trying to use count function in EQL query for Metric Bar to show the number of occurrences of a record.
    When the record type doesn't exist i expect the function to return count as 0. Instead the function throws a runtime exception and the whole Metric Bar portlet fails, with error No Results Available. Even though other components in the metric bar have valid results.
    2013-02-21 13:03:51,216 WARN [MetricsBarQueryProcessor] The EQL query does not return any results.
    2013-02-21 13:03:51,216 ERROR [MetricsBarQueryProcessor] The EQL query does not return any results.
    2013-02-21 13:03:51,216 WARN [MetricsBarResultsProcessor] No statement results to process.
    The EQL query i am using is
    RETURN NUMBER_OCCURS AS SELECT COUNT(EMP_ID) AS NUMBER_OCCURS where EMP_NAME IS NOT NULL group;
    I tried using COALESCE but that doesn't help.
    Can some one please suggest a workaround to this?

    Srikanth,
    Two statements are used here because the original question was pertaining to the null set (where there are employees in the nav state but no employees that fit the special analytics criteria in the navigation state). The question/answer has nothing to do with what is in the COUNT parentheses clause as Counting a null set will always give you NULL, not 0, no matter what you put in there.
    What we're really doing, in the second part of the query, is writing a query over a set of data that is not the null set (i.e. the current navigation state). This allows the 0 value to come through in the case where the first analytics statement is evaluated over a null set of records. If there were truly no records in the navigation state, this too would return a null set and not zero.
    Hope that makes sense, feel free to respond (either on here or offline) if it's unclear.
    Regards,
    Patrick Rafferty
    http://branchbird.com

  • Query for all hours in a month?

    Hello,
    I was hoping someone might be able to assist. I need to query for all the hours in a user specified date range (generally a month). For example,
    a query such as:
    select all hr_end from dual where start_date between '01-feb-2010' and '28-feb-2010'
    that returns:
    feb 01 2010 01:00
    feb 01 2010 02:00
    feb 01 2010 03:00
    feb 28 2010 23:00
    feb 28 2010 24:00
    Ideally, I want to be able to run this query within a WITH clause such that I can reference the temporary table/ list of hours in a subsequent select statement quickly. Something like:
    With
    all_hrs_in_month AS
    select .....
    where start_date between '01-mar-2010' and '31-mar-2010'
    I've looked around for similar questions, but have only found ones for all the 'days' in a month using level, connect by, row_num, for which I'm honestly not too familiar with and wasn't clear as to how I could modify to my needs.
    Greatly appreciate your help with this request.
    - j
    Edited by: user12942939 on Apr 5, 2010 12:04 PM

    Hi,
    Welcome to the forum!
    WITH     got_parameters  AS
         SELECT     TO_DATE ('01-mar-2010 00:00', 'dd-mon-yyyy hh24:mi')     AS start_date
         ,     TO_DATE ('31-mar-2010 23:00', 'dd-mon-yyyy hh24:mi')     AS end_date
         FROM     dual
    ,     all_hrs          AS
         SELECT     start_date + ( (LEVEL - 1)
                        / 24
                        )     AS hr
         FROM    got_parameters
         CONNECT BY     LEVEL <= 1 + ( 24
                                   * (end_date - start_date)
    SELECT       TO_CHAR (hr, 'DD-Mon-YYYY HH24:MI')     AS h
    FROM       all_hrs
    ORDER BY  hr
    ;Output:
    H
    01-Mar-2010 00:00
    01-Mar-2010 01:00
    01-Mar-2010 02:00
    01-Mar-2010 03:00
    31-Mar-2010 22:00
    31-Mar-2010 23:00Notice that start_date and end_date don't have to span then entire month; they don't even have to be in the same month.
    If you'd rather specify just one parameter (such as a single string containing the month and year):
    WITH     got_parameters  AS
         SELECT     TRUNC ( TO_DATE (:p_month, 'mon-yyyy')
                    , 'MONTH'
                    )          AS start_date
         ,     TRUNC ( ADD_MONTHS ( TO_DATE (:p_month, 'mon-yyyy')
                                 , 1
                    , 'MONTH'
                    )          AS end_date
         FROM     dual
    ,     all_hrs          AS
         SELECT     start_date + ( (LEVEL - 1)
                        / 24
                        )     AS hr
         FROM    got_parameters
         CONNECT BY     LEVEL <= ( 24          -- NOTE: Not adding 1 here
                               * (end_date - start_date)
    SELECT       TO_CHAR (hr, 'DD-Mon-YYYY HH24:MI')     AS h
    FROM       all_hrs
    ORDER BY  hr
    How It Works
    SELECT  LEVEL  AS n
    FROM    dual
    CONNECT BY  LEVEL <= x
    ;Produces a result set consiting of the integers 1, 2, 3, ..., x.
    There's nothing magical about the dual table; you can use any table AS LONG AS THE TABLE HAS ONLY ONE ROW .
    The other examples you saw probably just added this to a starting date, to get successive days, since, in Oracle date arithmetic, dt+n is a DATE n days after dt.
    Your case is slightly more complicated, because you want to add hours, not days. Since an hour is 1/24 of a day, we multiply by 24 to find how many integers to genereate, and divide by 24 when adding that number to the base date.
    Edited by: Frank Kulash on Apr 5, 2010 3:07 PM

  • Query for matching strings

    Hi, I am using a prepared statement and how can I perform string matching using that?
    For example, I have
    PreparedStatement pstat = con.prepareStatement( new String(sql))
    what should my sql String look like to query for strings containing "ab"
    so when the executeQuery() is called,
    I get results such as "abcd", "abcdcdc","ccccabccc"??
    Thanks a lot,

    try somethink like this:
    SELECT * FROM table_name WHERE column_name LIKE
    '%ab%'
    or
    SELECT * FROM table_name WHERE column_name LIKE ?
    providing "%ab%" as parameterAdding to that - you MUST do the % yourself and then use setString. The following will NOT work....
    SELECT * FROM table_name WHERE column_name LIKE '%?%'

  • How to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

Maybe you are looking for

  • Why can't I install mountain lion on my macbook pro?

    It still works.  I bought it in 2007.  What will I have to give up?

  • My lenovo experience: or how a fanboy started dissing it.

    My first Lenovo laptop I purchased new was ThinkPad X201T. While I used it with great overall satisfaction until recently for almost four years, it gave me a headache at the beginning. I came back from a military service, and was returning to school.

  • Splitting the internal table values

    I have a internal table with say 10000 lines i want to split it as 5000 and 5000 lines.How to code it? Moderator message: please try solving this yourself before asking, e.g. by studying the options of the LOOP statement. Edited by: Thomas Zloch on N

  • Sports highlight

    i want to make a football highlight video/movie for my son. Is it a way I can point him out from the rest of the football player by either placing an arrow over him or by making him glow in a still frame. Can anybody in the MAC world help me with thi

  • Continuos printing in smartforms

    hi experts, I am working with smartforms now.i am very comfortable with one page printing,but if it is continuos printing what all are the procedures involved in it. ie if i want to print invoice from 900001 to 9000010 at a time. pls give me step by