Sales Order Query for  in SAP B1

Hi,
I Need  to generate a report to Calculate the net sales orders for a particular customer in a given period. i can able to calculate the total sales order details itemwise but my query not works when the customer returns the particular products.( ie) I need to subtract the credit memo value from the order value of the particular product when the customer returns the product.
Here is my Query Please any one Help me... what mistake in this query
SELECT     A.CardName AS 'Customer Name', A.Address, A.DocNum AS 'Ord.No', CONVERT(varchar, A.DocDate, 3) AS 'Date', B.Dscription AS 'Item Name',
                      CASE WHEN B.itemcode = F .itemcode and A.CardCode = G.CardCode and A.Slpcode = F.Slpcode THEN B.quantity - F .quantity ELSE B.quantity END AS Quantity,
                      CASE WHEN B.itemcode = F .itemcode and  A.CardCode = G.CardCode and A.slpcode = F.slpcode THEN B.price - F .price ELSE B.price END AS Price, B.DiscPrcnt,
                      CASE WHEN B.itemcode = F .itemcode and A.CardCode = G.CardCode THEN B.linetotal - F .linetotal ELSE B.linetotal END AS Amount, B.VatPrcnt,F.ItemCode,E.Itemcode,D.Itemcode,C.Itemcode
FROM
ORDR A INNER JOIN
RDR1 B ON A.Docentry = B.Docentry LEFT JOIN
INV1 C ON A.Docentry = C.Baseref and C.Basetype=17 LEFT JOIN
DLN1 D ON A.Docentry = D.BaseRef and D.Basetype=17 or C.Docentry=D.BaseRef and D.Basetype =13 LEFT JOIN
RDN1 E ON D.Docentry = E.BaseRef and E.Basetype =15 LEFT JOIN
RIN1 F ON C.Docentry =F.BaseEntry and F.Basetype = 13 or E.Docentry = F.BaseRef and F.BaseType = 16 or E.TrgetEntry = F.Docentry and F.Targettype= 14 LEFT JOIN
ORIN G ON G.Docentry =F.Docentry Left join
OSLP H ON A.Slpcode = H.Slpcode
WHERE     (A.CardName = 'SHASUN CHEMICAL AND DRUGS') AND (A.DocDate >= '2000/9/30') AND (A.DocDate <= '2009/10/10')
group by A.CardName , A.Address, A.DocNum , A.DocDate, B.Dscription,B.Itemcode,
F.Itemcode,A.cardcode,G.cardcode,A.slpcode,
F.Slpcode,B.quantity,F.quantity,B.Price,F.price,B.vatprcnt,B.discprcnt,B.Linetotal,F.linetotal,F.ItemCode,E.Itemcode,D.Itemcode,C.Itemcode
ORDER BY 'Date'
Thanks,
vasanthapraba.

Maybe this will help you further?
SELECT A.CardCode, DocNum AS 'Ord.No', CONVERT(varchar, A.DocDate, 3) AS 'Date', B.Dscription AS 'Item Name', B.ItemCode AS 'Item Code'
, SUM(B.quantity - D.quantity) AS 'Quantity'
, SUM(B.price - D.price) AS 'Price'
, SUM(B.LineTotal - D.LineTotal) AS 'Amount'
      FROM ORDR A
INNER JOIN RDR1 B ON (A.DocEntry = B.DocEntry)
LEFT JOIN DLN1 C ON (B.DocEntry = C.BaseEntry AND B.LineNum = C.BaseLine)
LEFT JOIN RDN1 D ON (C.DocEntry = D.BaseEntry AND C.LineNum = D.BaseLine)
WHERE (A.DocDate >= '20090925') AND (A.DocDate <= '20090925') AND (A.CardName = 'SHASUN CHEMICAL AND DRUGS')
GROUP BY A.CardCode, A.DocNum, A.DocDate, B.Itemcode, B.Dscription
ORDER BY 'Date'

Similar Messages

  • Migrate all Open Sales Orders From Legacy System (SAP) To SAP System using

    Hi Experts,
                 I've to Migrate all Open Sales Orders From Legacy System (SAP) To SAP System using Business Objects with a new SALES ORDER DOCUMENT NUMBER referencing the older one.
               I'll get all the required data with field in an excel file.
                 Does any standard transaction exist for it ? Or how to go ahead with it ?
    Thanks and regards,
    Jyoti Shankar

    Hi
    If you are checking for CREATE option then Sales Doc Type
    For more Info goto SWO1 transaction -> BUS2032 --> DIsplay --> Execute --> There SELECT the method which you want to perform... There you can fine the MANDATORY parameters also....
    Or in DISPLAY mode PLACE Cursor on the Required Method and CLick the PARAMETERS button on toolbar...
    That will show the MANDATORY parameters...
    Reward if helpful....
    Message was edited by:
            Enter the Dragon

  • Migrating Open Sales Order From Legacy System (SAP) To SAP System

    Hi Experts,
                 I've to Migrate all Open Sales Orders From Legacy System (SAP) To SAP System using Business Objects with a new SALES ORDER DOCUMENT NUMBER referencing the older one.
               I'll get all the required data with field in an excel file.
                 Does any standard transaction exist for it ? Or how to go ahead with it ?
    Thanks and regards,
    Jyoti Shankar

    hi jyothi ,
       there are lot of ways of doing it depending on data upload volume it will be decided .
    1) thru abap bdc program which directly uses XL sheet data and creates SO using bapi/FMs.
    2) using scat.functional consultant should be good enough to use this.
    3)lsmw-laborious procedure but achievable.
      reward if helps !!!!!

  • Sales Order Conversion for Go-Live

    Folks,
    I would like to get your expert thoughts on sales order conversion for go-live. I will give my thoughts below and would like to see if you can extend them and make this better.
    1. The environment is this: the order entry systems are several external systems interfacing  with SAP CRM. Therefore, there are two options to bring the sales orders to SCM: i) Use the same interface (BAPI_APO_AVAILABILITY_CHECK that is called from CRM) and create the orders, or, ii) Create the sales orders in ECC and then use the sales order integration model. Note that this is the only time sales orders will come from the ECC system. In steady state, they will come from CRM and based on the SPM scenario that SAP has enabled, they WILL NOT be replicated in ECC
    2. Ensure that all deliveries in the system have been executed. That is, there is no stock that has been assigned to a delivery and the delivery has not been shipped. If this is not the case, you have to bring the deliveries into the system also. So, to clarify, no outstanding deliveries will be brought into the system as part of the conversion.
    3. Sales order fields related to BOP will be populated through program or by other means. This is implementation specific. Some example fields are: i) Sales Org, ii) Delivery Priority, iii) Shipping Conditions on the header, iv) Transportation Zone of customer, v) Ship-to Party number, etc.
    4. Run BOP for all the sales orders based on the criteria that has been defined for this conversion. Note that the criteria for the conversion could be different from the criteria that we will use for steady state.
    Could you add any missing steps?
    Thanks,
    Satish

    thanks nitin
    i would like to use it as prepayemnt itself
    but when i am trying to load using oe_payments base table it loads
    but when i use data and use in oe_payments_iface all it doesnot load after i run the order import program
    can u plz suggest me where i am going wrong
    thnaks

  • Combined Purchase Order and Sales Order Query. (Including Stand Alone Docs)

    Hi,
    I need some help please!
    I am looking for a query that will show all the Purchase Orders with all their base document Sales Orders. However I also need to show those stand alone Purchase orders and Sales Orders.
    What I have is two queries, one for the PO fields en one for The SO fields. I would like a way to combine these two so I have one query with the relevant PO and SO info next to each other.
    The final query will have a top heading structure like this:
    Status,Purchase No.,Supplier No.,Supplier Name,Week,Month,Del Method,Country,Method,Rep.|Status,Rep.,Sales No.,Customer No.,Customer Name,Customer Order no.,Cust. Del date,Doc total,Del Method
    +(The first part is for the purchase order section, the second part starting at the second 'Status' is the sales order section)
    +Purchase Order Query:
    SELECT
      T0.DocStatus 'Status',
      T0.DocNum'Purchase Order No.',
      T0.CardCode 'Supplier No.',
      T0.CardName'Supplier Name',
      DATEPART(ww,T0.DocDuedate)'Week',
      DATEPART(mm,T0.DocDuedate) 'Month',
      T1.TrnspName 'Delivery Method',
      T2.Country 'Country',
      T0.JrnlMemo 'Method',
      T3.SlpName 'Rep.'
    FROM OPOR T0 
    INNER JOIN OSHP T1 ON T0.TrnspCode = T1.TrnspCode
    INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode
    INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode
    Sales Order Query:
    SELECT
      T0.DocStatus 'Status',
      T2.SlpName 'Rep.',
      T0.DocNum 'Sales Order No.',
      T0.CardCode 'Customer No.',
      T0.CardName 'Customer Name',
      T0.NumAtCard 'Customer Order no.',
      T0.DocDueDate 'Cust. Delivery date',
      T0.DocTotal ' Doc total',
      T1.TrnspName ' Delivery Method'
    FROM ORDR T0 
    INNER JOIN OSHP T1 ON T0.TrnspCode = T1.TrnspCode
    INNER JOIN OSLP T2 ON T0.SlpCode = T2.SlpCode
    The problem I am having is that if I combine these queries it excludes all those records with blank/empty data fields.
    I do not mind having to go to crystal reports to get what I want.
    Any suggestions?
    Thanks!

    Hi thanks GordonDu,
    I have tried a union before, and yours works great. However my problem is to display the  PO en SO columns next to each other and not underneath each other.
    Something like this:
    Po No          Supplier          SO No           Customer
    1234           Sup 1             9876              Cust 1
    1235           Sup 2             no SO             Cust 2
    1236           Sup 3             9877              Cust 3
    1237           Sup 4             9878              Cust 4
    1238           Sup 5             no SO             Cust 4
    I have this query, but with this it drops all those Purchase Orders made Stand Alone and without a SO number.
    SELECT
      T2.DocNum AS 'Purchase Order No.',
      T0.DocNum AS 'Sales Order No.',
      T2.CardCode AS 'Supplier No.',
      T2.CardName AS 'Supplier Name'
    FROM ORDR T0 
       INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
       INNER JOIN OPOR T2 ON T2.DocEntry = T1.PoTrgEntry
    Though using your Union gives me all the information I want and the ability to expand on that, my problem is the "Display" part. I am sure I am doing something stupid somwhere 
    Edited by: Desmond Moll on Mar 7, 2012 8:03 AM

  • Monthly Sales Order query Doc Status problem

    Hi Experts,
    I am having an problem while making a total monthly sales order query in which I am not getting the document status which are Open - Printed. Also note that these document which are open printed are not having any target document.
    SELECT T0.[DocStatus],T1.[TargetType],T0.[CANCELED],T0.[CardCode], T0.[CardName], T0.[NumAtCard], T5.[SeriesName], T0.[DocNum], T0.[DocDate], T0.[DocDueDate], T0.[DocTotal],T0.[Max1099]'Total Before Discount',T0.[TotalExpns],T4.[descript]'Territory',T2.[SlpName]'Employee Name'
    ,T0.[discsum]  FROM ORDR T0  ,RDR1 T1,OSLP T2,OCRD T3,OTER T4,NNM1 T5  where  T0.DocEntry = T1.DocEntry AND T0.SlpCode = T2.SlpCode AND T0.CardCode = T3.CardCode
    AND T3.Territory = T4.territryID AND T0.Series = T5.Series and T0.[CANCELED]='N' and T1.[TargetType] is not null
    My mission for the above query is to have Total Monthly Sales Orders with value exluding the cancelled and closed sales sales ( close here means - which are manually done by right click on sales order screen and selecting Close )
    Please guied how to solve this issue because in the back end for Sales Order which have turned to deleivery are showing doc status as closed and the sales order which are manually closed are also showing doc status as closed. How to diffrentiate between them.
    Waiting for a positve feedback.
    Regards,
    Rahul

    Try this one:
    SELECT DISTINCT T0.[DocStatus],T0.[CardCode], T0.[CardName], T0.[NumAtCard], T5.[SeriesName],
    T0.[DocNum], T0.[DocDate], T0.[DocDueDate], T0.[DocTotal],T0.[Max1099]'Total Before Discount',
    T0.[TotalExpns],T4.[descript]'Territory',T2.[SlpName]'Employee Name',T0.[discsum]
    FROM DBO.ORDR T0
    INNER JOIN DBO.RDR1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN DBO.OSLP T2 ON T0.SlpCode = T2.SlpCode
    INNER JOIN DBO.OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN DBO.OTER T4 ON T3.Territory = T4.territryID
    INNER JOIN DBO.NNM1 T5 ON T0.Series = T5.Series
    where  T0.[CANCELED]='N' and T1.[TargetType] != -1
    Thanks,
    Gordon

  • Sale order costing for Trading goods

    Dear Experts,
    My client having retail industry.Client used to sold customers also like outwright customers direct sales not through retail stores. Now business would like to check margin agasinst one sale order through costing. My SAP working enviornment is IS Retail ECC6.0.
    1. Is it possible to do sale order costing for trading goods.(Goods p[urchased for all stores not particular customer)
    2.Wihtour BOM is it possible?
    3.Please forward any user docs ,if possible that costing
    Costing sheet like this
    1.Trading goods
    2.Packaging materila
    3.Overheads.Planned
    Beat Rgds
    Suma

    Answerd with Condition type

  • Sales Orders Blocked For Delivery

    Hi,
    Do we have T-Code for Sales Orders Blocked For Delivery other than VA14L,Because Customer name is not there in VA14L list.
    Thanks,
    NAG

    Hi naga sudhir
    Go to T-code--VA14L
    In that  go to menu-SettingsLayout--Current/Choose
    In this layout u can choose fields what u want to appear in that row.
    Any quries revert back to me
    Regards
    Srinivas.

  • Sales Order Confirmation when sales order goes for Credit Block

    want Sales Order to be Confirmed , i e Schedule line Confirmation , when sales order goes for Credit Block
    How i can Achieve this?
    Even when set for Sales Document typpe credit check as 'D' and credit group as ;03; ie at Goods Issue still order is not getting confirmed.

    I am not sure, why you want schedule line to be confirmed for credit blocked sales orders. Re-confirm with the client.
    There are controls when defining delivery blocks.
    Goto IMG - Log.Execution-Shipping - Deliveries- Define delivery blocks( check menu path in system, may not be same as shown here).
    Select 01- credit block " untick" from "Confirmation" Column.
    Now test with & see how ti works.
    Regards,
    Reazuddin MD

  • Route not determing automatically at sales order level for some sales order

    Dear All ,
    Route not determing automatically at sales order level  for some sales orders.We are using automatic route determination without wt group,eventhough we have configured the required settings
    I have checked all the forums but didn't find any solution for the same.
    Looking for your inputs .
    Thanks inadvance
    Regards
    Venkat

    Hi
    1. Copare the Routes which are Automatically determined and which are not automatically determined
    2. Have you mainted this route to be RELEVANT FOR TRANSPORTATION without this check route will not get picked up.
    SPRO > Logistic General > Shipping > Basic Shipping Function > Routes > Define Routes > Define Routes and stages > Select the Route and check for it's settings > CHECK MARK Relevant for Transport. Without this check the route will not get picked up as of my understanding.
    Thanks
    RB

  • Block the Material at Item level in Sales Order automatically for delivery

    Hi!
    My business scenario needs a material to be Ckecked for Inspection after raising the Sales Order by thirdparty person. So, I need to block that particular material at Item level automatically for delivery and rest of the line items can get delivered. I can do this by selecting the reason for Block at Item level manually, but I want the system to get detemine this block. And one more thing is that there is NO Quality Management module for this. So, let me know what I need to configure for this effect.   Thank you.....

    hi,
    pl check the user exit " userexit_save_document_prepare" or "userexit_save_document".
    Take the help of your abaper to see if the logic written here can affect the item level block in the sales order for inspection. Create new reason for the item level block and have it triggered with this exit. Instead of hard coding which might require regular intervention of abaper for code changes for the business to be able to manage it, maintain a master data in the material master against some field with a key.
    now use that key to identify if these materials require to be blocked at the sales order level for inspection. To release this item again the user has to go in VA02 mode to release the block. Let this be done after the inspection of that material.
    regards
    sadhu kishore

  • Goods receipt for sales order (sample for inspection)

    Hi Experts
    Is it possible to enter goods receipt for a sales order?
    This process is required for collecting sample from customer for carryingout testing of the sample.
    Please suggest the doc types and process steps.
    warm regards
    ram

    Hi Lakshmipathi
    Thanks for your reply.
    This is a sample received from a client for carrying out analysis and furnishing the laboratory test results as a Quality certificate
    So, the sales order is for execution of service (Testing service).
    The sample to be received in ref with the sales order and test result to be delivered to customer.
    Please suggest the best possible process
    warm regards
    ram

  • Valuated sales order stock for configured material

    Hi All!
    I have a small problem   : I created a new type of material (OMS2) - a configurable one, managed on quantity and value basis. I work with valuated sales order stock for configurable materials but the account in the purchase requisition is determined by means of event key GBB insted of event key BSX.
    Where is my error?
    Any idea would be appreciated.
    Florina C

    Hi
    I think you are talking about Special Stock "E"...ie) Sale Order Stock...
    If my understanding is correct then,
    If you go and see the Table T156....For the
    Movement Type: 101,
    Special stock Indicator : E,
    Qty. Updation Checked,
    Val. Updation Checked,
    Movement Indicator : Against PO,
    Consumption Indicator: Sales Order Stock.....combination....the transaction Event Key....GBB only has been Assigned....these  settings you cannot change...
    This linkage you can view in OLMW-----> Account Determination -
    > Acc. Determination W/O Wizard -
    >Account Grouping....also
    Reward if useful
    Regards
    S.Baskaran
    Edited by: baskaran srinivasan on Dec 20, 2007 12:18 PM

  • Plant Info is blank in Sales Order Due for Delivery (VL10A)

    Hi experts,
      In VL10A sales Order Due for Delivery, i have fields like Name, GI date, plant and shipping point. 
    There is data on shipping point.  However, the plant field is blank.  I like to get data for the plant.
    Can you pls point me to what user-exit or how  I can modify the program to bring data for plant ?
    I am aware that VL10A list orders at the header level.
    Thank you.
    Joyce

    closed.

  • Userexit to update sales order no for packaging material during PGI

    Hi,
    Scenario is like this:-
    1.Sales order will be created for material X
    2.Delivery will take place and packaging of material X will take place.
    3.The packaging material will come as a line item and we do PGI by picking the quantity.
    4.Now when we see the accounting document for PGI,we get the sales order reference for X.
    5.We are not getting the reference of Sales order no for packing material while seeing the accounting document in  PGI.
    6.Since the packing material is not maintained in Sales order thats why the sales order no is not getting updated in the accounting document.
    7.NOW I WANT TO UPDATE THE SALES ORDER FIELD FOR PACKING MATERIAL ALSO ONCE THE PGI IS TAKING PLACE.
    Can any one suggest me if there is any userexit to update the sales order field for accounting document of packing material once PGI happens.
    regards
    Somnath

    Hi,
    Since packging material is not sales order item so it can't be accounted in PGI packging material is aour internal stock and not sellable stock.
    Reward points if helps.
    Thanks & Regards
    Sasikanth.Ch

Maybe you are looking for

  • How can I tell if an Object Input Stream has more objects to read?

    I have a utility that I'm working on where objects are sent via the network as a complete file. I read the objects, update some, and send them back. I never know how many objects are in the file. I cache the file locally prior to performing this oper

  • External connectivity best practice

    Hi, I would like to know what are the best practices to have external users using Excel to connect to SSAS cube. I understand the general concept that a cube user must be in a domain AD andthat same user is a member of a SSAS cube. How can I ensure t

  • Why can't I access my att toolbar w/version 4.0?

    I made the mistake of downloading version 4.0, and, first, I don't like it, and my att toolbar has disappeared. Is this version made to be incompatible with add ons or what? It is most inconvenient as that toolbar has the ability to take me to my e-m

  • Basic questions about programing for J9 VM

    I need to create a java application to run on a Pocket PC 2003 OS and I'm limited to using IBM's Websphere J9 Virtual Machine. I'm new to using java in this capacity and therefore have lots of questions which I'm guessing are pretty basic. Despite my

  • Firefox 4 sucks big time. I uninstalled and downloaded 3.6.17.

    Sorry Mozilla, but Firefox 4 sucks big time. I uninstalled and downloaded 3.6.17. I've turned off automatic updates. V4 breaks JQuery and who knows what else, so I'll be a lifelong customer of my v3.6.17 version, coz I'm just not going to have establ