Query for Turnover per Customer / article and from wich agent in one file.

Hello Experts -  basicly the subject tells it all, what I whant to see in the query is:
Turnover Per Customer wich articles and wich agent is responsible for the customer.
Many thanks in advance.

Hi,
Actually there are two field in the INV1 table
1) Price = Net Price (after the adjustment of the Discount at row level)
2) pricebefdi = Gross Price ( which does not include the discount at the row level)
I have amended the query again based on the above fields :
select distinct t0.CardName as 'Business Partner Name',
CASE WHEN t1.discprcnt != 0 then ROUND(SUM((t1.Quantity*t1.PriceBefDi)*((100-t1.DiscPrcnt)/100)),2)
WHEN t1.DiscPrcnt = 0 then ROUND(SUM((t1.Quantity*t1.PriceBefDi)*((100-t0.DiscPrcnt)/100)),2)
WHEN t1.DiscPrcnt !=0 and t0.DiscPrcnt != 0 THEN
ROUND(SUM((t1.Quantity*t1.price)*((100-t0.DiscPrcnt)/100)),2)
END as [Total Turnover after Discount],
t1.DiscPrcnt as 'Discount Percentage Rows',
T0.Discprcnt as 'Header Discount',
t1.VatSum as 'Vat Amount', t1.Dscription as 'Item Name',
sum(t1.Quantity) as 'Qty Sold', t3.SlpName as 'Sales Employee Name'
from OINV t0 inner join INV1 t1 on t0.DocEntry = t1.DocEntry
inner join OSLP t3 on t3.SlpCode = t0.slpcode
where t0.DocDate >= '2011.01.01' and t0.DocDate <= '2011.12.31'
Group BY t3.SlpName, t0.Cardname,t0.slpcode, t1.Dscription,t1.DiscPrcnt,t1.vatsum,
t1.DiscPrcnt,t0.discsum,t0.discprcnt
order by t1.Dscription
I have incorporated the one where discount is there both on header and rows.
Kind Regards,
Jitin
SAP Business One Forum Team
Edited by: Jitin Chawla on Oct 12, 2011 11:17 AM
Edited by: Jitin Chawla on Oct 12, 2011 11:18 AM

Similar Messages

  • Query for non turn customer report in service module(Add-on)

    Hi,
    I want create  query for non turn customer report, that mean the customer who are not come for  last 6 months to our service workshop in service module(Add-on). this is a scenario. 
      SELECT T1.U_CardDate, T1.U_JCardNo,T1.U_TypeSrv,T2.U_VehReg,T2.U_PurchDt, T2.U_VehDesc, T2.U_VehModel, T1.U_KmsRead,   T1.U_BPCode, T0.CardName, T0.AddrType , T0.Building,T0.Block, T0.Address,T0.City,T0.ZipCode, T0.State1,T0.MailBuildi,T0.MailBlock, T0.MailAddres, T0.MailZipCod, T0.MailCity, T0.State2 ,T0.MailAddrTy,  T0.Phone1, T0.Phone2, T0.Cellular FROM [dbo].[OCRD]  T0 INNER JOIN [dbo].[@ALD_JOBCARD]  T1 ON T0.CardCode = T1.U_BPCode INNER JOIN  [dbo].[@ALD_VEHMAST]  T2 ON T1.U_BPCode = T2.U_BPCode WHERE T1.U_CardDate BETWEEN [%0] AND [%1] ORDER BY T1.U_CardDate.
    this query is get all  customer data who are not come to service workshop for last 6 month. i want to filter data who are not come last 6 months this year. kindly assist me
    thank you.

    Check this:
    SELECT Max(T1.U_CardDate) 'Lase Serve Date', T1.U_JCardNo,T1.U_TypeSrv,T2.U_VehReg,Max(T2.U_PurchDt) 'Last Purchase', T2.U_VehDesc, T2.U_VehModel, T1.U_KmsRead, T1.U_BPCode, T0.CardName, T0.AddrType, T0.Building,T0.Block, T0.Address,T0.City,T0.ZipCode, T0.State1,T0.MailBuildi,T0.MailBlock, T0.MailAddres, T0.MailZipCod, T0.MailCity, T0.State2 ,T0.MailAddrTy, T0.Phone1, T0.Phone2, T0.Cellular
    FROM [dbo].[OCRD] T0
    INNER JOIN [dbo].[@ALD_JOBCARD] T1 ON T0.CardCode = T1.U_BPCode
    INNER JOIN [dbo].[@ALD_VEHMAST] T2 ON T1.U_BPCode = T2.U_BPCode
    WHERE T1.U_BPCode NOT IN
    (SELECT DISTINCT U_BPCode FROM dbo.[@ALD_JOBCARD] WHERE DateDiff(DD,U_CardDate,GetDate()) < 183)
    Group By T1.U_JCardNo,T1.U_TypeSrv,T2.U_VehReg,T2.U_VehDesc, T2.U_VehModel, T1.U_KmsRead, T1.U_BPCode, T0.CardName, T0.AddrType, T0.Building,T0.Block, T0.Address,T0.City,T0.ZipCode, T0.State1,T0.MailBuildi,T0.MailBlock, T0.MailAddres, T0.MailZipCod, T0.MailCity, T0.State2 ,T0.MailAddrTy, T0.Phone1, T0.Phone2, T0.Cellular
    ORDER BY T1.U_CardDate

  • I need a sim card for my 3G refurbished phone and don't know which one to use.  I get a message IMEI 01181100937 939 4 How do I find the serial number

    I can't find which carrier to use on my refurbished I phone 3 G.  The screen says I need a sim card and has the message IMEI 01 181100 937 9394.  Also ICCID unknown.

    They are free at Corporate Verizon stores; retailers usually charge for them.  You also can call Customer Service and have them send you one.
    And you don't need a SIM card to activate an iPhone 4S on VzW's network.

  • SAP Query-for  Reporting   how to create and use it

    Hi SAP Gurus,
    i need your help. in my project, client is asking to create queries to generate reports, i am not familiar with queries, so would appreciate it if any one can guide me and tell me the procedure for writing and creating queries soon.
    also if you have any study material on steps on How to write and create queries for PP module
    thank you very much

    Hi
    Please refer below document
    http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_Introduction.asp
    Also refer below
    How to Create Infoset Query (SAP Query)
    Steps on how to proceed to create a Query:
    ADHOC QUERY
    A query can be created to extract information from master records  i.e  Infotypes.  For example, by creating a query , the data relating to an employee contained in various Infotypes can be extracted.
    Proceedure :  
    Decide on  the various Infotypes we  want to make the query.  Decide on the area where we  want to query  i.e  Global area or Standard area.  Standard area is client specific and globel area will include all clients.
    Menu : HR – PM – Admn -  Information System -  Adhoc Query
    Select area standard and select the  user group already created
    Creation of new query  :  
    TC SQ03  -  Select Environment – Select Standard Area -  Enter  --  If new user group is to be created, enter name of the user group, click on create and enter necessary information and  exit after saving
    TC SQ02  -  Enter name of the Infoset – Create – enter name of Infoset -  Data source -- >  Table join by basis table – give name of table e.g  pa0000 -  Enter -  Click on insert table if we  want to include more tables – give name of table one by one and after finishing,  place cursor on the joining lines and right click to delete unwanted relationships  - check  - and go back  - field groups  -  include all table fields  - click on generate button   -  go out
    TC SQ03  -  Select user group  -   eg.  Payroll
    Infoset  - Enter name of newly created Infoset 
    Assign users and Infosets  -  Assign infosets  -  put tick on payroll  - save and go back
    TC  PAAH  -  Expand the nodes and put tick on relevant fields depending upon necessity
    Save the query  by giving the same name as infoset for easyness..
    For executing a query which is already created
    1. Go to SQ01 transaction
    2. Go to Environment menu->query areas->std areas
    3. Then choose the user group where the query is created
    4. It will display all the queries created for the group.choose the query you want to executeand click execute.
    5. will take to the initial screen
    6. Enter the required parameters and execute
    Regards
    Ranga
    Message was edited by:
            Ranganathan Srinivasamurthy

  • Steps for replicating GR custom field values from EBP to SAP R/3

    Dear SRM Gurus,
    We wre using SRM 5.0 extended classic scenario..
    We are having 3 custom fields for GR in SRM, we want to replicate these values to 3 other standard fields in SAP R/3..
    Can you pls tell us the Procedure, Steps and standard objects that has to be changed for replicating the GR field values from SRM to SAP R/3(4.6C).
    Thanks in advance,
    Chandra Sekhar.

    Hi
    <b>Please go through the following links -></b>
    Re: Confirmation screen field to be mapped to backend field
    Re: Creating Confirmations in SRM - What is the preferred method
    Re: GRN IDOC Transfer to ERP  - MBGMCR01 ( 2 IDOCS created)
    Re: Problem to send idoc for a Good Receipt created
    GR IDOC Number
    Re: Idoc error in Goods confirmation - urgent
    Re: Delete goods confirmation in SRM3.0
    Re: SRM / MM integratuion: goods receipt
    IDOC MBGMCR01: CO Ctd-pedido exceeded by 1 UN:
    <b>Some useful SAP OSS Notes to refer -></b>
    Note 521488 - FAQ: MB_CREATE_GOODS_MOVEMENT
    Note 521427 - FAQ: IDocs for goods movements
    Note 521488 - FAQ: MB_CREATE_GOODS_MOVEMENT
    Hope this will definitely help.
    Regards
    - Atul

  • Query for inserting data into table and incrementing the PK.. pls help

    I have one table dd_prohibited_country. prohibit_country_key is the primary key column.
    I have to insert data into dd_prohibited_country based on records already present.
    The scenario I should follow is:
    For Level_id 'EA' and prohibited_level_id 'EA' I should retreive the
    max(prohibit_country_key) and starting from the maximum number again I have to insert them
    into dd_prohibited_country. While inserting I have to increment the prohibit_country_key and
    shall replace the values of level_id and prohibited_level_id.
    (If 'EA' occurs, I have to replace with 'EUR')
    For Instance,
    If there are 15 records in dd_prohibited_country with Level_id 'EA' and prohibited_level_id 'EA', then
    I have to insert these 15 records starting with prohibit_country_key 16 (Afetr 15 I should start inserting with number 16)
    I have written the following query for this:
    insert into dd_prohibited_country
    select     
         a.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
    from
         (select
              max(prohibit_country_key) pkey
         from
              dd_prohibited_country) a,
         (select
    prohibit_country_key pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
         from
              dd_prohibited_country
         where
              level_id = 'EA' or prohibited_level_id = 'EA') b
    My problem here is, I am always getting a.pkey as 15, because I am not incrementing it.
    I tried incrementing it also, but I am unable to acheive it.
    Can anyone please hepl me in writing this query.
    Thanks in advance
    Regards
    Raghu

    Because you are not incrementing your pkey. Try like this.
    insert
       into dd_prohibited_country
    select a.pkey+b.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
       from (select     max(prohibit_country_key) pkey
            from dd_prohibited_country) a,
         (select     row_number() over (order by prohibit_country_key)  pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
            from     dd_prohibited_country
           where level_id = 'EA' or prohibited_level_id = 'EA') bNote: If you are in multiple user environment you can get into trouble for incrementing your PKey like this.

  • Which version of PhotoShop Elements should I buy for Windows Vista Home Premium and from what source?

    First time buying PhotoShop.  I need it for a project I'm involved with at my school, but I can't download Creative Cloud or PhotoShop Elements 13 because Vista is not supported by Adobe.  However, I find it easier to find a version more fit for my computer rather than upgrade it (I'll just be brief, it's not convenient AT THIS TIME for me to attempt to upgrade my PC, even if many believe it'd be better for me).
    I was just planning on looking on Amazon for PhotoShop Elements PC boxes available and going with whatever version 11 or below that was at a good price.  Is this a good way to go or is there something special about purchasing CD's to download I need to be aware of?  Is buying from a source like Amazon rather than straight from Adobe putting me at risk for a phony version of PhotoShop Elements (though I was looking to buy a "new" box to avoid this if I can find some)?
    I'm having trouble finding WHERE Adobe sells its products from its own website rather than Creative Cloud right now.  A link would very much be appreciated if such a place exists.  Thank you.

    You can download a free trial version for PSE 10, 11 or 12 from this link:
    <Download Photoshop Elements products | 13, 12, 11, 10>
    You can use this trial version for 30 days after which you will need to buy a boxed version from Amazon and use the serial number from the box to activate your trial version.
    If, however, you complete your project in the next 30 days then you don't need to buy anything.  Money saved for something else.
    Good luck.

  • ABAP User Roles and Query for accessing particular T- codes and Reports

    dear Gurus
    I have one problem, i want to know about ABAP User Query ,i have one requirement my user wants to Lock all the HR Std versus Customized reports in T- code SQ01,other department peoples also see the Payslips and Hr personal reports which is harmfull to the dept so i want to Lock all the reports in Std T- code in SQ01 and i have created one Customized User Roles or Query in which the T-codes and Reports are assigned only those particular user can access the T-codes and Std reports .how can it be possible i dont have any idea about user roles and Queries .
    kindly help me out or send me some documents related to user roles and queries
    regards ritesh sharma

    Hi Ritesh,
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/103cafc2-7a64-2b10-14b3-eddb7d324561
    Regards,
    Flavya

  • Query regarding creating a Custom Event and Firing.

    I have created a custom event,a custom listener and a custom button.
    But when I click on custom button,my event is not being fired.
    When and how do I need to invoke the fireEvent() ?
    Please can any body tell me if I have overlooked any thing ?
    Thanks,
    // 1 Custom Event
    import java.util.EventObject;
    public class MyActionEvent extends EventObject{
            public MyActionEvent(Object arg0) {
         super(arg0);
    // 2 Custom Listener
    import java.util.EventListener;
    public interface MyActionListener extends EventListener {
          public void myActionPerformed(MyActionEvent myEvent);
    // 3 Custom Button
    public class MyButton extends JButton {
        // Create the listener list
        protected javax.swing.event.EventListenerList listenerList = new javax.swing.event.EventListenerList();
          public MyButton(String str){
         super(str);
         public void addMyActionEventListener(MyActionListener listener) {
             listenerList.add(MyActionListener.class, listener);
        protected void fireMyActionEvent() {
            MyActionEvent evt = new MyActionEvent(this);
            Object[] listeners = listenerList.getListenerList();
           for (int i = 0; i < listeners.length; i = i+2) {
                 if (listeners[i] == MyActionListener.class) {
                      ((MyActionListener) listeners[i+1]).myActionPerformed(evt);
    } // end of class MyButton.
    // 4 Test my Custom Event,Listener and Button
    public class MyButtonDemo extends JPanel {
        protected MyButton b1;
        public MyButtonDemo() {
            b1 = new MyButton("Disable Button");
            b1.setToolTipText("Click this button to disable the middle button.");
            b1.addMyActionEventListener(new MyActionListener() {
         @Override
         public void myActionPerformed(MyActionEvent myEvent) {
         System.out.println("My ActionEvent....");
            add(b1);
        private static void createAndShowGUI() {
            JFrame frame = new JFrame("ButtonDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            MyButtonDemo newContentPane = new MyButtonDemo();
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

    Hi Stan,
    I would like to use my custom action listener rather that using the the normal actionPerformed(ActionEvent e)
    But some how this event is not being fired.
    Any suggestions to fire this?
    b1.addMyActionEventListener(new MyActionListener() {
             @Override
             public void myActionPerformed(MyActionEvent myEvent) {
         System.out.println("My ActionEvent triggered....");
    });

  • SAP query for asset report with retirement and depreciation retirement

    Hi Expert,
    Can anyone tell me in table ADA which filed is holding the figure of retirement and retirement depreciation?
    Thank oyu

    Hi,
    Max.
    For your question you can check the tables ANEP for asset transactions line items and for asset value fields you can check out ANLC.
    I hope this may help you.
    If you have any doubts feel free to ask.
    Regards,
    Pankaj A Bhalerao.

  • I received pictures in a dozen emails and saved each picture into one file in .pages.  I did not import the photos before doing this and now iPhoto won't recognize the pictures because they are in a .pages file.  How do I get the pics to iPhoto?

    I received a dozen pictures in a few emails and I saved them all into one file in pages.  I just copied and pasted.  I do not have the originals any longer.  Iphoto will not permit me to import the pictures as it does not recognize a .pages file, nor can I simply click and drag from the pages document to iphoto nor from pages to the desktop to iphoto.  How can I save each picture I guess back into a jpeg and then import them into iphoto or have i lost them to a pages document forever?  This is urgent as I need the pictures made into a book on iphoto for work by Friday!!!  Please advise!  Thank you.

    Greetings,
    Locate the Pages document wherever it's located on your computer and click once on it to highlight it.
    Go to File > Duplicate to make a backup copy of the file.
    Click once again on the file to highlight it.
    Go to File >  Get Info
    In the "Name & Extension" category remove the ".pages" extension and put in ".zip".
    Close the info window and double-click the now renamed pages file (zip file now).It will decompress into a folder which contains all the base components including all the images you added.  These can be dragged onto the iPhoto icon to import them.
    Hope that helps.

  • Evevy song i have is duplicated, i try to delete the old one, but if i do, the new one dissapears also, i saw at the explorer window and every song is just one file

    My library is duplicated, i did what the support suggest but if i delete the old song the new one also dissapears, i reviewed the windows file and only appears one file, i try to find an answer but do not have yet any.

    I've written a script called DeDuper which can help remove unwanted duplicates. See this  thread for background.
    tt2

  • Merging PDFs and then saving them as one file in Leopard

    Would someone please tell me how I can merge PDF files into one PDF file. I have been able to drag and drop them together in Preview. I would love to be able to save the merged files into one file. Any ideas. I have read a lot online about this possibility in Snow Leopard, but I can't seem to save the dang file.
    Help.

    Open the first PDF. Open the tray so you can see the file on the left. Drag the other PDFs onto the first file in the tray. You can't just drag into the tray window anymore, you have to drag onto the file itself to merge. Save the file with new name.
    Macmost has a good podcast on this subject that came out about a week ago. Shows other PDF tricks with Preview as well.

  • SAP B1 query for turnover in sales sorted by item and supplier.

    Hello experts,
    please, is it possible to create a query SAP B1 for finding turnover in sales by item and supplier? I would need to know exact total quantity of sold items sorted by supplier.
    Is it possible?
    Thank you in advance 
    jonmar7

    Try to include Credit Memo in this way:
    SELECT T4.CardCode,T4.CardName, SUM(T0.Price * T0.Quantity) AS turnover,SUM(T0.Quantity) AS QTY, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName
    FROM INV1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T2.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OINV T3 ON T3.DocEntry = T0.DocEntry INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode
    WHERE T4.CardName LIKE '[%0]%'AND T3.DocDate Between [%1] AND [%2]
    GROUP BY T4.CardCode, T4.CardName, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName
    UNION ALL
    SELECT T4.CardCode,T4.CardName, SUM(-T0.Price * T0.Quantity) AS turnover,SUM(-T0.Quantity) AS QTY, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName
    FROM RIN1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T2.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN ORIN T3 ON T3.DocEntry = T0.DocEntry INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode
    WHERE T4.CardName LIKE '[%0]%'AND T3.DocDate Between [%1] AND [%2]
    GROUP BY T4.CardCode, T4.CardName, T2.ItmsGrpNam, T5.GroupName, T1.ItemCode, T1.ItemName
    Inventory transfer should not affect your sales at all.  As for A/R Correction Invoice, you need to include OCSI and CSI1 tables.  We don't have those data to try.  You have to add them by yourself.

  • Approval Query for a specific customer group

    Dear Experts,
                 Following is the scenario, customer deals with whole sale and retail customers group. The client wishes to ensure that If the whole sales customer group account balance greater than zero then while making a sales order or invoice it should trigger approval.
    Saravanan

    Hi Saravnan......
    Thy this Approval Query and just put the Group Code for your customer in this group code's inverted comma....
    SELECT Distinct 'TRUE' From OCRD T0 Where T0.Balance>0 and GroupCode=' '
    And T0.CardCode=$[ORDR.CardCode.0]
    If above does not work then use below...
    SELECT Distinct 'TRUE' From OCRD T0 Where T0.Balance>0 and GroupCode=' '
    And T0.CardCode=$[$4.0.0]
    Regards,
    Rahul

Maybe you are looking for

  • What is happening overriding method  in JVM

    1.what is happeining in JVM while i do overriding method ? 2. why we cant create object for abstract class. what is happeining in JVM? HOW TO I KNOW internal process of JVM above i mentioned . is there any book for this?

  • Solution Manager key error when installing ECC6

    hi Iam installing ECC6 abap+java and facing a problem with the solution manager generated key.Each time iam putting in the key its says its the wrong one. i dont know where iam making a mistake.i managed to generate one before when upgarding to ECC6

  • My ihone only displays a white screen and I want to fix it myself.

    my iphone will only display a white screen can I fix it and how can I?

  • Keynote: Some images are missing

    Ever since I upgraded to Keynote 6.2 and Mac OS 10.9.3 my images are deleted somewhere between me saving the file, and retrieving the file again later. Last night I was working on a brand new presenation I created (not upgraded or imported). Everythi

  • Safari Unexpected Quit, but I do expect it.

    My Safari has recently started crashing almost every time I go to the adobe flash forums page. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid=15&catid=288 Not every time, but most times. If I first go empty cache and then go to t