Latest vendor name based on item

hi
when i do the following query , i am taking an eg of the item_no 1020101001
select msib.segment1,max(pha.approved_date) from
po_headers_all pha,
po_lines_all pla,
po_vendors pv,
mtl_system_items_b msib
where
pha.po_header_id = pla.po_header_id
and pla.item_id = msib.inventory_item_id
and pv.vendor_id=pha.vendor_id
and msib.segment1='1020101001'
--and pha.approved_date=max(pha.approved_date)
group by
--item_id.
msib.segment1this is the output i get
segment1 MAX(PHA.APPROVED_DATE)
1020101001 1/9/2011 3:16:48 PM
when i do the following query
select msib.segment1,max(pha.approved_date) ,pv.vendor_name from
po_headers_all pha,
po_lines_all pla,
po_vendors pv,
mtl_system_items_b msib
where
pha.po_header_id = pla.po_header_id
and pla.item_id = msib.inventory_item_id
and pv.vendor_id=pha.vendor_id
and msib.segment1='1020101001'
--and pha.approved_date=max(pha.approved_date)
group by
--item_id.
msib.segment1
,pv.vendor_name
segment1           MAX(PHA.APPROVED_DATE)  VENDOR_NAME
1020101001    7/21/2008 9:09:20 AM   TRIZAC  ABU DHABI
1020101001   1/9/2011 3:16:48 PM        SAUDI CEMENT COMPANY
1020101001   2/14/2010 4:03:46 PM     UNION CEMENT NORCEM CO.
1020101001  5/19/2010 3:08:32 PM      AS CIMENTO SANAYI VE TICARET A.S.
i require the most recent vendor_name for a particular item ( i require the output as below)
segment1 MAX(PHA.APPROVED_DATE) VENDOR_NAME
1020101001 1/9/2011 3:16:48 PM SAUDI CEMENT COMPANYkindly guide me
thanking in advance

I am not sure what you are looking to fetch. For the scenario you have given you need to use the sub-query.
SELECT A,SEGMENT1, A.APPROVED_DATE, PV.VENDOR_NAME
FROM (SELECT msib.segment1, MAX(PH.approved_date) approved_date
FROM PO_LINES_ALL PL,
PO_HEADERS_ALL PH
mtl_system_items_b msib
WHERE PL.po_header_id = PH.po_header_id
AND MSIB.item_id = PL.ITEM_ID
AND MSIB.segment1 = :1
GROUP BY MSIB.segment1) A,
PO_HEADERS_ALL PH,
PO_VENDORS PV
WHERE A.approved_date = PH.approved_date
AND PV.VENDOR_ID =PH.vendor_id
- The query should have right filters (item_id, vendor_id or document_num), otherwise it will behave very badly.
- They can return multiple recods if there are more than one PO approved at same time. In that case the outer query also needs an aggregation.
Thanks, Siva

Similar Messages

  • Report for vendor list based on items

    Hi Experts,
                    report format:
    ITEM NAME     ITEM TYPE    VENDOR NAME   VENDOR TYPE
    computer           domestic        abc computers     manufacturer
    computer           domestic        gef computers      dealer
    computer           domestic        jkl computers       trader
    sofa                   import            abc lifestyles       manufacturer
    chair                 domestic         xyz pvt ltd           dealer
    how many vendors are supplying that particular item? item type ? vendor type?
    Help in this query.
    Thanks & Regards,
    Saikrishna.

    Hi Raviraj,
                  Thanks. i just altered this query by giving condition.
    SELECT T1.[Dscription] as 'Item Name', T3.[ItmsGrpNam] as 'ItemType', T4.[CardName] as 'Vendor Name', T5.[GroupName] as 'Vendor Type' FROM OPCH T0  INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod INNER JOIN OCRD T4 ON T0.CardCode = T4.CardCode INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode  WHERE T1.[Dscription] between [%1] and [%2] GROUP BY T4.[CardName], T1.[Dscription], T3.[ItmsGrpNam], T5.[GroupName]
    Thanks & Regards,
    Saikrishna.

  • Display Vendor Name In PO Item Condition In Item Details

    Hi,
    Process is, if we have created to PO (ME21N) and given XX Vendor in Header and ZZ Vendor Code has maintained as per condition wise in line item wise in condition tab in item details but not shows ZZ Vendor Name.
    I want to display the Vendor Name in item details.
    Please tell me, How to display the vendor Name?
    If any User Exit or other option through.
    Devendra

    Thanks for Reply, as suggested by you, I have checked with ABAPer maybe this enhancement use for new tab in PO
    I need to display the vendor name at the space before the vendor and vendor code are shown.
    Me21n-->give item and its details>item conditions tab---->select particular condition type -
    >click on Conditional details icon. There at the end right hand side vendor field is present where we can give vendor code. Beside the vendor field i need to display that given vendor code related name. So that user won't make any mistakes in giving the vendor code
    Pl provides me the solution to do this. Which is the best way to bring vendor name in that screen?
    Devendra

  • FBL3N adding vendor name to line item display

    Our users require the vendor name to be displayed on the G/L line item layout when they execute FBL3N.  I was able to get the vendor number to display through the use of Offsetting account number.  Is there a way through standard config to also pull in the associated vendor name?
    Thanks in advance,
    Linda

    Hi!
    Take a look at the following thread: adding a field to FBL3N
    Cheers,
    Jarek
    Edited by: Jaroslaw Cichon on Feb 19, 2009 3:15 PM

  • Populate header text with reference number and vendor name

    Hi Experts,
    My client wants to populate the line item text field - SGTXT in MIRO / FB60 with the reference number field XBLNR and the vendor name.
    Is it possible to do it before the invoice get posted?. Like, just after the user entered the vendor account number and the reference number in FB60 system picks the vendor name against the vendor number from LFA1 table and the reference number entered in FB60 screen and populates them in text field ?
    Similarly in MIRO - before the invoice get posted is it possible to pick the reference number from MIRO screen and pick the vendor name based on the PO number entered on the MIRO screen.
    Please advise how to do this.
    Thank you
    Shino

    Hi
    This can be achieved by using a User Exit in Substitution rule. This is done through GGB1. Define the rule
    Prerequisite
    (System T Code =FB01 or MIRO) and Account Type = K
    Substitution
    User Exit
    The following link will be of help to you to define a user exit in substitutition rule
    http://help.sap.com/saphelp_46c/helpdata/en/5b/d231a843c611d182b30000e829fbfe/content.htm
    Regards
    Sanil Bhandari

  • Display of vendor name in po condition type

    Dear SAP Gurus,
    I have got a requirement to add vendor name in po item detail condtions tab in that if we select particular condition type and see the details there we can see vendor and now it is required to add vendor name display based on the given vendor.
    i got some idea of doing sonmething in the screen of that program.
    programname SAPLV69A
    Screen number 640.
    We need to display vendor name against vendor.Can you tell me the badi or any exit for coding the requirement.
    Regards,
    Anand.

    Hi
    Add you own tab in the PO for this item with this info. Use the badi's ME_GUI_PO_CUST and ME_PROCESS_PO_CUST.
    If you need more info, let us know.
    Regards
    Eduardo

  • Supress Vendor name in std report S_ALR_87012103 - Vendors: Items

    Hi ,
    I am using report 'S_ALR_87012103 - Vendors: Items -> List of Vendor Line Items' to list the vendor open items and in the output the vendor name with address is displayed, I want to supress name and address so that when I download to excel it will easier for me to change the columns.
    Than

    Try using FBL1N instead of this report, which does not show address.
    Regards,
    SDNer

  • Vendor Name Appearing Different for Different Line Items in FBL1N

    Hi,
    I am executing FBL1N and changing the layout to include the Vendor Name in the line items. But when the line items are appearing, the Vendor Name is appearing different for different documents. I wish to see from where the system is picking up the name, so that I can rectify this. But since the layout is being changed after the report is executed, the debug window is taking me in this. Can someone help me please how to debug so that I can see from where the name is coming?
    Thanks and Regards,
    Sameer Joshi

    Hi Raymond,
    Yes it was due to the BADI.
    Thanks for your reply.
    Thanks and Regards,
    Sameer Joshi

  • Vendor name not showing correctly in TDS GL line item display fbl3n

    Hi Gurus,
    I am facing an issue in regards to TDS. As you know that normally we make a cheque payment to a vendor, we issue one cheque for one vendor.
    But my client follows a slightly different practice. Suppose they have to pay an amount of 30000 to three vendor A B C equally 10000 each. They right a self cheque to the SBI bank and also send them the list of these 3 vendors who are also having their account in the same bank. They instruct the bank to take money from their  account and then credit in the respective vendors account.
    Now the transaction goes like this:
    Vendor A   10000
    Vendor B    10000
    Vendor C   10000
        To Bank                 29700
        To TDS on A              100
        To TDS on B              100
        To TDS on C              100
    Now when the user will go to FBL3N and check the TDS GL 100020196 and see the line items it should show like as per the client:
    Vendor A       100
    Vendor B       100
    Vendor C       100
    But it shows the below result:
    Vendor A   100
    Vendor A   100   ( should be vendor B)
    Vendor A   100   (should be vendor C)
    I believe that is the standard behavior of the system to show the vendor line. They do not want to change the way of their posting and their concern is if it shows like the same at the time of return filing how will know vendor wise tds.
    Now either I need to resolve this situation in FBL3N or give them a report which should give them Vendor wise TDS information for the TDS filing.
    J1INMIS report is there but it shows only the TDS and the vendor number, it does not give the vendor name. I either want a solution of this issue in FBL3N or a report which shows vendor wise TDS with vendor number and name. Please let me know if there is a solution to this issue.
    Kindly consider this very urgent.  I am attaching the relevant screenshots.
    Thanks
    Urmila

    Hi
    Unfortunately there is no report in SAP other than J1INMIS which caters to Indian reporting requirements. You can think of enhancing the same.
    Also check your enhancement for FBL3N as to why it is not working as it should with the help of your ABAP Colleagues. It is not displaying the name correctly.
    Thanks & regards
    Sanil Bhandari

  • Report GL Account Line Item with vendor name and VAT registration number

    Hi,
    Is there any standard SAP report/inquiry for GL Account Line Item like FBL3N, with information vendor name and VAT Registration Number (field STCEG) without using ABAP.
    Thanks.

    Hi,
    We can get purchase register through T.Code: 'J1I2' by specifying condition types and tax codes.
    We can't get 100% report from this T.Code.
    Check it once.
    Regards,
    Padmaja N.

  • Fbl1n and fbl5n line item wise display the cutomer and vendor name

    Hi,
    My user is asking report for fbl5n and fbl1n line itemwise dispaly vendor and customer.See the report for one time vendor and customer name displaythe line item wise display in FBL!N/FBL5N. but not the display the regular vendors/customer.So one time table name BSEC
    Please advise
    Regards.
    Edited by: yps y on Nov 13, 2008 1:26 PM

    Hi,
    line item reports FBL1N/FBL5N are reading the line items (wow, what a big surpise ) and displaying information on line item level.
    As the vendor/customer name is NOT stored in the line items, you cannot display this in the lines (along with other item level information., like amount, posting key, doc.type, etc.). You may find a field called "Name 1) in the field catalog when configuring the ALV layout but this is empty for normal customers/vendors. It is only filled in for one time (Cpd) customers - the reason is as explained above: for these special accounts, the name IS stored on line item level (it varies from item to item),, that's why it can be read and displayed in the items.
    Now how about normal customers/vendors?
    You have to activate Business Transaction Event 1650 and implement a simple code so that depending on the account type (D = customer, K = vendor), you get the business partners name from table KNA1 / LFA1 and put it into field Name1.
    Hope that helps, points welcome
    Csaba

  • Vendor name in g/l line item display

    Hi,
    I have a requirement to get the name of the Vendor in line item display of Rec. G/L code. In standard reports FBL1N and FAGLL03 we can get only vendor code. Is there any possibility to insert the vendor name in standard report or any alternative report available in the system.

    Hi Sridhar,
    If you want to display the report on the system, then you may look at the options suggested above by other friends.
    If your requirement is to download the report, then you can have a vendor list seperately, download the normal FAGLL03 report and run a simple vlookup function and get the names of the vendors.
    Regards,
    Mike

  • Item Preferred Vendor Name with OINM OITM and OMRC

    Hi all
    How to add Item Preferred Vendor Name to this Query?
    SELECT T0.[ItemCode],T1.CardCode, T1.FirmCode, T2.FirmName, T1.ItemName, sum(T0.[InQty])[In Quantity], sum(T0.[OutQty])[Out Quantity],sum(T0.[InQty]) - sum(T0.[OutQty])[Balance Quantity],  T0.[Warehouse], sum(T0.[TransValue])[TransValue] FROM OINM T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OMRC T2 ON T1.FirmCode = T2.FirmCode WHERE T0.[Warehouse]  between [%0] and [%1] and  T0.[DocDate]  <=[%2] GROUP BY T0.[ItemCode], T1.CardCode, T1.FirmCode, T2.FirmName, T1.ItemName, T0.[Warehouse]
    Kedalene

    Hi,
    Try this:
    SELECT T0.[ItemCode],T1.CardCode, T0.[CardName],T1.FirmCode, T2.FirmName, T1.ItemName, sum(T0.[InQty])[In Quantity], sum(T0.[OutQty])[Out Quantity],sum(T0.[InQty]) - sum(T0.[OutQty])[Balance Quantity],  T0.[Warehouse], sum(T0.[TransValue])[TransValue]
    FROM OINM T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode and T0.[CardCode] = T1.[CardCode] INNER JOIN OMRC T2 ON T1.FirmCode = T2.FirmCode left join OCRD T3 on T1.cardcode = T3.cardcode
    WHERE T0.[Warehouse]  between [%0] and [%1] and  T0.[DocDate]  <=[%2]
    GROUP BY T0.[ItemCode], T1.CardCode, T1.FirmCode, T2.FirmName, T1.ItemName, T0.[Warehouse], T0.[CardName]
    Thanks & Regards,
    Nagarajan

  • IView to search vendor code based on Vendor  Name

    Hi Guys
    We have developed an Web Template in BW 3.5 to browse quality score for our suppliers.  The selection screen is expecting to have a Vendor Code Number being input.  However, our management is not always aware of the code.  The dimension used in 0VENDOR. Did somebody create an application (BSP, JSP, ...)to we could put in a EP6 iView that would allow me to enter a partial segment of a vendor name , it would go either in R3 or BW, and it would return all the vendor code(s) containing the segment and then I would be able to choose the vendor code i want to extract data from... Basically something similar than performing a search from MK03
    Thanks!
    Eric L.

    Thanks for the reply.
    My manager posted many of his articles through his meta link ID but kept my name as the Author.
    So I want to go through those metalink notes. Since my manager has left the current organization I am unable to reach him
    Please guide me

  • Vendor name is deleted after the approver changes the product category.

    Hello,
    We have implemented workflow WS14000044(Completion by Purchaser) and
    WS14500015(Item-Based Main WF).
    At workflow WS14500015 level, when the approver changes the product
    category, the vendor name is deleted.The previous validation allows the
    PO creation , But the PO is created without vendor.
    Furthermore under transaction process purchase orders 'BBP_POC' the
    purchaser can not access in change mode to the vendor field in order to
    add a vendor.
    How can we give access in change mode to the vendor field for purchaser in transaction 'BBP_POC' ?
    Regards,
    Lina

    Hi,
    Which SRM version are you working on?
    Please see if the foll notes help:
    <b>801591 Source determination after item change</b>
    881346 Vendor incorrectly deleted
    873972 Sources of supply in the shopping cart with catalog items
    908178 Transferring reference: Deleted vendor
    Note 829652 - Completion workflow in shopping cart: Vendor
    789087 Changed product category: Vendor not deleted
    BR,
    Disha.
    <b>Pls reward points for useful answers.</b>

Maybe you are looking for

  • How to assign scripts in nace?

    what is the use of nace?

  • Calling Adobe form via ABAP Web Dynpro

    Hi Ive followed the below WIKI and have encountered an issue and finding it rather frustrating to resolve http://wiki.sdn.sap.com/wiki/display/WDABAP/CallAdobeFormthroughABAPWebDynpro Im fairly new to this to pls excuse my ignorance The message Im ge

  • System & Installation Numbers are missing from Service Manager

    Hi All, We have just upgraded a system from 2007A to 8.8 and when you start the Service Manager the System and Installation Numbers are missing. Any idea as to why? Best regards Earl

  • Searching folders in Disco Admin

    Hi, I have multiple business areas opened in Discoverer Administrator. How do I search for a folder name in these business areas? I just want to make sure before creating another folder that something similar does not exists. Thanks.

  • Updating Windows in Boot Camp

    Once Windows is installed in a bootcamp partition, how should I install updates to the drivers? Is using Windows update a safe bet, or should I just stick to the bootcamp drivers? In specific, I'm reffering to updates to things like the graphics driv