Query minimum quantity

Good Morning Guru,
I have 2 tables, master inventory and master bill of material,
master bill of material is a produce structure that raw materials(RM) were needed to make a finish product (FG)
create table inven
( stock_num varchar2(10),
category varchar2(1),
QTY_OH number(10)
create table bom_d
( FG varchar2(10),
RM varchar2(10)
insert into inven values('A','F',0);
insert into inven values('B','F',0);
insert into inven values('A1','R',10);
insert into inven values('A2','R',7);
insert into inven values('A3','R',12);
insert into inven values('B1','R',10);
insert into inven values('B2','R',10);
insert into inven values('B3','R',5);
insert into bom_d values('A', 'A1');
insert into bom_d values('A', 'A2');
insert into bom_d values('A', 'A3');
insert into bom_d values('B', 'B1');
insert into bom_d values('B', 'B2');
insert into bom_d values('B', 'B3');
commit;
select * from inven;
SQL> select * from inven;
STOCK_NUM C QTY_OH
A F 0
B F 0
A1 R 10
A2 R 7
A3 R 12
B1 R 10
B2 R 10
B3 R 5
SQL> select * from bom_d;
FG RM
A A1
A A2
A A3
B B1
B B2
B B3
SQL> select fg,rm,stock_num, qty_oh
2 from inven i, bom_d b
3 where rm=stock_num
4 /
FG RM STOCK_NUM QTY_OH
A A1 A1 10
A A2 A2 7
A A3 A3 12
B B1 B1 10
B B2 B2 10
B B3 B3 5
I want to display :
only one for each FG that has minium qty_oh
(I want to display as bellow)
FG RM STOCK_NUM QTY_OH
A A2 A2 7
B B3 B3 5
need help, how to make the sql?
using oracle 8i
Thank you very much

Hi,
That's called a Top-N Query .
Here's one way to do it:
SELECT     fg
,     rm
,     stock_num
,     qty_oh
FROM     (     -- Begin in-line view to compute r_num
          SELECT     b.fg
          ,     b.rm
          ,     i.stock_num
          ,     i.qty_oh
          ,     RANK () OVER ( PARTITION BY  b.fg
                                  ORDER BY          i.qty_oh
                              ) AS r_num
          FROM     bom_d     b
          ,     inven     i
          WHERE     b.rm     = i.stock_num
     )     -- End  in-line view to compute r_num
WHERE     r_num     = 1
;What do you want to do if there happens to be a tie for the lowest qty_oh (for example, if you change the qty_oh to 10 for stock_num='B3')? The query above will include all the items with the lowest qty_oh (that is, all 3 rows with fg='B' and qty_oh=10).

Similar Messages

  • Minimum quantity in sales order

    Hello friends,
    Can anyone tell me how to maintain minimum quantity in sales order, (Not Minimum order quantity of material master) as only maximum (target) quantity is maintainable in sales order at Item level? So after this development in sales order, one can enter two quantities (minimum and maximum) so that sale can be done between this quantity range.
    I know this is not possible without exits or developments, but please tell if someone has came across the same scenario which exits used by you.
    <b>Required Minimum Order quantity Field in Sales Order at item level like Cumulative Order Quantity in Sales Units (VBAP-KWMENG) at proper position in Transaction-> VA01-VA02-VA03.
    Program name: SAPMV45A Screen number: 4900 or wherever it is adjusted at item level i.e. Additional Data B Tab.</b>
    Thanks in advance
    Warm regards
    Amit

    Hi Prabhu Peram,
    I want to maintain a input field can you throw some light on the same.
    Regards
    Amit

  • Adjust to Minimum Quantity for Subcontracting Order

    Dear guru.
    I can set up the Control profile in purchasing customizing in order to round to the minimum quantity filled in the info record.
    I have verified that this happen only for standard purchase order.
    Do you know a solution in order to Adjust to the Minimum Quantity also for Subcontracting Purchase Order ?
    Thanks in advance

    solved. it was a my mistake

  • Setting up minimum quantity at HEADER level at ARUN

    Dear Experts,
    We have a requirement in each order that there must be a minimum of 10 pc allocated before a delivery can take place.
    I know for the ARUN setting that you can set up a release rule but this is using a percentage.  Is there a way where I can set it up with no. of pieces instead?
    Thanks very much and look forward to your reply.
    Kind regards,
    Jenny

    Hi Chetan,
    Sorry that I didn't explain it clear enough.  What I'm trying to set up is not the minimum quantity that a material must be ordered.
    What I would like is that e.g.:
    Sales order:
    Item 10 = 5 pc
    Item 20 = 5 pc
    Total pc of this order = 10 pc
    At allocation run, if there are only enough stock of 5 pc for Item 10 and 4 pc for Item 20, giving a total of 9 pc of allocable quantit then since it is not meeting my minimum quantity of 10 pc, the result would bee that no allocation should be done (and no reservation is needed, so just drop the order).
    At the moment, this set up is based on a percentage i.e. 80% fullfillment etc before a order can be allocated (under "Release Rule" setup).  I would like to make it as a no. of pieces and not percentages.
    Please advice if this is possible in SAP.
    Many thanks,
    Jenny

  • Minimum Quantity in Sale Order based on Ship To Party city

    Dear Experts
    It is possine in Std SAP to get information or error message based on Minimum Quantity in Sale Order based on Ship To Party city??
    Thanks
    Krishna

    No it is not possible.  You have to go for sale order User exits in the program MV45AFZZ - USEREXIT_SAVE_DOCUMENT_PREPARE
    thanks
    G. Lakshmipathi

  • Help me.... (Minimum Quantity Order) in Sales Order

    Dear guru
    i have created Material like mobile phone, in material Sale-org 1 i have mention minimum quantity as 5 no to be order and i creat sales order as 2no of mobile phone, but the minimum quantity display mesage showing like total weight, not total quantity, how can i display error message like min quantity 5 no  should to be order.
    regards
    Mohammed Renu
    [email protected]

    Hi
    Check the unit of mimimum order qty in MM01... That may be as KG...
    <b>Minimum Order qty Unit will be same as Base unit of measure...</b>
    If You have KG there you have to maintain base unit of measure as you need may be EA-each/PCS  for your requirment...
    Reward if helpfull
    Muthupandiyan

  • Minimum quantity sales order

    Hi all,
    Am trying to restrict (via a warining message) users from creating sales orders with less than a minimum quantity for a given material and a given customer. I read in some threads that I should use transaction VD51, but the only thing I can do is to specify minimum delivery quantity. Can you please suggest a solution? Thanks

    Hi,
    Since your scenario of minimum order qty, setting it in the material master might not solve as you told. But you can think of creating dummy contracts ( quantity contracts ) for those customers whose those minimum order quantities as per your requirement. And whenever you want make a sales order for these customer make sure refer these contracts and reference the quantity fully. Now, from the quantity contracts
    customer A - 5, B - 10 so on ...., units is copied into sales order as you desired.
    Hope it helps. Please reward if useful.
    Also just to add, since you are new I suggest you practice and understand the various functionalities provided in SAP that you can on your own imagine these kind of options where you use the application as per the requirement.
    Thanks & Regards
    Sadhu Kishore

  • Prices conditions, minimum quantity and multiple

    Hello,
    I am currently working on SRM 5.0 on which I am going to plug MDM 2.0.
    I was wondering 2 things:
    1. Is it possible, in standard SRM, to specify price conditions for full catalogs items (there is no Material Master managed in SRM). For example:
       - If someone orders a quantity of pens between 1 and 10, he will pay 1€/pen
       - If someone orders a quantity of pens between 10 and 100, he will pay 0,8€/pen
       etc
    If it is not possible, do you know if we can do it in MDM?
    2. Is it possible, in standard  SRM, to force user to order a minimum quantity of items, and to force him to only orders multiples of this order quantity?
    If it is not possible, do you know if we can do it in MDM?
    Thanks for your help,
    Patrick

    Hi Patrick
    1) Is possible in MDM Catalog
    2) Not standard. You can achieve this using BBP_DOC_CHECK_BADI.
    Best regards
    Ramki

  • Put unit measure and minimum   quantity article dtw

    Hello,
    I want to put, through dtw, in registry item, its  unit buy   and minimum quantity of purchase, I used baseunitname and minorderquantity column, but not me uploaded your data, why? Which should I use column. thanks

    For Inventory UoM on Inventory Data Tab use <b>InventoryUOM (in DTW template)</b>
    For Purchasing UoM on Purchasing Data Tab use <b>PurchaseUnit (in DTW template)</b>
    For MinLevel (Minimum Inventory Level) on Inventory Data Tab use <b>MinInventory
    (in DTW template)</b>
    Suda

  • Query Designer : Quantity Conversion as per UOM

    Hi gurus,
    I am facing a typical situation here. I have Product Quantity data that I fetch from R3, This has diff UOM based on different product. I know the conversion factor. I have not included the conversion factor in the transformation while loading the data. Hence in the cube, the data is loaded without any conversion.
    Now, in my query, I want that the Quantity data be displayed always in say BOX (Whether at aggregate level, ex. Sales Office level or at a more granular level (product brand level)) it should always be in BOX. Can I make such a modification in my query so that the end result for quantity should always be in BOX.
    thanks n regards,
    Sree

    Hi Sree,
    You can set unit conversion for relevant key figures in the Query Designer.
    For that, you need to create a quantity conversion type first.
    For a BW7.x system, use transaction RSUOM to maintain quantity conversion type.
    It could be defined like this:
    Source unit: from data record
    Target unit: fixed: BOX
    Hope this helps.
    Regards,
    Patricia

  • Quantity Contracts for minimum quantity and above

    Scenario:
    1.     Customer Can order materials which are mentioned in the list of materials provided by him.
    2.     The company has agreed to give customer bonus on quantity ordered. The bonus will also be in terms of quantity as free   goods. (for e.g 0-100 mtonnes, free good will be 10 mtonnes)
    3.     The bonus quantity can be adjusted among the materials ordered. (It can be adjusted using one material or using all the materials (no percentage distribution defined)
    Is there a scope in SAP Contracts to configure this type of contracts?

    Hello Will,
    You can configure a Common Distribution Channel and a Common Division and assign them to all the sales orgs in the system and maintain customer master data in this common sales area
    then you can create a sales order with reference to a contract maintained in any sales area
    but I'm not sure how you are maintaining the pricing condition records and its behaviour when you create a sales order
    please let me know whether you succeed by this configuration
    regards,
    Santosh

  • Condition type if you order a minimum Quantity.

    Hi,
    Does anybody know what condition type I need to know if you have to pay more if you order under a certain quanity? I know that you can use MM00 for minimum value.
    Best regards,
    Eric.

    Hi,
    You could have a look at using scales for this if the price is dependant on how many you order?
    But if you just want an extra charge of X if the qty is less than the minimum order qty set in the info record, then you will have to create a new condition type and use some clever coding etc. to ensure that it is only triggered when the minimum order qty has not been reached.
    Steve B

  • Query - Delivered quantity at schedule line of Sales Order

    Hi,
    I've realized a sales order report and i need extract for each schedule line the delivered quantity (VBEPD-VSMNG). How can i find the correct values?
    Thanks and best regards.
    Antonio

    Hi.
    You can use the function module RV_SCHEDULE_CHECK_DELIVERIES to get the delivered quantity corresponding to schedule line item  in sales order.
    Please refer below code:
    Internal table it_vbep has got field VSMNG which is the delivered quantity for each line item
      SELECT * FROM vbfa
        INTO  TABLE  it_xvbfa
        WHERE vbelv = <sales order numer>
        AND posnv = <sales order line item>
        AND vbtyp_v = 'C'.
        SELECT  * FROM vbup
        INTO TABLE it_xvbup
        WHERE vbeln = <sales order numer>
        AND posnr = <sales order line item>.
        SELECT * FROM vbep
        INTO TABLE it_vbep
        WHERE vbeln = <sales order numer>
        AND  posnr = <sales order line item>.
        SELECT  * FROM vbap
        INTO  TABLE it_xvbap
        WHERE vbeln = <sales order numer>
        AND  posnr = <sales order line item>.
        CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
          EXPORTING
            fbeleg                  = <sales order numer>
            fposnr                  = <sales order line item>
          TABLES
            fvbfa                   = it_xvbfa
            fvbup                   = it_xvbup
            fxvbep                  = it_vbep
            fvbap                   = it_xvbap
          EXCEPTIONS
            fehler_bei_lesen_fvbup  = 1
            fehler_bei_lesen_fxvbep = 2
            OTHERS                  = 3.
    Regards,
    Sameer

  • Purchase order minimum order quantity

    If mininum order quantity is 5000 for a particular material code. We have 3 PRs with quantity 2000, 1000, 500 ea. When we create PO w.r.t. these 3 PRs system creates PO with 5000 Ea quantity for each PR. There by the PO quantity is 15000.  Client requirement is that when these 3 prs are converted into a single PO, the quantities should get added first and then rounded.
    In this case 20001000500 = 3500 (added quantity) and then minimum quantity of 5000 should be ordered. Kindly suggest.

    Dear
    Goto MRP1 VIEW -Keep Mini  Lot size as 5000  .Test it in Sand box with a demand of 2000 and run MRP MD03 , I hope it will generate PR of 5000  if you do not have any stock .
    You can also keep period lot size ( MB/WB) in MRP1 view with Individual and Collective Indicator ( MRP4)   so that it will club all the requirement in that period and generate on PR of total qty
    Check and revert back
    Regards
    JH

  • MINIMUM COMPONENT QUANTITY

    Dear Gurus
        when i am going to create the bom in which total 7 component are there.but out of 7,three components are alternative of each other,suppose A,B and C are these components whose uom is kg. i have alredy defiened these components in bom with minimum quantity 0.1 kg,but i have to replace  quantity with zero but it is not accepting.is there any setting where i can give quantity zero duing creating BOM.
    thanks
    kk

    Hi Kedar
    Quantities cannot be zero in bom, it the 3 component materials are alteranative materials use alternative item group. using this u can select either of the materials while doing the GI.
    U have 2 strategies in this
    1. By usage probability: in this case u give usage probability of this material and this material is used in that % while doing GR
    2. By 100% check: in this case it uses the component which is 100% available.
    The 2 one may not be useful for u , use the 1st one with probability zero for the component for which u want to keep the quantity as zero.
    Regards
    Prasad
    Reward if found useful.

Maybe you are looking for

  • How to edit text on PDF form in Acrobat 8 professional

    I just took a Word doc and created a form for an application.  The client changed the deadline and I would like to know if I can make that change in Acrobat 8 Prof (MAC) or if I have to make the change in Word, create a PDF and completely re-do the f

  • Resizing Background Image

    I did some google searching...but, I am seeking the ability to have my background image resize to the visitor's browser...not tile, but rezise...I see some older google articles on javascript and CSS3...but, I see flash sites do it enough and believe

  • Stuck in PIO

    Hello, Short version: Can't seem to get out of PIO mode.  Long version: Installed a (new from Tiger Direct) Samsung HM160HC, supposed to be the fastest drive that will work in my A25-S207. I did a clean install of XP Pro and SP3. Got all the relevant

  • Heat ram geforce 6800 ultra

    i'm planning on installing a watercooling on my msi geforce 6800 ultra because the fan just makes way too much noise. therefore i can choose between a complete vga cooling or just a chipset cooling. so i was wondering... does th ram get hot when thei

  • Indesign media files

    Hi,,,,, i placed a flv video in indesign  from c drive. and it plays very well. and saved the file. when i deleted this video from the location of c drive. and then i play it in indesign file. it will not play. would you have any idea about this.