Joining Sales Orders and Delivery Notes in Query

Hi Experts
Please could someone provide me with the correct SQL syntax for joining tables ORDR, RDR1, ODLN and DLN1 in a query?
I need to show a list of the (rows of all open sales orders) and (closed sales order (which have a delivery note) between certain dates).
Thanks
Jon

Hi Gordon
Thanks for your help.  Could you help me a little further?  I am writing the query to show me a mixture of (Open Order rows which contain item code 'C&P') and (closed orders between 2 dates which also contain C&P) - both need to have the customer having property 54 set as 'Y'
Working with what you sent me it almost works but for some reason I cannt fathom it won't show the open orders only the closed.  I think it may have some do with my last JOIN
This is what I have:
SELECT T0.DocNum 'Delivery No', T0.DocDate 'Delivery Date',  T3.Quantity 'Delivery Quantity', T1.DocNum 'S/O No', T1.DocDate 'SO Date', T1.DocStatus, T3.ItemCode, T3.Dscription, T2.Quantity 'SO Quantity', T2.Quantity-T3.Quantity 'Balance Quantity', T2.LineTotal'C&P Price After Discount', T2.DiscPrcnt, T2.Project, T4.QryGroup54'Carriage Deal', t2.freetxt, t1.comments
FROM DBO.DLN1 T3
INNER JOIN DBO.ODLN T0 ON T3.DOCENTRY = T0.DOCENTRY LEFT JOIN DBO.RDR1 T2 ON T3.BaseENTRY = T2.DOCENTRY AND T2.ItemCode = T3.ItemCode LEFT JOIN DBO.ORDR T1 ON T2.DOCENTRY = T1.DOCENTRY INNER JOIN OCRD T4 ON T0.CardCode = T4.CardCode
WHERE (T2.ItemCode LIKE 'C&P%%' AND T1.DocStatus='O' and t4.qrygroup54='Y')  or (T2.[ItemCode] LIKE 'C&P%%' AND T1.[DocStatus] = 'C' and T4.QryGroup54='Y' and (T0.DocDate Between '[%0]' and '[%1]'))
Thanks
Jon

Similar Messages

  • Status of sales order and delivery notes

    Hello,
    what is the status of sales orders that permit to create delivery notes for this sales orders.
    And what is the status that block us to create delivery Notes.
    Regards.
    Zied.

    Hi..
    1. The over all status of the sales order in header shuld be Being processed...Rejection status shud be  nothing rejected..Delivery status shuld be Not delivered....Credit status shuld be Approved/released
    2. Status will be Blocked if any block is assing to the sales order or else it wud be Not blocked
    Reg,
    JJ
    Edited by: Jagsap on Nov 25, 2009 11:03 AM

  • I am not able to get in sales order and delivery  24 hours

    Hi Frinds,
    i am not able to get in sales order and delivery  24 hours even i have defined pick pack time wrkdays 24hrs in
    CONFIG PATH:-Implementation Guide for R/3 Customizing (IMG) -> Logistics ->Execution->basic shipping Functions-> scheduling-> Delivery Scheduling and transporting Scheduling -> Define Scheduling by Shipping Point Or Transaction code:-OVLZ.
    Expected  Results:-Create sales order and delivery and check that the delivery The order has 24 hours after the transfer order is confirmed to allow time to pack order
    *can you help any body  to get in sales order and delivery  24 hours .
    Regards
    Madhu

    Dear Madhu
    Apart from OVLZ, you can also check in VOV8 where for your sale document type, check whether any value is maintained in the field "Lead time in days" at the bottom screen.
    thanks
    G. Lakshmipathi

  • Quantity and Price Totals on Sale Order and Delivery Order

    Dear ABAP Gurus,
    I want to add totals of line items (Quantity and Price) in sale order and delivery order screens. Can you please guide me how to do this. The price can be any from pricing procedure ie exclusive or inclusive price of sales tax.
    regards,
    RSA
    Moderator message : Requirements dumping not allowed, show the work you have already done, thread locked.
    Edited by: Vinod Kumar on Jan 28, 2012 9:23 PM

    Hi,
    Try this :
    IF @transaction_type in ('A','U') AND (@OBJECT_TYPE='22')
    BEGIN
    If exists (SELECT t3.docentry FROM OWOR T0  INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry left join POR1 T2 on T2.[U_JONum] = T0.[OriginNum] and  T0.[ItemCode] =  t2.U_SubConItem] INNER JOIN OPOR T3 ON T2.DocEntry = T3.DocEntry WHERE T1.[PlannedQty] <> T2.[Quantity] and  T1.[ItemCode]  = 'subcon' and  T3.DocEntry = @list_of_cols_val_tab_del )
    Begin
    SET @error = 10
    SET @error_message = 'Not allowed to add more than planned'
    End
    End
    Thanks & Regards,
    Nagarajan

  • Abap Report including sales orders and delivery data.

    Hi Experts,
    I Want to develop a new abap report which would contain the data for sales orders and delivery.
    I want to fetch all the sales orders based on the ship date (LIKP-WADAT_IST) of the delievry.
    Could anyone please let me know how to fetch teh data or is their any function module which would help me to solve my problem.
    <Removed by moderator>
    Thanks,
    Komal.
    Moderator message : Spec dumping not allowed. Thread locked.
    Edited by: Vinod Kumar on Aug 10, 2011 1:25 PM

    post this in ABAP forum for quicker response.
    Regards
    Raja

  • Quantity is different from sale order and delivery

    Hi,
    Gurus,
    Quantity is different from sale order and delivery.
    I identified the Material in the sales order, the item category for this material as BOM.
    I have also checked the bill of material display header overview. The Base Quantity maintained as 1000 EA3. The SUBITEM maintained in G in the unit field in bill of material display.
    Accordingly i have checked the same for material master's additionl data in Units of Measure tab, it is mentioned the basic unit as 1000 EA3 and alternative unit as 600 G.
    My client processed the order for 100 QTY. The QTY for the two sub item is 99.601 each in the sale order.
    My client Question is why in delivery the Material Qty is coming as 99.730 and the SUB ITEM is coming as 99.330 EACH.
    Note:- The material X is maintained in EA3 in Bill of material header overview. I do no how the sale unit came as G for the Material in sale order.
    The other two sub item is perfectly coming as G. Because it is maintained in G in the Bill of Material Display.
    Guide me GURUS.
    Thanks and Regards,
    ANAND

    Hello Rumar
    I guess you entered the text manually in the sales order. The Ship-to may not be having any text, but the Sold-to may be and it may be coming from sold to.
    In transaction VOTXN, check the access sequence for the text type id and see which one takes precedence - one from customer master or from the order by checking the order of accesses.

  • In Sale Order and Delivery - Inventory should be effect

    Dear Experts,
    i am having a scenario that in sales order and delivery, on material items inventory should not be effected.
    How i can acheive this.
    Please let me know the solution.
    With Regards

    Hi Mr.Rachumallu,
    I am not very sure about your question but if my understanding is right, you can acheive it through the VTLA Tcode and for the Item category of the suitable delivery and sales document combination you need to maintain the pos/neg quantity as "Zero".
    I hope I am helping you.
    Regards
    Vijay

  • Availability check on storages in sales order and delivery documents

    Hi all,
    I'm verifying if it's possible to find a standard or a custom solution for this type of problem:
    I have a scenario in which there are more storages relevant for MRP (ex. 01, 02, 03, 04), and, in if I check availability in sales order or delivery (using checking rules "A" or "B") with setting which considering storages location inspection in availability check control, system check if there's stock available on all these storages.
    I'm trying to verify if it's possible to consider only some on these storages (ex. 01 and 03 only) in sales order and delivery documents availablity check.
    I know that in sales order storage location field is normally filled only using exit, but i don't know if it's possible to do, using a user exit, check availability considering only some storages and not all. At delivery level i have tried to use stock strategy, but this functionality don't have consequences on availability check, also if it's relevant during good issue phase.
    Any suggestion will be appreciated.
    Regards
    Gianpaolo

    Hi Gianpaolo,
    We had some issues with availability check on a Customer Site.
    I don't remember right now if we had to exclude storage locations from MRP to take them out from ATP, but I guess Shiva is 100% correct.
    At the end, what was done was to always "force" a unique storage location in the sales order item, which will be the storage location used for shipping of the delivery of course.
    If you use WM in your plant, then you will have no problem in having a unique storage location, so no problem.
    Anyway you are correct in your analysis, if the Storage location is not informed in the sales order item, then all the plant stock is taken in account for ATP.
    Best Regards,
    Franck
    Freelance Logistics SAP Consultant

  • How to block sales order and Delivery order based on payment terms ?

    Hi  experts ,
    I have an sceneria to block the sales order and delivery based on payment terms ?
        For eg )  Customer payment terms  is Z001 which is 5 % discount within 30 days , No discount within 60 days.
                        My requirement here is a)   if open item exceeds 30 days , delivery to be blocked
                                                               b)  if open item exceeds 60 days , Sales order to be blocked..
    Pls give me a solution....

    HI Kakas,
    If possible in configuration , pls let me know .
    payment terms is     5 % within 30 days if customer pays
                                     No discount  within 30 to 60 days if customer pays.   
    Here , i need to control , sales order to be allowed and delivery not to be allowed  for a customer if any open invoice within 30 to 60 days and sales order to be blocked if  open invoice exceeds 60 days..
    Is this possible in Credit management ?.. 
    pls let me know...
    with Regards
    S.Siva

  • Sales Order and Delivery

    Hii
    Is it possible to delete the sales order and delivery documents after adding it.
    for eg.
    Customer C001 created sales order and then made delivery.
    Is it possible to delete that sales order and delivery document and trasactions done related to it.what will be its impact.
    Can we do this.
    reply
    Thanks
    Neetu

    Neetu,
    Change posting period if delivery is not in current month.
    In 2 ways you can return a delivery
    1. Copy To from delivery.
    2. Copy From from return.
    You can return using any of 2 ways as below
    1.Open reqd. delivery click Copy To and select return,
    Change posting date,due date,document date if required,
    once again apply tax code it is removed on changing posting date,Check Doucment total match with delviery
    enter remarks for returning.Click Add to save it.
    2. Open return select required customer code,enter posting
    date,due date & document date as in delivery,Click Copy From
    Select required delivery,Use document wizard,Copy all data,
    Click add to save it.
    3. If items are excisable then copy return to incoming
    excise invoice,Enter excise reference number in it,
    Click add to save it.
    Now return process is completed,status of sales order & delivery & and also return document.
    Jeyakanthan

  • How to configure route in sales order and delivery

    Hi friends,
    Can any one explain about Route determiantion steps. It has to take the route automatically in sales order and delivery also.
    i have configured
    shipping condition, transportation group, transportation zone, plant, shipping point determination, actual route by proposalroute.
    Apart from this what are the remaining steps, but it is not picking  in sales order and delivery.
    please any one send the steps for route determination. its very urgent for me.
    Thanks & regards
    Raju

    hi,
    Route is determined
    1.Country of Departure & Departure Zone taken from Shipping Point
    2.Country of Destination & receiving Zone from Ship to party
    3.Shipping condition from CMR
    4.Transportation Group from MMR
    5.Weight Group which is optional.
    Check the above.
    Route is determined in delivery.
    ASHA

  • 051 routine between sales order and delivery copy control

    Hi,
    The copy control routine 051 in copy control from sales order to delivery defines four combination criteria.
    1) delivery types same in config of sales doc type
    2) sales org same of the sales orders
    3) delivery indicator same
    4) billing type same as defined in sales doc type.
    my question is if i have the follwoing copy control defined between sales order and delivery :-
    sales       del           sales       deliv         bill      routine
    order        type         org        agreement       type     in copy ctrl
    type
    ZOR          ZLF          1000         SAME          ZF2         051
    ZTSD          ZLF          1000         SAME          ZF2         051
    my question is how will the routine combine  all the sales doc type into a single delivery.  my confusion is since the rotuine is attached to every combination of sales doc type and delivery type in copy control, how will the routine identify that it has to combine the sales doc type ZOR and ZSTD into a single delivery.
    one of the statements wriiten in routine 051 is that " check sales org is same for all document ". does this mean that the routine will identify sales orders with doc type ZOR only  if the routine is attached in config for copy contol between zor and zlf and  i remove the routine for copy control belwteen zstd and zlf.
    regards
    sachin

    Sales order is the order from your customer and delivery is when you are delivering the item.
    Shipping: In general  when the item is dispached from the warehouse, we can say the item is shipped,where as delivery is item/product reaching to the end customer.
    Hope it helps,
    Kiran

  • Sales order and delivery requirement

    Hi,
    I have never worked real time on TOR and availibility check. I need help on clarification on the concept.
    1) The sales order transfers the requirement to MRP. So in the sap system there is a standard  requirement type/class 41 for the same. I need to know why there is a requirement type/class for sales order related delivery (011- delivery req type/class) ?
    In sales order related delivery, only availibility check is controlled(thru delivery item category) since the requirements are already transferred from sales order. so why the 011 delivery requirement ?
    2)The requirement type is determined through sales order item categoryMRP type.for the same combination of item categorymrp type, do one has to assign both the sales order and delivery requirment. I.e. suppose sales item category is ZTOR and mrp type is PD. so do one has to necessarity configure the follwoing
    ZTOR+PD=041(SALES ORDER REQ TYP) and 041 assigned to 041 req class
    ZTOR+PD=011 (DELIVERY REQ TYPE) and 011 assigned to 011 req class
    regds

    hi,
    please go in to class details you will find various indicators, related to costing, accounting etc.
    kapil

  • Sales order and Delivery difference

    I Am trying to write a query to produce totals of items ordered by customers compared to deliveries made. However there may be 3 deliveries made to one sales order and so my sales order total for an item is getting multiplied by 3 and showing a difference compared to the amount delivered where in fact the whole order has been delivered. How do I hold the sales order total per item once but then compare with the total delivery per item over multiple deliveries?

    Hi,
    Try this query for cost difference
    SELECT T0.ItemCode, T0.Dscription, Sum(T0.LineTotal) AS 'Order Value', ISNULL(Sum(T1.LineTotal),0) AS 'Delivered Value', Sum(T0.LineTotal) - ISNULL(Sum(T1.LineTotal),0) AS 'Lost Sales'
    FROM RDR1 T0 LEFT OUTER JOIN DLN1 t1 ON  T0.DocEntry = T1.BaseEntry AND T0.LineNum = T1.BaseLine and T1. BaseType = 17
    GROUP BY T0.ItemCode, T0.Dscription
    ORDER BY T0.ItemCode
    Replace my query with below query
    SELECT T1.[CardName]'CustName',T1.DocNum 'SOOrder',T1.[DocStatus]'SOStatus',T0.[Project]'JobNo', T0.ItemCode,T0.Quantity 'SOQty',T2.Quantity 'Delivered QTY',T0.OpenQty 'BalQty', T3.DocNum 'Delivery#',T3.[DocDueDate]'DelDate'
    From RDR1 T0 inner join ORDR T1 on T0.DocEntry=T1.DocEntry
       left join DLN1 T2 on T2.Basetype=17 and T2.BaseEntry=T0.DocEntry and T2.BaseLine=T0.LineNum
       left join ODLN T3 on T2.DocEntry=T3.DocEntry
    Thanks & Regards,
    Nagarajan

  • Link from sales order to delivery not complete

    2007A
    We have a few cases where the link from a sales order to delivery is not complete. For example, we have a sales order with 2 lines on it. We copy to delivery and add. Remarks field has the comment "based on sales order ...." However if you try to get to base document the icon is not available. In looking at the base document, base reference, base line fields on the items they are blank.
    We also have instances of this where there were 20 lines on a sales order, we copy to delivery and 19 lines are linked but one is not.
    Any ideas as to why this might be happening?

    Hi Keith ,
    It looks like an application error to me if the action is straight forward - copy from SO to Delivery .
    If you can replicate the issue , it is definitely a bug and you probably need to test with upgrade if it is happening or not .
    So far , I would look for a higher version of patch and see if that issue is particularly addressed and resolved .
    Also use this query for more help
    SELECT DISTINCT T0.DocNum FROM ODLN T0, DLN1 T1 WHERE (T0.DocEntry = T1.DocEntry) AND (T1.BaseEntry = [%0] OR T1.BaseRef = [%1])
    Hope this helps
    Bishal
    Edited by: BIshal Adhikari on Dec 11, 2009 9:47 AM

Maybe you are looking for