Query to identify the Latest Pur Price of a item's First PO doc Num & Date

Hi Experts,
Version: 2007B
I want a query to do FMS in my purchase order UDF.
The information i need in UDF through FMS is,
I want the document number and Posting date of the first document of the Last purchase Price. Let me make it more clear with the example.
I am creating a Purchase order of PO01 for a item XXXX1  on 12/3/11, and enter the price of INR 400.
and again creating the Purchase order of PO25 for the same item as on 25/04/11, here since the last purchase is the price list am selected in the document level , it will show me as 400. its right.  now here i want the information in my UDF is   " Ref:PO01 as on 12/03/11"
This information am using it to identify the LATEST PURCHASE PRICE'S FIRST DOCUMENT DATE AND ITS DOC NUMBER to give a proof to the supplier.
Hope this information would explain my requirement.
Regards,
Dwarak
Edited by: Dwarakanath.P on Apr 19, 2011 3:11 PM

Dear GordonDu,
While executing this query, am getting these errors.
1). [Microsoft][SQL Native Client][SQL Server]Unclosed quotation mark after the character string ' as of +T0.DocDate  From OPOR T0 INNER JOIN POR1 T1 ON T1.DocEntry=T0.DocEntry  WHERE T1.ItemCode = $[$38.1.0]  ORDER BY T0.DocDate DESC FOR BROWSE '. 2). [
2). [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '$38.1.0'. 2). [Microsoft][SQL Native Client][SQL Server]Statement 'Service Contracts' (OCTR) (s) could not be prepared.
Please Let me make sure of my requirement once again in short.
1)  I have created a UDF in a Purchase Oder at title level.
2) next, i am creating a PO for 3 items.
3)now, i want to display the 3 items doc no and Posting date of the first Puchase order of the latest price(Last price).
thanks for your time, if you dont mind , and if you need i can also come in skype voice chat to clarrify my requirement friend.
thanks & regards,
Dwarak

Similar Messages

  • Need Store DB tables to query to get the latest scanned price at register

    Need Store DB tables to query to get the latest scanned price at register.
    Please provide a sample sql script that will help me do this. I need to have this informatino for several items at a time.
    Thanks,
    Edited by: user10133807 on Jan 13, 2012 9:22 AM
    Edited by: user10133807 on Jan 13, 2012 9:23 AM

    Hi,
    You can find multiple items saled price at the register by running below quary
    select distinct DC_DY_BSN,ID_ITM_POS,MO_PRN_PRC from TR_LTM_SLS_RTN;
    Thanks,
    MG

  • ASL information with the latest quotation price for that item

    Hi Gurus,
    I am looking for a query to find the Item, Approved Supplier (from the ASL) and the latest quotation price for that item from the approved supplier.
    Please help !!
    Thanks in advance !!
    KM

    Dear GordonDu,
    While executing this query, am getting these errors.
    1). [Microsoft][SQL Native Client][SQL Server]Unclosed quotation mark after the character string ' as of +T0.DocDate  From OPOR T0 INNER JOIN POR1 T1 ON T1.DocEntry=T0.DocEntry  WHERE T1.ItemCode = $[$38.1.0]  ORDER BY T0.DocDate DESC FOR BROWSE '. 2). [
    2). [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '$38.1.0'. 2). [Microsoft][SQL Native Client][SQL Server]Statement 'Service Contracts' (OCTR) (s) could not be prepared.
    Please Let me make sure of my requirement once again in short.
    1)  I have created a UDF in a Purchase Oder at title level.
    2) next, i am creating a PO for 3 items.
    3)now, i want to display the 3 items doc no and Posting date of the first Puchase order of the latest price(Last price).
    thanks for your time, if you dont mind , and if you need i can also come in skype voice chat to clarrify my requirement friend.
    thanks & regards,
    Dwarak

  • MDX Query to show the latest product text again historical facts (Type 2 dimenion linking on Surrogate key and also Natural Key)

    I need to write a MDX query to show the latest product text again historical facts or a chosen product text in time. I can write this query in TSQL, but new to MDX.
    The way I do it in TSQL is joining two queries together on the Natural Key as opposed to the surrogate key.
    Can this be done in MDX. I know I could write two separate MDX queries, one which get the product text I wan and the other to get the measure with the actual product text and Natural Key, and use a lookup function in ssrs to show the two result sets I the
    same tablix by looking up the Natural Keys. But this should be able to be done in one query shouldn't it.
    In the dsv the fact knows to join to the dimension using the surrogate key.
    Thanks J

    Hi Jamster,
    According to your description, you want to write a query to show the latest product text, right?
    In MDX, we can use LastNonEmpty function to return the lastest member winth a dimension. LastNonEmpty is an aggregation function available in the Enterprise version of SQL Server. However, you can create your own with a little bit of recursive MDX. Here
    is a sample query for you reference.
    With Member Measures.LastHits as
    iif(isempty(Measures.Hits),
    ([Date].[Year Month Day].prevmember,
    Measures.LastHits
    ),Measures.Hits)
    Reference
    http://cwebbbi.wordpress.com/2011/03/24/last-ever-non-empty-a-new-fast-mdx-approach/
    http://richardlees.blogspot.com/2010/07/getting-last-non-empty-value.html
    If this is not what you want, please provide us the detail structure of your cube and the expected result, so that we can make further analysis and give you the exactly MDX query.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Query to identify the recovery catalog database name from target database

    Hi,
    How to get the recovery catalog database name from the registered target database?
    i dont know my recovery catalog database for my target database.
    I know we can use the query
    select * from rc_database;
    from recovery catalog database to know all the registered database with the recovery catalog but I want to know is there any way or query to identify the recovery catalog database name from target database to which the target database is registered
    With Regards
    Boobathi P

    You can check the backup scripts which you use to backup your target database to get the catalog database name.
    And check the corresponding connect string in TNSNAMES.ORA file or tnsping to get the server details of the catalog database.
    Edited by: gopal on Apr 12, 2013 12:59 PM

  • Hi, App Store tells me I have installed the latest Pages update, yet it will not open Pages docs created on other machines that DO have the latest version . Any tips?

    Hi, App Store tells me I have installed the latest Pages update, yet it will not open Pages docs created on other machines that DO have the latest version . Any tips?

    Hi
    Pages 5.0 and 10.9.
    While App Store tells me there is no update avalable to Pages, which it says was installed Nov. 4, its the old Avatar/logo thingo and, as I say, it will not open the Pages docs created on my MacBook, which definiitely does have the new Pages running smoothly.
    cheers

  • Need help on how to identify the latest timestamp ran for the WorkBooks

    I know some tables to identify the workbooks when they are created.But this tables are not updating If we ran the workbook today.
    for example, :   if we created workbook & saved on 05/25/2009 or opening old WB.After that if we ran same workbook on 05/26/2009 then system has to update the latest timestamp as last ran.but iam unable to find this timestamps for workbooks.
    WB are maitained in RSDDSTAT.here i can able to find when it was last changed but not the latest timestamps.Our requirement to find the latest timestamp ran for the WorkBooks from last one year, which are using.
    below are the tables to identify when the workbook was created and other details:
    RSRWBINDEX  List of binary large objects (Excel workbooks)
    RSRWBINDEXT  Titles of binary objects (Excel workbooks)
    RSRWBSTORE  Storage for binary large objects (Excel workbooks)
    RSRWBTEMPLATE  Assignment of Excel workbooks as personal templates
    RSRWORKBOOK  Where-used list for reports in workbooks
    Thanks in advance
    Mahesh

    Any Updates,
    I got one more table to identify WB,
    /BI0/PTCTWORKBK - Master Data (Time-Ind.): Characteristic Workbook
    Still unable to find Last run timestamps for workbooks
    Mahesh.

  • Query to find the latest two transactions for each Group

    Hi All,
    Consider the following sets of records in a table test.
    Group---Tran_Dt---SlNo
    c1 10/10/2003 1
    c1 10/10/2003 2
    c1 10/10/2003 3
    c1 11/10/2003 1
    c2 10/10/2003 1
    c2 10/10/2003 2
    c2 11/10/2003 1
    c2 11/10/2003 2
    c2 11/10/2003 3
    c3 10/10/2003 1
    c3 10/10/2003 2
    c3 10/10/2003 3
    I want to list out the latest two transactions for each group irrespective of the slno and trans_dt as below:
    group tran_dt SlNo
    c1 11/10/2003 1
    c1 10/10/2003 3
    c2 11/10/2003 3
    c2 11/10/2003 2
    c3 10/10/2003 3
    c3 10/10/2003 2
    Any help on this would be appreciated.
    Thanks
    Walter Nicholas T

    Hi Walter,
    Please try following query.
    select Group,tran_dt,sino from
    select Group,tran_dt,sino,(DENSE_RANK()OVER (PARTITION BY Group ORDER BY tran_dt desc,sino desc)) rank from test
    ) where rank between 1 and 2
    Thanks,
    Samir

  • How do I identify the latest file modifications, application install, and registry key modification for Security Forensics.... using GP Audit for registry/file system

    Hello,
    Title pretty much states it all. I initially set out (as part of a Security Forensics initiative) to identify the most recently installed applications, modified files, and registry key changes using PowerShell. I attempted to pull this information and sort
    them by date installed/last modified, but it was brought to my attention this information isn't always present and can be modified - so it's not accurate.
    At that time it was suggested we use Group Policy auditing for Registry and File System -  but I'm not sure how I'm going to use/pull these in PowerShell? This will be used on remote host all over the world so local physical access isn't an option.
    My question is:
    Once Group Policy Auditing for Registry and File System has been enabled, how would I go about pulling those audit logs for review once a system has been identified as compromised? I'm brand new to this GP Auditing (we have a separate team for that) so feel
    free to take it from the beginning. :)
    Thanks in advance!

    Hi,
    Here are a few suggestions for you:
    Ensure Remote Registry service is started on local and remote machines.
    Add the – Credential option and supply administrative credentials within the command.
    More information for you:
    Get-Eventlog doesn't work against Vista/W7 clients
    https://social.technet.microsoft.com/Forums/en-US/c5185a01-b0d2-49a7-9aa7-52e6534ada04/geteventlog-doesnt-work-against-vistaw7-clients?forum=winserverpowershell
    PowerShell - How to Get XML EventData - Remote Eventlogs - Exchange Events
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/382b10c9-d740-46b1-b81c-b24de911eb14/powershell-how-to-get-xml-eventdata-remote-eventlogs-exchange-events-?forum=ITCG
    Powershell script to gather failed logon attempts by event id and type from the security events log
    https://social.technet.microsoft.com/Forums/scriptcenter/es-ES/00a62492-c63a-4c8b-92f9-1cc857223a00/powershell-script-to-gather-failed-logon-attempts-by-event-id-and-type-from-the-security-events-log?forum=ITCG
    Best Regards,
    Amy
    Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Query to find the latest record with respect to the current status

    Dear gurus
    I have the following data in a table
    Customernum
    bkcode
    reqtdate
    Prevstat
    currstat
    The data will be like this
    CustomerNum bkcode reqdate prevstat currstat
    5900 1 03-Aug-12 0 1
    5900 1 06-Aug-12 1 0
    5900 5 22-Jun-12 0 1
    If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
    If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
    If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
    I have trying hard to get this thing confused what to use Lead or Max
    Kindly guide me

    Hi,
    one way here:
    WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
    AS
       SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
       SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
       SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
    SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
      FROM (SELECT a.*
                 , ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
                                           ORDER BY reqdate DESC) AS rn
              FROM mytable a
    WHERE rn=1
       AND currstat=1;
    CUSTOMERNUM     BKCODE REQDATE     PREVSTAT   CURRSTAT
           5900          5 22-JUN-12          0          1Regards.
    Al
    Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
    Changed again!! Previous logic was wrong

  • HT4623 My Itunes on my PC keeps telling me I need to update my phone to the latest itunes 10.6.3 and my iphone is up to date on all of its updates. Wont let me download any music etc? Help please.

    My itunes on my PC keeps telling me I need to update my phone to the latest 10.6.3 and according to my phone I have no new updates. This is preventing me from downloading music from my itunes to my iphone. Please help!

    It is not telling you to update your iphone, it is telling you that you need to update itunes on your computer.

  • SQL query to fetch the catalog category for a PLM item

    Hi All,
    Can anyone help me with a sql query of how we can fetch the catalog category for a PLM item.
    Regards,
    Shruti

    Hi,
    You could monitor the SMSProv.log when you check the category of an application. It shows that SQL query the SCCM provider used is related to function fn_ListCategoryInstances.
    Best Regards,
    Joyce

  • Best query to get the latest version

    Hi,
    I have a table as below:
    col1 col2 col3.... col_ver col7
    I have a combination od values for col1 to col6. I have values in col7 which is different for each value in col_ver. col_ver is a version column.
    For a particular combination (col1 to col6) I want to get the rows with the maximum version. Can anyone suggest the best sql for this ?
    I have 2 options as below, please suggest from performance point of view which would be better (i don't have enough rows to test) and if there is a any other better way
    option 1:
    SELECT col1, col2, col3, col4, col5, col6, col_ver, col7
    FROM
    (SELECT col1, col2, col3, col4, col5, col6, col_ver, col7, MAX(col_ver) OVER (PARTITION BY col1, col2, col3, col4,
    col5, col6) MVER
    FROM tabA )
    WHERE col_ver = MVER;
    option2:
    SELECT col1, col2, col3, col4, col5, col6, col_ver, col7
    FROM tabA A
    WHERE col_ver = (SELECT MAX(col_ver) FROM tabA B
    WHERE
    B.col1 = A.col1
    AND B.col2 = A.col2
    AND B.col3 = A.col3
    AND B.col4 = A.col4
    AND B.col5 = A.col5
    AND B.col6 = A.col6);
    Thanks a lot in adavnce

    SQL> with t as
      2  (select 'a1' col1, 'b1' col2, 'c1' col3, 'd1' col4, 1 col_ver,  100 col7
      3     from dual
      4   union all
      5   select 'a1' col1, 'b2' col2, 'c1' col3, 'd1' col4, 1 col_ver,  101 col7
      6     from dual
      7   union all
      8   select 'a1' col1, 'b2' col2, 'c2' col3, 'd1' col4, 1 col_ver,  102 col7
      9     from dual
    10   union all
    11   select 'a1' col1, 'b2' col2, 'c2' col3, 'd2' col4, 1 col_ver,  103 col7
    12     from dual
    13   union all
    14   select 'a2' col1, 'b1' col2, 'c1' col3, 'd1' col4, 1 col_ver,  104 col7
    15     from dual
    16   union all
    17   select 'a2' col1, 'b2' col2, 'c1' col3, 'd1' col4, 1 col_ver,  105 col7
    18     from dual
    19   union all
    20   select 'a2' col1, 'b2' col2, 'c2' col3, 'd1' col4, 1 col_ver,  106 col7
    21     from dual
    22   union all
    23   select 'a2' col1, 'b2' col2, 'c2' col3, 'd2' col4, 1 col_ver,  107 col7
    24     from dual
    25   union all
    26   select 'a1' col1, 'b1' col2, 'c1' col3, 'd1' col4, 2 col_ver,  108 col7
    27     from dual
    28   union all
    29   select 'a1' col1, 'b2' col2, 'c2' col3, 'd1' col4, 2 col_ver,  109 col7
    30     from dual
    31   union all
    32   select 'a1' col1, 'b2' col2, 'c2' col3, 'd2' col4, 2 col_ver,  110 col7
    33     from dual
    34   union all
    35   select 'a2' col1, 'b2' col2, 'c1' col3, 'd2' col4, 2 col_ver,  111 col7
    36     from dual
    37   union all
    38   select 'a2' col1, 'b2' col2, 'c2' col3, 'd2' col4, 2 col_ver,  112 col7
    39     from dual
    40   union all
    41   select 'a1' col1, 'b2' col2, 'c2' col3, 'd2' col4, 3 col_ver,  113 col7
    42     from dual
    43   union all
    44   select 'a2' col1, 'b1' col2, 'c1' col3, 'd1' col4, 3 col_ver,  114 col7
    45     from dual)
    46  select * from t;
    CO CO CO CO    COL_VER       COL7
    a1 b1 c1 d1          1        100
    a1 b2 c1 d1          1        101
    a1 b2 c2 d1          1        102
    a1 b2 c2 d2          1        103
    a2 b1 c1 d1          1        104
    a2 b2 c1 d1          1        105
    a2 b2 c2 d1          1        106
    a2 b2 c2 d2          1        107
    a1 b1 c1 d1          2        108
    a1 b2 c2 d1          2        109
    a1 b2 c2 d2          2        110
    a2 b2 c1 d2          2        111
    a2 b2 c2 d2          2        112
    a1 b2 c2 d2          3        113
    a2 b1 c1 d1          3        114
    15 rows selected.
    SQL> -- from here we only need to get those with the lastest value for the col_ver
    SQL> with t as
      2  (select 'a1' col1, 'b1' col2, 'c1' col3, 'd1' col4, 1 col_ver,  100 col7
      3     from dual
      4   union all
      5   select 'a1' col1, 'b2' col2, 'c1' col3, 'd1' col4, 1 col_ver,  101 col7
      6     from dual
      7   union all
      8   select 'a1' col1, 'b2' col2, 'c2' col3, 'd1' col4, 1 col_ver,  102 col7
      9     from dual
    10   union all
    11   select 'a1' col1, 'b2' col2, 'c2' col3, 'd2' col4, 1 col_ver,  103 col7
    12     from dual
    13   union all
    14   select 'a2' col1, 'b1' col2, 'c1' col3, 'd1' col4, 1 col_ver,  104 col7
    15     from dual
    16   union all
    17   select 'a2' col1, 'b2' col2, 'c1' col3, 'd1' col4, 1 col_ver,  105 col7
    18     from dual
    19   union all
    20   select 'a2' col1, 'b2' col2, 'c2' col3, 'd1' col4, 1 col_ver,  106 col7
    21     from dual
    22   union all
    23   select 'a2' col1, 'b2' col2, 'c2' col3, 'd2' col4, 1 col_ver,  107 col7
    24     from dual
    25   union all
    26   select 'a1' col1, 'b1' col2, 'c1' col3, 'd1' col4, 2 col_ver,  108 col7
    27     from dual
    28   union all
    29   select 'a1' col1, 'b2' col2, 'c2' col3, 'd1' col4, 2 col_ver,  109 col7
    30     from dual
    31   union all
    32   select 'a1' col1, 'b2' col2, 'c2' col3, 'd2' col4, 2 col_ver,  110 col7
    33     from dual
    34   union all
    35   select 'a2' col1, 'b2' col2, 'c1' col3, 'd2' col4, 2 col_ver,  111 col7
    36     from dual
    37   union all
    38   select 'a2' col1, 'b2' col2, 'c2' col3, 'd2' col4, 2 col_ver,  112 col7
    39     from dual
    40   union all
    41   select 'a1' col1, 'b2' col2, 'c2' col3, 'd2' col4, 3 col_ver,  113 col7
    42     from dual
    43   union all
    44   select 'a2' col1, 'b1' col2, 'c1' col3, 'd1' col4, 3 col_ver,  114 col7
    45     from dual)
    46  select a.col1, a.col2, a.col3, a.col4, a.col_ver, a.col7
    47    from (select t.col1, t.col2, t.col3, t.col4, t.col_ver, t.col7,
    48                 row_number() over (partition by t.col1, t.col2, t.col3, t.col4
    49                                    order by t.col_ver desc) rn
    50            from t) a
    51   where a.rn = 1;
    CO CO CO CO    COL_VER       COL7
    a1 b1 c1 d1          2        108
    a1 b2 c1 d1          1        101
    a1 b2 c2 d1          2        109
    a1 b2 c2 d2          3        113
    a2 b1 c1 d1          3        114
    a2 b2 c1 d1          1        105
    a2 b2 c1 d2          2        111
    a2 b2 c2 d1          1        106
    a2 b2 c2 d2          2        112
    9 rows selected.
    SQL>

  • Query to identify the type of partition on a table

    [p]
    Could any one provide me an sql query to find out what type of partition
    1). Range
    2). List
    3).Hash partition
    does a partition table have?
    #2
    Can there be a partitioned table without any partitions on it or is it mandatory to have atleast one partition??[p]

    Could any one provide me an sql query to find out what type of partition ALL_PART_TABLES
    Why create a partitioned table without any partitions ?
    Nicolas.

  • Query to find the no. of related no. of Items with a item.

    Hi,
    I made some items in inventory. I have to find the no. of child items that are connected to a parent item. Like if there is a parent item a and it has two sub item b1 and b2. again b1 has two subitem b11, b12. similar b2 have two subitem b21, b22. and this goes on. So i have to make a query to find out all the the items.
    Plz give me the solutions.
    Regards
    user609981

    Dou you know read?
    -- the number of rows in a table named yourtable:
    select count(1) from yourtable;
    -- the number of columns in a table
    -- If is a user's table:
    select count(1)
    from user_tab_columns
    where table_name='YOURTABLE'
    --If it is´t
    select count(1)
    from DBA_tab_columns
    where owner = 'USEROWNER'
    and table_name='YOURTABLE'

Maybe you are looking for

  • How do I find out where my remote wipe was triggered

    I had a laptop stolen out of my house. And I finally got an email about 2 1/2 weeks later that my remote wipe had started blah de blah. What I really want to know is WHERE it started so that I can give that information to the police and catch the lit

  • Need to limit number of rows returned by a query

    Hi. Is there a way to limit the rowsets returned to me in a query? I need to get the first 100, then the next hundred, etc until there are no more rows left to retrieve. Someone told me that I should use a cursor to do this. Does anyone have a specif

  • Jms-xi-idoc scenario

    Hi As ECC system is going to receive idoc's we got to set partner profiles in this sytem. If I am not wrong  in ECC system we are going to set the partner profiles of XI system ?? or partner profiles of ECC system itself ?? Meanwhile whether we got t

  • How can BI recognize business event into transactional environment?

    Dear colleagues: As I have been looking forward to figure out BW based BAM solutions, such as to implement BW to recognize business event into Transactional applications I just found the TechEd 2008 BPX Community winner proposal Operational BI-Embedd

  • How to create native key events

    Hello can someone tell me please if (and if yes, how) it is possible to create native, therefore by the underlying recognized key events? My Java-App needs to send several key inputs which are also required to be noticed by Windows... Thanks Matthias