How to rank  according to sales

Hi, im currently need to do a report.
I need to rank my sales numbers desc.
how would i go about doing this?
eg.
rank | description | sales
1 | cosmo | 525
2 | you | 523

Thanks, but i cant seem to make it work.
I actually need 2 paremeters to select the rank:
eg. select rank from: 18 to 25
This is the code i have, but it doesnt work, it brings back all the ranks:
select RANK() OVER (ORDER BY sum(ool.ORDERED_QUANTITY) desc ) "Rank"
, ool.customer_number
,hp.PARTY_NAME
,osf.ORGANIZATION_CODE
,osf.NAME
,sum(ool.ORDERED_QUANTITY) sales
from (select RANK() OVER (ORDER BY sum(ool.ORDERED_QUANTITY) desc ) as rnk
from oe_order_lines_v ool
,hz_parties hp
,hz_cust_accounts hca
,OE_SHIP_FROM_ORGS_V osf
,xxpub_calendar_plan_hdr_v cph
, mtl_system_items msi
,ar_customers_v cust
--,xxwsh_routeman_v xr
where ool.CUSTOMER_NUMBER = hca.ACCOUNT_NUMBER
AND ool.CUSTOMER_NUMBER = cust.CUSTOMER_NUMBER
--AND xr.CUSTOMER_NUMBER = ool.CUSTOMER_NUMBER
--AND xr.LINE_ID = ool.LINE_ID
--AND xr.ROUTE_FUCNTION = 'DELIVERY'
AND hca.PARTY_ID = hp.PARTY_ID
AND ool.SHIP_FROM = osf.ORGANIZATION_CODE
AND msi.organization_id = fnd_profile.value('SO_ORGANIZATION_ID')
AND ool.inventory_item_id = msi.inventory_item_id
AND msi.inventory_item_status_code = 'Active'
AND cph.inventory_item_id = msi.inventory_item_id
AND cph.organization_id = msi.organization_id
AND ool.INVENTORY_ITEM_ID = cph.INVENTORY_ITEM_ID
AND ool.ORDERED_ITEM = cph.PUBLICATION_CODE
AND to_char(cph.ISSUE_NUMBER) = ool.ATTRIBUTE1
) t,
oe_order_lines_v ool
,hz_parties hp
,hz_cust_accounts hca
,OE_SHIP_FROM_ORGS_V osf
,xxpub_calendar_plan_hdr_v cph
, mtl_system_items msi
,ar_customers_v cust
--,xxwsh_routeman_v xr
where ool.CUSTOMER_NUMBER = hca.ACCOUNT_NUMBER
AND ool.CUSTOMER_NUMBER = cust.CUSTOMER_NUMBER
--AND xr.CUSTOMER_NUMBER = ool.CUSTOMER_NUMBER
--AND xr.LINE_ID = ool.LINE_ID
--AND xr.ROUTE_FUCNTION = 'DELIVERY'
AND hca.PARTY_ID = hp.PARTY_ID
AND ool.SHIP_FROM = osf.ORGANIZATION_CODE
AND msi.organization_id = fnd_profile.value('SO_ORGANIZATION_ID')
AND ool.inventory_item_id = msi.inventory_item_id
AND msi.inventory_item_status_code = 'Active'
AND cph.inventory_item_id = msi.inventory_item_id
AND cph.organization_id = msi.organization_id
AND ool.INVENTORY_ITEM_ID = cph.INVENTORY_ITEM_ID
AND ool.ORDERED_ITEM = cph.PUBLICATION_CODE
AND to_char(cph.ISSUE_NUMBER) = ool.ATTRIBUTE1
AND t.rnk <= 5 --:p_rank
group by 1,ool.CUSTOMER_NUMBER
,hp.PARTY_NAME
,osf.ORGANIZATION_CODE
,osf.NAME
Message was edited by:
Shashe
Message was edited by:
Shashe

Similar Messages

  • How to assign version in sales order and transfer to PP module

    Hi all
    Users say that customer will require to produce/deliver old goods (we active revision level. The newest material version is D. But customer want version B). How to assign version in sales order and let PP user know the version customer want (MRP run and production order must use version B's BOM)?
    Regards,
    Rita

    Hi,
    i have a query if you have implimented ECM this will serve the purpose but it also depends on how good the planning is, in ur client site ( out of SAP ) where planner will plan according to the customer requirement as to which version to be kept active for a date range.The ECO analysts(functional) or consultants will make the ECO changes for those dates.
    In general for those type of customers (who needs old version) a different SO created under different document type which will create a production orders with specific order type depending on the assignment of requirement type and requirement class.
    those specific production ordertypes can be inturn assigned to either different plant where your old version BOM's will be active.
    You need to look into the custom settings in SAP to design the larchitecture to allign with other requirements.What i explained u is common methodology used.
    Hope this is clear..
    Prakash
    Message was edited by:
            prakash Uddagatti

  • How to configure rescheduling for sale order quantities

    kindly explain how to configure rescheduling for sale order quantities that are created last month. kindly explain. i am in urgent.
    regards,
    g.v.shivakkumar

    Hi,
    Short text
    Rescheduling sales and stock transfer documents: by material
    Description
    The 'Rescheduling' program (SDV03V02) processes sales document items that are contained in the item directory for the material. It takes into consideration open items and schedule lines from stock transfer items, stock transfer scheduling agreements and purchase order requests (items only), referred to hereafter as stock transfer documents, for the materials.
    All sales documents for the material that are still open are selected. This means that the material index must be activated for at least all sales document types, whose items may have requirements. All stock transfer documents or items for the material that are still open are also selected. Open in this case means for example, that there is no deletion indicator, that the item from a stock transfer purchase order request cannot be labeled as completed or that the quantity delivered and posted to goods issue for the item in a stock transfer purchase order is the same as the amount ordered. An availability check can only be carried out if a checking rule is assigned to the document type - if this is not the case, the document or document item is not checked.
    Checking rule 'A' is used as a basis for rescheduling sales orders (exceptions to this are rush orders  they use checking rule B, and orders with individual customer stock; they use checking rule AE). Stock transfer documents use the checking rule that is assigned in Customizing for Purchasing. It is important that the scope of checks is consistent for both the stock transfer documents and the sales documents and that they do not exclude each other, as this can lead to incorrect test results. An example of an incorrect setting would be: The scope of check for checking rule 'A' checks delivery schedules for stock transfer purchase orders and stock transfer purchase requests, however the scope of check for the checking rule for the stock transport scheduling agreement does not.
    The items and schedule lines found in the selection are sorted according to 'Priorities' - document category, delivery priority, creation date of the item or schedule line (for stock transfer purchase orders and delivery plans) entered on the selection screen or according to the schedule line date of the earliest schedule line with order quantity, document number and item number and then transferred to the availability check. Priority 1 is highest priority and priority 5 the lowest. Stock transfer purchase order requests are sorted after stock transfer purchase orders and scheduling agreements, as they are less binding. This means that when you have identical sort criteria such as delivery dates, the stock transfer purchase order item is checked first and then the item from the stock transfer purchase order request.
    The preset option 'Unconfirmed documents required' only carries out rescheduling for materials for which there is at least one unconfirmed transaction.
    You can use the parameters 'Sorting criteria delivery date' to define whether sorting is carried out with the order quantity after the creation date of the item or the delivery date of the earliest schedule line.
    If you mark the 'Simulation' field, the checked documents are not saved. Instead a results list is generated and saved. However, the availability check for the corresponding documents continues as if saving has taken place already, that is, that the simulated list corresponds to the actual one.
    Under 'Options' on the selection screen, specify whether sales documents and/or stock transfer documents should be processed. For stock transfer documents you can enter whether stock transfer purchase orders and scheduling agreements should be processed at item or schedule line level:
    Processing at item level:
    All open schedule lines for the item are read and collected, then transferred to the availability check. To sort and prioritize documents, you do not need each individual schedule line. It is sufficient to have the item or data from the first schedule line. All open schedule lines for the item are processed and checked.
    Example of processing at item level:
    Sorting: Date (Delivery date first schedule line) - Document number - Document item
    Doc. cat. Doc. number  Doc. item  Doc. schedule line  Delivery date PO        4500000012      10               0001              26.01. PO        4500000012      10               0002              26.02. PO        4500000025      20               0001              28.01. PO        4500000025      20               0002              02.02.
    You can see that the second schedule line for document 4500000025/20 from 02.02 was processed after the second schedule line for document 4500000012/10 from 26.02. This is because all open schedule lines for an item are read and processed. The first schedule line from 4500000012/10 has the earliest delivery date, therefore it has priority.
    Processing at schedule line level:
    Each open schedule line for an item is entered in document sorting in accordance with the values entered under 'Priorities'. The availability check is carried out for each individual schedule line.
    Example for processing at schedule line level:
    Sorting: Date (delivery date first schedule line) - document number -document item
    Doc. cat.    Doc. number  Doc. item  Doc. sched. line  Del. date PO           4500000012    10             0001           26.01. PO           4500000025    20             0001           28.01. PO           4500000025    20             0002           02.02. PO           4500000012    10             0002           26.02.
    Here you can see that each schedule line was sorted according to its delivery date. Note that this type of processing requires more runtime due to the individual checks and more frequent saving.
    The results of rescheduling are saved, as long as the program was not started in simulation mode. When calling up from the 'Sales' area menu or when directly starting via the development environment, the iniator is informed via a dialog box that he has just started a process that changes data. He can then decide whether or not he wants to continue.
    Checking procedure for stock transfer documents:
    An availability check of stock transfer documents in rescheduling is carried out in accordance with the check carried out when manually creating a document. If, however, the required quantity for a schedule line is not available on a particular date and will not be ready until later, new schedule lines are created for the stock transfer purchase orders and scheduling agreements, containing the relevant data. New items are created in this case for stock transfer purchase order requirements. The total sum of schedule line quantities for a processed schedule line corresponds to the schedule line quantity of the original schedule line.
    First example: Using a stock transfer purchase order item with a schedule line:
    a) Status of item before rescheduling run:
    Del. date  PO quantity   Confirmed quant  Confirmed del. date 23.07.      50 items       0 items              -
    ==> This now affects the stock/requirement situation:
        - Goods issue is posted for the material in the delivering plant on the 23.07.
        - A purchase order of 10 items was created for the material in the delivering plant. Delivery is expected on the 29.07.
    b) Status of stock transfer purchase order item after rescheduling run:
    Del. date PO quantity   Confirmed quant   Confirmed del. date 23.07.     40 items      40 items            23.07. 29.07.     10 items      10 items            29.07.
    ==> The first schedule line was changed in accordance with the results of the rescheduling availability check. Only 40 of the 50 original items could be delivered on the 23.07. Therefore, a new schedule line is created for the rest on the 29.07. for 10 confirmed items.
    Second example: Same output situation as the above example.
    ==> There is now a change in the requirement/stock situation:
    A purchase order for 10 items is created for the material in the delivering plant. Delivery is expected on the 29.07. A further purchase shows another 40 planned items on the 30.07.
       Status of stock transfer purchase order item after rescheduling run:
    Del. date PO quantity  Confirmed quant  Confirmed del. date 29.07.     10 items       10 items          29.07. 30.07.     40 items       40 items          30.07.
    ==> The first schedule line was changed in accordance with the result of the availability check for rescheduling. The original delivery date is set to the date confirmed in the ATP check. A new schedule line is created for the remaining 40 items, that are available on the 30.07.
    Note:
    Any set fixed delivery date and quantity indicators and creation indicators for schedule lines or items are 'inherited' by newly created schedule lines. Assuming that the original schedule line was fixed in the above example (since it is created manually), this indicator is also set for the newly created schedule line.
    If shipping scheduling is activated for a stock transfer document type, this is also implemented for newly created schedule lines, with the exception of route schedule determination. This means that in the current version of the program no route schedule has been determined for a schedule line containing a route schedule for which new schedule lines may need to be created.
    The results of the run are issued in the form of a list, which is also saved, so that the results can be controlled at a later date. This is done using the function 'Evaluate rescheduling', but it is only a good idea to do this after the first rescheduling has taken place. You can restrict selection requirements but these can however affect the runtime. You can use this function to analyze the saved list until the next rescheduling run, which writes over the result. If you start rescheduling in the background, a spool file with the result list referred to will be created in the corresponding setting. You can see this in spool management.
    Output
    A list of changed documents, a list of documents in which an error occurred during processing and as a result were not changed, can be called up via the menu 'Edit - Error log'. If in a subsequent evaluation a restricted selection is carried out, a note appears at the end of the list to say that not all document items are displayed.
    You can set the scope of the list under the menu option 'List' in the list display. You can view improvements, deteriorations and the whole list. Before the documents can be included in one or either of the restricted lists, the date or quantity has to have changed so that the item can be contained in both the list of improved or deteriorated documents.
    You can use the interface for changing transactions and the order list to navigate. Use 'Back' to exit the list and 'New selection' to return to the selection screen.
    Recommendation
    You should only start this program occasionally and use very restricted selectin criteria during working hours as it requires enormous system resources.
    Note
    The columns for 'New date' and 'New confirmed qty' only contain entries if the dates or quantities have changed.
    As the system only runs the change check (dates/quantities) per line in the original list, an item whose backlog has increased in the list of improvements. This occurs, for example, if the whole quantity can be delivered at once but at a later date. In this situation, the system determines an increase for the line when it compares quantities.
    Regards,
    Amrish Purohit

  • Maintain Billing Number Range according to Sales Organization / Plant

    Hi,
    How to create Billing Number Range according to Sales Organization / Plant wise...
    Please guide..

    Hi SAP~MM 
    It can be developed through Z Table.Take the help of your Abaper.Check this below link it is useful for your issue
    Number ranges
    Plantwise number ranges
    Let me know if your problem is solved
    Regards
    Pradeep

  • Attachment According to sales area

    Hi Experts,
    Can anyone please tell me how can we configure to get the costomer attachments according to sales area of the customer.
    Thanks.

    HI,
    if ur requirement is to attach a word document or anything to the customer based on sales area first  activate the paramaeter SD_SWV_ACTIVE(take basis help fo r this) and to fulfill ur requirement go the selected sales of the customer (XD02 tcode) and in the sales area tab in the title bar only one select button is there if u click on that it will show attachment list select that and attach the document as per ur wish.
    Regards,
    kishore.

  • How to count number of sales orders generated in a month in SAP SD

    Hi SD Gurus,
    I have a very strange query from client. I have to count the number of sales order created in a month for a z report. For example 30 in Jan, 25 in Feb etc. Could anyone suggest me How to count number of sales orders generated in a month in SAP SD.
    Regards
    Vinod Kumar

    Hi,
    Goto the T.Code "SE16" or "SE16n" or "SE11".
    Enter the table name as VBAK
    Enter the created on date as the starting date of the period and to date as the end date.
    Enter.
    Click on "Number of Entries".It will tell you the number of entries created in a particular period.
    If you want a report,goto the T.Code "VA05n".
    Regards,
    Krishna.

  • Complete MRP status according to Sales order schedule line data

    Dear All,
    Please help me to get technical configuration releted to
    "complete MRP status according to Sales order schedule line data"
    or MRP w.r.t. Schedule line
    Please send fields and table and logic specification .
    Thanks & Regards,
    Ashish Gautam

    You can use following Fm for change sales order
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
      EXPORTING
        salesdocument     = p_vbeln
        order_header_in   = s_order_header_in
        order_header_inx  = s_order_header_inx
        behave_when_error = 'P'
      TABLES
        return            = it_return
        order_item_in     = i_order_item_in
        order_item_inx    = i_order_item_inx
        schedule_lines    = i_sched
        schedule_linesx   = i_schedx.

  • How can I create multiple sales orders with reference to one contract?

    Hello Gurus,
    Can you please how can I create multiple sales orders with reference to one contract?
    thanks!
    Rakesh

    hi
    Lets consider example
    In your contract for line item 1 you have entered qty 100
    You careated sales order with 70 quantity, and now you want to creat another sales order for 30
    For this first you need to check what is your item category in contract (VA42)
    Goto VOV7
    SPRO - IMG  - Sales and distribution - Sales - Sales document item - Define item categories - Go to change mode
    Make the completion rule = B Item is completed after full quantity has been referenced

  • How to find that a sales order for which there is  delivery but no goods

    Hi
    How to find that a sales order for which there is  delivery but no goods issue has been done i.e we have an open delivery for a sales order.
    How in VBUK table can we find  out with the sales order no .
    Thanks in advance

    make use of table VBFA.
    Regards
    Peram

  • How can we reject a Sales order after first Down payment invoice for Italy?

    Hello,
    As a legal requirement in Italy the Down paymenty have to be transformed into real invoices, another legal requirement is that an invoice cannot be cancelled it has to reversed by a credit memo.
    I would like to know in this context how we can reject a sales order line once a Down payment invoice has been emitted.
    When I do enter a reason for rejection in the sales order line I receive the message : V1036: Subsequent documenst exist for item XXX and then V2432 Cancellation not possible. Down payment request already created.
    I can create a down payment credit memo in order to cancel the down payment invoice but how can I get rid of my SD requirement in MD04 if I cannot reject the sales order line?

    Hello,
    have you tried using a recjection code which is not relevant for billing?
    Regards,
    Uli

  • How to create a new sales order to internal requisition?

    Hi, All
    Need help!!!
    How to create a new sales order to internal requisition?
    The internal requisition has generated order sales but this has already been canceled, so I need to create a new sales order to the same internal requisition.
    How to release the internal requisition to re-create new sales order and after import in OM?
    please help me
    Thanks and regards
    Manuel,

    You cannot.
    Once a ISO is generated for an IR, the transferred_to_oe flag is set on that req.
    If the ISO was canceled, you should cancel the IR and create a new one.
    Hope this helps,
    Sandeep Gandhi

  • How user can get a Sales Text for the any Line Item in the Billing?

    Salute Masters ! !
    How user can get a Sales Text for the any Line Item in the Billing?
    It's coming for other Order (Line Item for Bought out Item at Project Site - Some Item they procure at project site & complete the task).
    Where I can configure in system for all.
    Rgds
    Srivastav
    09973504950

    Hi,
    Sales text can be copied from customer to order , order to delivery and delivery to billing .
    Check the T-code : VOTXN , do the customization as per your requirement.
    check the below link :
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/dd/55f993545a11d1a7020000e829fd11/content.htm

  • Purchase according to sales

    hi all,
            my client want Purchase order report according to Sales order after MRP run and  Order recommendation run, i.e which purchase order(child item) belongs to which sales order.
    thanks
    rahul

    You may check these threads:
    PO from SO
    Re: show SO# on purchase order

  • How we add & grandtotal of sales order report in alv

    hi guru how we add & grandtotal of sales order report in alv
    regards
    subhasis

    hi subhasis,
    since u want the grand total in ALV use the following code...
    clear gs_fieldcat.
    gs_fieldcat-fieldname = field.
    gs_fieldcat-tabname = DB table
    gs_fieldcat-seltext_m = text.
    gs_fieldcat-do_sum = 'X'
    gs_fieldcat-datatype = data type (Curr or Quant)
    gs_fieldcat-ref_fieldname = reference field name
    gs_fieldcat-ref_tabname  = reference table name
    append gs_fieldcat to gt_fieldcat.
    hope this will work...
    please reward points in case usefull
    regards,
    prashant

  • How can I create a sales order with reference to a purchase order?

    How can I create a sales order with reference to a purchase order?
    Thanks in advance...

    Hello,
    you can't create a sales order with reference to a purchase order. You can input customer PO nuber in the sales order Purchase Order number filed.
    Prase.

Maybe you are looking for