Query with Item info sales and purchase quantity

Hello,
I have an query were i want to report an total quantity of sales and purchase. But it is not working.
SELECT T2.CardName, T0.ItemCode, T0.ItemName, T0.OnHand, T0.IsCommited AS 'Bevestigd', T0.OnOrder AS 'In Bestelling', T0.SuppCatNum AS 'Leveranciersnummer',
SUM(T3.Quantity) 'Total Sales', SUM(T5.Quantity) 'Total Purchase'
FROM dbo.OITM T0
INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode
LEFT JOIN INV1 T3 ON T3.ItemCode = T0.ItemCode
LEFT JOIN OINV T4 ON T4.DocEntry = T3.DocEntry AND T4.CardCode = T0.CardCode
LEFT JOIN PCH1 T5 ON T3.ItemCode = T0.ItemCode
LEFT JOIN OPCH T6 ON T6.DocEntry = T5.DocEntry AND T6.CardCode = T0.CardCode
WHERE T2.CardCode =[%0]
GROUP BY T2.CardName, T0.ItemCode, T0.ItemName, T0.OnHand, T0.IsCommited, T0.OnOrder, T0.SuppCatNum
Can somebody help me??
Mark

Hello Gordon,
Changed the query like beneath.
SELECT T2.CardName, T0.ItemCode, T0.ItemName, T0.OnHand, T0.IsCommited AS 'Bevestigd', T0.OnOrder AS 'In Bestelling', T0.SuppCatNum AS 'Leveranciersnummer', SUM(T3.Quantity) 'Total Sales', SUM(T5.Quantity) 'Total Purchase'
FROM dbo.OITM T0
INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode
INNER JOIN INV1 T3 ON T3.ItemCode = T0.ItemCode
INNER JOIN OINV T4 ON T4.DocEntry = T3.DocEntry
INNER JOIN PCH1 T5 ON T3.ItemCode = T0.ItemCode
INNER JOIN OPCH T6 ON T6.DocEntry = T5.DocEntry AND T6.CardCode = T0.CardCode
WHERE T0.CardCode = '[%0]'
GROUP BY T2.CardName, T0.ItemCode, T0.ItemName, T0.OnHand, T0.IsCommited, T0.OnOrder, T0.SuppCatNum
Still get strange numbers in the last 2 total sales and total purchase
kind regards
mark

Similar Messages

  • Edit back to back sales and purchase order with dropped ship warehouse

    Hi
    Our Client request to be able to edit back to back sales and purchase order with Drop Shipped WH which is frequently required according to their business nature in overseas trading.
    Kedalene Chong

    Hi Daniel,
    In the PO Ship To address field, the database/company address will appear until a warehouse is selected. Once a WH is selected, that is the address that will appear. If there is no WH address, the company address is indicated in the field (note: no company name just the address).
    If you want a different address/name, you can type it into the ShipTo address field and the PLD template will use whatever is in the field.
    If it is because there is no company name on the PO - does this mean you want a different company name than the one in the PO header. If this is the case and the ShipTo address & company name is always the same, you can update the PLD template by changing the ST address field to Text and enter the company name & address you want on the PO. This will appear on every PO regardless of what is in SAP. If you want the company name to always be the same, add a text field above the ST address field and fill in the company name; the address will be pulled from the PO Logistics ST field (per the first paragraph above).
    If this is not what you want, please explain in more detail what you would like to do.
    Heather

  • Report for Sales and purchase tax (selection criteria-Tax code)

    Hi
    I have one query for sales tax details which gives me detail for all A/R invoices and taxes involved in it. But i want that while executing query system should ask tax code and gives detail of tax amount in front of item and invoice according to tax code selected.
    The query is:
    SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price, (Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)', (SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ', (SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ', (SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ', (SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ', (SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ', (SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ', (SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ', (SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ', (SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ', (SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ', (SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ', (SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ', (SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ', (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ', (SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ', (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ', (SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ', (SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ', L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total' FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14 GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal ORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
    I want 2 queries which asks tax code during selection criteria for both cases sales and purchase.

    Hi Malhotra,
    Try this,
    1st remove the FROM/TO Doc. Date where Condition in your Query report.
    AND add the below where condition in your Query report.
    WHERE statype = '[%0]'
    OR
    Try this Query Report.
    SELECT
    M.DocNum as 'A/R Invoice No.',
    M.DocDate as 'Inv. Date',
    M.CardCode as 'Customer Code',
    M.CardName as 'Customer Name',
    M.NumAtCard as 'Bill No. & Date',
    ISNULL(L.ItemCode,'Service Item') as 'Item Code',
    L.Dscription,
    L.Quantity,
    L.LineTotal,
    L.TaxCode,
    L.[VatSum],
    M.WTSum AS 'TDS (Rs.)',
    M.DocTotal as 'Total (Rs.)'
    FROM OINV M
    LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
    WHERE
    (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]')
    AND
    L.TaxCode='[%2]'
    GROUP BY
    M.DocNum,M.DocDate,M.CardCode,M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    L.LineTotal,M.DocEntry,M.[DiscSum],L.TaxCode,L.[VatSum],M.WTSum,M.DocTotal
    ORDER BY
    M.DocNum,M.DocDate,M.CardCode,M.CardName,M.NumAtCard,L.ItemCode,L.Dscription,L.Quantity,
    L.LineTotal,M.DocEntry,M.[DiscSum],L.TaxCode,L.[VatSum],M.WTSum,M.DocTotal
    Regards,
    Madhan.

  • Linking document info record and purchase order

    Hi all,
    I hope that someone can help me because I'm having a problem with creating links between document info records and purchase orders.
    By default in SAP I can create links between document info record and purchase order ITEMS! When I create that link, I can see it in document info record under Object links tab, but when I double click on the number of purchase order nothing happens (I expected that this purchase order will open).
    Why is that so?
    Why can't I access purchase order from document info record even though the link exists?
    The other question is about creating object links to purchase orders, not purchase order items! Is it possible to link document info record with purchase order?
    I would appreciate quick answer because we're in the middle of a project and we're stuck with that problem.
    Thanks!

    Hi Karlo,
             As you mentioned, object links could be linked to Purchase order items. In customisation you maintain these entries under the node SPRO > Cross Application Components> Document Management--> Control Data --> Define Document Types --> Define Object Links.
    There are many links in the standard system (possible entries).
    The system automatically determines the screen number (dialog box) where the key data for the object is maintained for document maintenance.
    You can check the screens when the screen entry is missing or contains errors by doing the following:
    Start the Object Navigator and display the objects for the development class  CV.
    Expand the function group 130. The structure nodescreens lista all screens that can be used for object links.
    You can make an object link to SAP objects that are not shown in the possible entries list. To do this, proceed as follows:
    In the standard system, there are already two special screens for the module pools SAPLCV130 and SAPLCV140 for the linked SAP object.
    You must create two new screens with the same number for the module pools SAPLCV130 and SAPLCV140 .
    The processing logic must follow that of screen 1204 in program SAPLVC130.
    Create function module OBJECT_CHECK_XXXX (XXXX = object name)
    If the object can be classified, this function module already exists .
    Otherwise copy the function module for linking equipment DOCUMENT_CHECK_EQUI and change it as required for the new object.
    Hope the above instruction helps in solving your problem,
    Sojan
    Note : Award points if you find the information useful

  • Intracompany sale and purchase of material

    Hi All
    I would like to know how can intracompany sale and purchase be carried out in SAP?
    Details of problem:
    There are 2 LOBs under one company code which are represented  by 2 diff plants, valaution area and profit centre.
    When 1 LOB requires component "A" (trading component), then LOB 2 sells this item to LOB1 with profit margin.
    How can this scenario be mapped in SAP so that my material inventory doesnt inflate and at the same time there is sale shown in LOB 2 and purchase in LOB1. Also corresponding entries of internal sale and internal purchase are shown in resp profit centre.
    Request you to please help me out.
    Regards
    Rakesh

    Hi gj,
    SAP's answer to the requirement was already mentined above. SAP foresees to use a parallel profit center valuation where the internal sales would be represented.
    from the help docu:
    Company A sells a product to Company B, thereby realizing a profit that must be shown in its balance sheet (corporate and tax balance sheets). Because Company A and Company B both belong to a group, this sale is merely as an internal stock transfer when looked at from the point of view of the group. Thus no group (internal) profits can be realized as a result of this transfer. Such internal profits can also arise when the exchange is between two profit centers instead of two independent companies of the group.
    [http://help.sap.com/saphelp_erp60_sp/helpdata/en/eb/13811243c411d1896f0000e8322d00/frameset.htm]
    best regards,
                      Udo

  • Intra-company sale and purchase between two plants

    Hi All
    I would like to know how can intra-company sale and purchase be carried out in SAP?
    Details of scenario:
    There are 2 plants under one company code which are represented by 2 diff profit centre.
    When plant u201CAu201D requires component, it raises Purchase Order and then plant u201CBu201D issues Sale Order and sells this item to plant Au201Du201D with profit margin.
    How can this scenario be mapped in SAP so that my material inventory does not inflate and at the same time there is sale shown in plant 2 and purchase in plant 1. Also corresponding entries of internal sale and internal purchase are shown in respective profit centre.
    Request you to please help me out.
    Regards
    Prashant

    Hi,
    Please ask your MM and SD consultant to configure Stock Transfer Order for such situation, the process flow will be as follows:
    1. Create PO with type Stock Transfer Order
    2. Create Delivery (VL10B)
    3. Do the Goods issue
    4. Then do the goods receipt
    There will be two plant that is shipping plant and receiving plant.
    Please refer below link:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c05e2251-91f0-2c10-4e91-e919468e4687?QuickLink=index&overridelayout=true
    Br,VIvek

  • S_ALR_87012357 report - Advance Return for Tax on sales and purchase

    Hi Friends,
    I would like to know few things in regards the VAT report S_ALR_87012357 report - Advance Return for Tax on sales and purchase:
    (1) What information brings the S_ALR_87012357 report?
    (2) As of now this report displays tax against vendor line item and not expense line item. Is there any other report that shows all the positions lines affected to tax?
    (3) Is it possible that the tax line stays only in the expense line account and not in the vendor line account or not any intercompany line account?
    (4) Is it possible S_ALR_87012357 report shows information about the tax allocanted in expense accounts and not in vendor accounts?
    Appreciate a faster response.
    Thanks in advance.

    Please try report S_ALR_87012359. This report gives you opportunity to choose account selection.
    I am unsure how the SAP is setup in your organisation. S_ALR_87012357 should pick up expenses selection as well.
    This report entirely depends on tax code selection.

  • FM or BAPI for creating purchase info records and purchase conditions

    Hi all,
    i need create purchase info records and purchase conditions from txt-file,
    What FM or BAPI i can used for this?
    Thanks and Regards,
    Andrei

    You can use trasaction SXDA_TOOLS.....
    object type BUS3003
    program type BINP
    program/method RM06IBI0
    but the fields must be sequentially written in the txt, with every space inclusive....

  • Sales and purchase journal - balance carry forward to next page

    Hi all,
    When we run sales and purchase journals in transaction S_ALR_87012357 (Belgium) and print it we want a summary per page and balance carry forward to next page.
    The paging is correct by selecting "statistical info not printed" in output control but we don´t want only summary on last page, instead on every page and a total summary on last page.
    Does anyone knows how to mangage this?
    Best regards Lisa

    With a developer implement a the BADI  FI_TAX_BADI_010

  • Sales and Purchase analysis, sort by date default

    Hello,
    Is there a way to default the sales and purchase analysis reports to show the most recent orders first vs. the oldest orders first in the list?  I am refering to the reports that appear when you are in Item Master Data, and then click on the graphs in the Sales Data and Purchasing data tabs.
    Thank you

    Hi,
    You may double click the column header to change the sort.
    Thanks,
    Gordon

  • How to extract User status for Sales and purchase contracts

    Hello,
    We need to load the User status linked to sales and purchase contract.
    I think that there is no datasource in BI content.
    What is the better solution ?
    - Enhance a standard datasource like 2LIS_11_VASTH with a status field (This solution is not ok for Purchase contract)
    - Create a spécific datasource to extract this status
    - Others
    Thanks for your help
    Best regards
    Christophe

    Hi,
    In your scenario its better to use generic extractor to get the reqd data. This data can than be stored in a DSO on the BI side.
    And you can look up for the user status using a routine .
    Regards,
    Rahul

  • How can you expect the customer to have a LOCAL/COUNTRY Based Credit Card every where we go??? Last week I was on holiday in HK,  and  from my Hotel I was able to use m VN Credit Card with my Apple ID and purchase online!  Why THIS WEEK, can't I use my HS

    Apple_ID_card_declined_for_this_country
    How can you expect the customer to have a LOCAL/COUNTRY Based Credit Card every where we go???
    Last week I was on holiday in HK,
    and
    from my Hotel I was able to use m VN Credit Card with my Apple ID and purchase online!
    Why THIS WEEK, can't I use my HSBC Platinum Credit Card from Vietnam,
    for my Singapore Apple ID account ,
    while working here in Vietnam???

    Unfortunately, this is a problem that is driven by the DRM Dictatorship.  Despite the proliferation of mobile devices and the fact that there are many of us who do a lot of international travel, content providers don't want you to have access to their products outside of your homeland.  The Balkanized mentality of the DRM Dictatorship is way out of touch with the modern world.
    At least Apple, to its credit, allows you to use your accounts outside of your homeland as long as you have the proper credentials for them.  Most other services use the more Draconian geolocation filtering which does require you to be physically present in your homeland.  For the most part, you are not allowed to leave home if you want access to your favorite entertainment!

  • Getting the default zero-rated sales and purchase tax codes

    Hi,
    Does anyone know how to obtain the default zero-rated sales and purchase tax codes? ie the tax exempt sale and purchase tax codes.  The OADM holds the default sales and purchase tax codes but not the default zero-rated sales and purchase tax codes. Is this set by region?
    Lita

    Hi Lita,
    I don't know much about the zero rated tax codes or where it is set up, but what I can suggest is if you know where the system retrieves it (say on an Invoice) that you use SQL Profiler to possibly investigate where the queries are pulled from.
    Where in SBO is the zero-rated tax codes used?
    Hope it helps,
    Adele

  • Tax on sales and purchase

    could anybody plz forward me the step-by-step config for "TAX ON SALES AND PURCHASE"- i am facing problem as my config could not calculate taxes
    thanq

    hi
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/cf/540ef7d61a11d2955500a0c929f4c9/frameset.htm
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/76/f3043b39eec71fe10000000a114084/frameset.htm
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/01/a9ca79455711d182b40000e829fbfe/frameset.htm
    for furthur notes
    http://help.sap.com/search/search_overview.jsp
    nagesh

  • Linking Access tables, creating a query with using both Access and Oracle

    Hello,
    I am using 3.0.04.34 version Oracle Developer. I am supposed to create a script/procedure to use both Access tables and oracle tables together. There is an option in developer to copy the access tables into oracle. But it doesn't help me. Because when we updated the access tables
    the copied ones are not be updated. How can I created a linked access tables to oracle and create a query with using both access and oracle table together.
    I will appreciate if you guys help me. I look forward to hearing from you guys.
    Thanks,
    Pinar

    Pinar,
    to be able to query MS Access tables in Oracle you need an additional product, the Oracle Database Gateway for ODBC. It allows you to link any foreign database into an Oracle database using a suitable ODBC driver. You can then access the MS Access tables through a database link based on the Database Gateway for ODBC. This will also allow you to join local Oracle and remote MS Access tables from your Oracle database.
    There's a note on My Oracle Support which gives you more details:Document 233876.1 Options for Connecting to Foreign Data Stores and Non-Oracle Databases - For example - DB2, SQL*Server, Sybase, Informix, Teradata, MySQL
    And there's also a dedicated Forum: Heterogeneous Connectivity

Maybe you are looking for