Query to fetch vendor number with whom this item was last purchased

Hi All,
We have a requirement to fetch the vendor number for an item with whom the item was last purchased. We need to derive this by looking at the open Purchase Order or the Material Transactions for the transaction type of ‘PO Receipt’ whichever is the latest.
For this we are using the below query, but this query is taking a lot of time and doing an INDEX RANGE SCAN on PO_LINES_N1 & MTL_MATERIAL_TRANSACTIONS_N1
SELECT MAX (v.segment1)KEEP (DENSE_RANK LAST ORDER BY DECODE
(UPPER (poh.closed_code),
'OPEN', poh.creation_date,
mmt.transaction_date
poh.creation_date) seg1
FROM po_headers_all poh,
po_vendors v,
mtl_material_transactions mmt
WHERE poh.po_header_id IN (SELECT pol.po_header_id
FROM po_lines_all pol
WHERE pol.item_id = p_inv_id)
AND v.vendor_id = poh.vendor_id
AND mmt.inventory_item_id(+) = p_inv_id
AND mmt.transaction_type_id(+) = 18
AND mmt.transaction_source_id(+) = poh.po_header_id;
Can anyone please help me in rewriting this query or if we can use different tables to acheive the same functionality.
Regards,
Shruti

Hi,
Can anyone please help me with the below query.
Regards,
Shruti

Similar Messages

  • Query to find vendor number with whom a particular item was last purchased.

    Hi All,
    I want to frame a SQL query to find vendor number with whom a particular item was last purchased.
    I got to know that we can find this by looking at the open Purchase Order or the Material Transactions for the transaction type of ‘PO Receipt’ whichever is the latest.
    Can anyone please help me in framing such query.
    Regards,
    Shruti

    Here is a hint
    Use the mtl_system_items_b table to get the inventory_item_id.
    Use it in the po_lines_all table to get po_header_id
    Use it in po_headers_all table to get vendor_id
    Use it in po_vendors to get segment1 (i.e. vendor#)
    Hope this helps,
    Sandeep Gandhi

  • Balance the item 1 - Vendor invoice with two expense items for two co codes

    Hi
    In our case document splitting is active with profit centre balancing.
    When I am posting a FI vendor invoice with two expenditure items to two difference company codes & cost centres, the system is generating the clearing line items but it is not posting and giving an error message that "balance profit centre data is not there in line item".  Since this is a vendor item and no profit centre information cannot be given manually, system has to split the item with relevant profit centre information, right ?  But that is not happening, please help me out.

    Hi,
       Document splitting configuration is done at client level and assigned at company code level.
    Document split is done based on the item categories and base item categories configured.
    This can be done only for the entities inside a company code and not for the company code and it is done to have a Zero balance check in the entities.
    Document splitting is done mainly for reporting purposes.(eg: Segment reporting, Profit center reporting etc.,)
    you are posting for two different company codes in a single transaction means it will be cross company code transaction.
    System will generate two different document numbers for eac line item and a single cross company code transaction number for the entire transaction.

  • Runtime error - FBL1N - vendor balance with customer line item

    Hi gurus,
    One scenario where i have assign vendor as customer & customer as vendor in vendor & customer data. also make tick mark for both clearing with vendor & customer.
    when i see the customer report with vendor item it shows me the customer & vendor dues but when i tried to see the vendor balance with customer line item it gives dump error.
    Runtime Errors         PERFORM_NOT_FOUND
    Exception              CX_SY_DYN_CALL_ILLEGAL_FORM
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_FORM', was
         not caught in
        procedure "%_LDB_CALLBACK" "(FORM)", nor was it propagated by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        The program "RSDBRUNT" is meant to execute an external PERFORM,
        namely the routine "CB_DDF_GET_KNA1 " of the program "RFITEMAP ", but
        this routine does not exist.
        This may be due to any of the following reasons:
        1. One of the programs "RSDBRUNT" or "RFITEMAP " is currently being developed.
        The name "CB_DDF_GET_KNA1 " of the called routine may be incorrect, or
        the routine "CB_DDF_GET_KNA1 " is not yet implemented in the program "RFITEMAP
        2. If the program SAPMSSY1 is involved in the runtime error, one of
        the function modules called via RFC is not flagged as remote-capable.
        (see Transaction SE37  Goto -> Administration -> RFC flag)
        3. There is an inconsistency in the system. The versions of the
        programs "RSDBRUNT" and "RFITEMAP " do not match.
    Warm regards,
    Dhananjay R.

    Hi martin
    still problem was not solved. actually i am working on ECC 6.0 & not required to implement the sap note on development. i had done the configuration in vendor master & customer master for clearing.
    please suggest me.....what to do ?
    Than'x
    Dhananjay R

  • E-pub books: when I click on a book to read it, this message appears:  "This item was originally downloaded with a different user account or Adobe ID. To continue, please add that account."

    I incorrectly replaced the backup for my iPad2 by accident when I tried to retrieve it to my new iPad Air.  It now no longer exists.
    I can still see the icons of the books on Kalahari's reader. (Kalahari is an e-pub bookshop in South Africa.
    When I click on a book to read it, this message appears:  "This item was originally downloaded with a different user account or Adobe ID. To continue, please add that account."
    I know for certain that the Adobe ID (e-mail address) is still correct. See below.  The password seems to be the problem.  This appears to have been changed a few times over the past two and a half years.  Which one? Was hoping Adobe could help. (case number: 0214089318)
    Can anyone please assist me to get back on track, what should I do to open and read my e-pub books again?
    Much appreciated.
    Leon Fisher
    Johannesburg
    South Africa
    [email protected]

    Hi I have the exact same issue.
    Someone please post a solution...

  • When I click on a book to read it, this message appears:  "This item was originally downloaded with a different user account or Adobe ID. To continue, please add that account."

    I incorrectly replaced the backup for my iPad2 by accident when I tried to retrieve it to my new iPad Air.  It now no longer exists.
    I can still see the icons of the books on Kalahari's reader. (Kalahari is an e-pub bookshop in South Africa.
    When I click on a book to read it, this message appears:  "This item was originally downloaded with a different user account or Adobe ID. To continue, please add that account."
    I know for certain that the Adobe ID (e-mail address) is still correct. See below.  The password seems to be the problem.  This appears to have been changed a few times over the past two and a half years.  Which one? Was hoping Adobe could help. (case number: 0214089318)
    Can anyone please assist me to get back on track, what should I do to open and read my e-pub books again?
    Much appreciated.
    Leon Fisher
    Johannesburg
    South Africa
    [email protected]

    Hi I have the exact same issue.
    Someone please post a solution...

  • Premiere CC 2014: Message on loading project from older version: This project was last used with Mercury Playback Engine GPU acceleration (CUDA)...

    After installing Adobe CC 2014 I have each time a message when loading an old Adobe pro project. Message:This project was last used with Mercury Playback Engine GPU acceleration (CUDA), which is either not available or not certified on this system. Mercury Playback software will be used. I have very recent HP Zbook 15 with a NVIDIA Quadro K2100M. At webinar today it was explained how to solve this, but sound was not understandable at my machine at that moment. Help? What need I to do.

    Problem is solved since yesterday via Adobe helpdesk. It appeared that the newest driver for the NVIDIA were note present. So after downloading the new drivers it work. But I think Adobe should mention those issues when they launch new versions of Adobe CC like in June.

  • HT3842 Those steps don't work. I'm using the lastest version of itunes (11.0.1.12) on Windows. This article was last updated in 2009 and lists itunes 7.7. Anyone have any ideas, or is there a new article that accounts for the changes to itunes?

    Those steps don't work. I'm using the lastest version of itunes (11.0.1.12) on Windows. This article was last updated in 2009 and lists itunes 7.7. Anyone have any ideas, or is there a new article that accounts for the changes to itunes?

    Try This
    http://support.apple.com/kb/PH12359

  • HT1725 I having problem with my download items that I purchase off itune

    I having issue with download the items i have purchase on itune website

    If you have a bad cell signal that can happen.

  • I purchaced a song, but I received a notice that this song was already purchased but not downloaded what does this mean?

    I purchased a song, but I received a notice that this song was previously purchased but not downloaded. Doesn't this occur immediately, if not how do I do this?

    Store>Check for Available Downloads

  • Need to fetch Vendor number from shipment to SD billing document creation

    Hi Guru's.
    I want to  fetch the Vendor number from the Ship Cost document and want to populate on the SD billing document and then corresponding acctg document. Is there any way or user exits available?
    Thanks in advance for your help.

    Hi
    For your requirement you can add a Zfeild in the shipment tables and link that table to the Vendor tables.You can either go with USEREXIT_FIELD_MODIFICATION
    Regards
    Srinath

  • Hi, I still use an iPhone 4, ever since my recent update of iOS I cannot purchase apps from the App Store, and a message keeps appearing saying that, 'this item cannot be purchased from the US store, and please switch to the Malaysia store''.

    I keep getting this message when I try to update my apps and when trying to purchase new apps from the App Store. I checked my iTunes ID and it turns out that the country shown there is the one that I am actually living in. And it is the same as my billing address, but when I tried to update my apps again, I keep getting this message, 'you are not eligible for purchase of this item from the US store, please switch to the Malaysia store'. How do I solve this issue.
    Besides ever since I updated my phone iOS it has started misbehaving, quite irritably at times. Dropped calls, slow typing, apps open very slowly, apps cannot be updated with prompts coming up like, this app cannot be updated now, please try again. I had to delete quite a few apps and reinstall them again. I had a trouble free experience with this phone till now, but is apple losing its magic. 

    Thanks too all the people who responded. . . . (noone)
    Got it sorted though. Seems that Apple has issues with multiple apple id's.
    Seems i had to somehow remember and use the original id i had when i first bought my 1st iPhone. . . .
    Even after that it was extremely hard to get my apps back on my PC.
    If anyone else has the same problem. . . .email Apple. Cya.

  • With a lock item in a purchase order, release strategy works?

    Dear All,
    I have a very important question for myself.
    I have a purchase order with only one item.
    I have set this item to locked.
    Release strategy works without problems.
    Is this situation correct?
    I don't understand it but maybe the release strategy works normally too....
    Please help me with a explanation
    Thanks in advance

    Yes, if a release strategy is applied to a PO, then even if you block / delete an item, it will still have the release strategy.
    This is standard behaviour, because you can later remove the deletion indicator or unblock the PO, whence the PO will again have to go through the Release Procedure.

  • Vendor number with logic inbuilt for Purchasing organization

    Hi,
    Can anyone help me to get Vendor Numbers based on purchasing organization.
    Example: Purchasing organization 1A, Vendor account no internal number range assigned is 10000-19999
    Now we create new vendor code , it should be 1A10000, instead of 10000.
    Please help.
    Regards,
    MG

    Hi Manish,
    You can use the BADI VENDOR_ADD_DATA for this purpose. Implement it and write the below code in method MODIFY_ACCOUNT_NUMBER
    The code will be like below:
    method IF_EX_VENDOR_ADD_DATA~MODIFY_ACCOUNT_NUMBER.
      data : v_eko type ekko-ekorg.
      get PARAMETER ID 'EKO' FIELD v_eko.
      C_LIFNR = C_LIFNR+5(5).
      CONCATENATE v_eko C_LIFNR INTO C_LIFNR.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = C_LIFNR
    IMPORTING
    OUTPUT = C_LIFNR .
    endmethod.
    It will resolve your problem.
    Thanks

  • Query on getting the Pane with all the items for creating Views

    Hi Group,
    I have a query as under:
    I was trying to create a sample Web Dynpro ( for ABAP ) using tcode SE80 and while creating view, I have to get the Pane with the items ( eg., Radio element, text fields, text areas, etc., kind of all UI Elements )....
    But, I was not able to get while defining the View for the Web Dynpro application....
    Please let me know if any setting has to be done to get this or any other clue as to get this Pane...
    Thanks in advance.
    Regards,
    Vishnu.

    hi vishnu....
            make sure you have given the host and port in the local host file in c:/.
    [link|help.sap.com/saphelp_erp2005/helpdata/en/43/e86de5008b4d9ae10000000a155369/content.htm ].
    ---regards,
       alex b justin

Maybe you are looking for

  • Remote control and NAL screen

    We use NAL screen only here for the students. The problem we are having is if a student uses the option Close all programs and log on as a different user. The remote will not work again till the computer is shut down and restarted. This is also true

  • FI and controlling error while posting GL

    hi all, I did Fi configration by creating all by my own... but when i  was trying to post GL in fb50 itz thorows error of the following ......... Controlling area  does not exist Message no. KI101 Diagnosis Controlling area  does not exist. System Re

  • New to flash. I import a flash professional project into flash builder but don't see a design mode

    in flash builder to place object onto!!! I can see design mode if I import a catalyst project, as well an mxml file, but not with flash professional. Any help?

  • BB Flip External Display Caller Notification Issue

    Hello- I have owned this phone for approximately two weeks; and until today it was working perfectly. As of today the external display is no longer working for "caller ID" or incoming call notification. The temporary fix was to disable the "auto answ

  • Job failed with error tempdb is not available

    HI All, Backup job failed with error 'Unable to determine if the owner () of job backup_all_user_db_full has server access (reason: The log for database 'tempdb' is not available. [SQLSTATE HY000] (Error 9001)).' I checked in errorlog LogWriter: Oper