SQL for Top 10 Products Sold

Hi Everyone. I want to report on my top 10 products sold by Volume not Invoiced amount. Any ideas?
SELECT TOP 10 T1.[ItemCode],
MAX (T1.[Dscription]),
SUM (T1.LineTotal)
FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.[DocDate] BETWEEN [%0] AND [%1] GROUP BY T1.ItemCode
Thanks

Hi,
Try this:
SELECT top 10 (T1.[Volume]), T0.[DocNum], T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription], sum(T1.[LineTotal]) FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDate]  between [%0] and [%1] GROUP BY T0.[DocNum], T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription],T1.[Volume]
Thanks & Regards,
Nagarajan

Similar Messages

  • How to generate reports for specific products sold in e-commerce

    Hello,
    I am going to start letting products from other manufactures be sold in my online store and do a percentage split of the profit with the manufacture. I was wondering how to tag those specific products and generate a report on how many products were sold and what the gross income was from those products. This will make the quartly accounting so much easier....
    Thank you for any help...

    Supplier - Choose a supplier that you source this product from. Setting this value is useful for when you report on your sales to see which supplier products are most popular.
    Commission Payable % - The commission percentage number is stored for each product in an order. If you have to pay commissions to suppliers for selling their products then setting this number allows you to run reports that calculate the final amounts for you.
    Yea I found this stuff eairlier but the question is how do you actually run the report and how do you set up a supplier? I don't see why this is so hard it should be in the custom reports section of the reports tab. Then make new eComerce report, then pick supplier then filter for sales by supplier. But there is no filter for sales... just a filter for status and country. And I would think that you would add a supplier to the affilate program but that is actually for something else entirely. Sorry this is probably very simple and I am over complicating it...
    Thanks for your help...  

  • Sql for top sql

    Dear DBAs
    Application team has asked me to provide TOP Sql statements in testing database which can help them to improve code. Developer gave OEM top sql example from his last job.
    Currently I do not have OEM installed. I am on 10.2.0.1.0 . I was thinking
    to create a job to run sql and email everyday.
    What sql can I use to generate that report ? What does OEM reports on when it show TOP Sql ?
    Thanks

    OEM will show you TOP sql by different catogories (each of which can be sorted) such as:
    Disk Reads Per Execution
    Buffer Gets Per Execution
    Executions
    Disk Reads
    Buffer Gets
    Buffer Gets Per Row
    Buffer Cache Hit Ration
    Sorts
    Shareable memory
    Rows Processed
    CPU Time
    Elapsed Time
    Now having said that....just because the TOP sql statement is the TOP sql statement does not mean that anything needs tuned. Your developers should be examining their SQL using insite gained from reading articles and documentation.
    Tuning use explain plan:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:231814117467
    SQL Tuning
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sql_1016.htm#sthref1061
    Automatic SQL Tuning
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sql_tune.htm#g42443
    In particular:
    12.2.4 Using SQL Tuning Advisor with Oracle Enterprise Manager
    These links should point you in the right direction:
    Of course there are books and Oracle classes that concentrate on these issues as well.
    Regards
    Tim Boles

  • Looking for the oracle equivalent of T-SQL 'SELECT TOP n'

    Hi,
    I'm looking for the Oracle equivalent of T-SQL 'SELECT TOP n'
    and can't find any. There is SAMPLE(n) function but it supposed
    to pick up random values and I'm not sure if it's possible to
    make it select top values. Please help 8-)
    Thanx

    Hi Marina.
    Oracle does not have a functionality like SQL Server for TOP
    selection. The ROWNUM option should be used with great care and
    you may get unreliable results.
    Try looking at Metalink
    Doc ID: 291065.999
    Doc ID: 267329.999
    - They discuss this issue, and solutions.

  • Query for top 10 selling products and their current stock

    Hi ppl
    I am using the sales overview cube 0SD_C03 to get top 10 selling products. What I want is to get the current stock available of the top 10 products from Material Stocks/Movements cube 0IC_C03. From what I know, we have to make a multiprovider to get this information. Can anyone guide me how to go about it?

    Hello Javed,
                         You can use Replacement path for this.
    1.Create a report for Top 10 Products in InfoCube 0SD_C03 - Exampls Report A
    2.Create another report with Stock and use a variable for Product with processing type replacement path in InfoCube0IC_C03 - Example Report B
    3. In Report B and assing the Report A to this variable.
    When you execute the Report B it will execute the Report A in background and displays it in Report B.
    Hope it helps,
    thanks
    Chandran

  • SQL for pulling description from product identification section off of summ

    I tried using the DB schema tool to generate sql for pullling the Description field off of the Product Indentification section on the summary tab and it came up with zero records even though i know we have a few 1,000 specs that use that field.
    Can you send me the sql that i should be using or the table to look in to find that text??
    thanks,
    David

    This should get you started,
    select
      ss.SpecNumber as "Spec Number"
      , ssn.name as "Spec Name"
      , sdftp.Description as "Description"
    from SpecDescriptionFreeTextProp sdftp
      inner join gsmProductIdentification gpi on sdftp.fkSpecID = gpi.pkid
      inner join SpecSummary ss on gpi.fkSpecID = ss.SpecID
      inner join SpecSummaryName ssn on ssn.fkSpecsummary = ss.PKID
    where
      ssn.langid = 0

  • Will Apple improve the earbud structure? The current ones kill my ears. For the price consumers pay for these products, we should receive top notch earbuds that fit the ear.

    Will Apple improve the earbud structure? The current ones kill my ears. For the price consumers pay for these products, we should receive top notch earbuds that fit the ear.

    Some phones that you can buy do not come with headphones at all.
    http://apple.com/feedback

  • Equivalent for TOP 1 of SQL Server used in subqueries

    Hi all,
    I am trying to migrate a sql query from SQL Server to Oracle 9i, which uses the SQL Server TOP keyword in correlated subqueries.
    How should I write it in Oracle?
    The query is more complicated, but in principle looks like:
    SELECT TAB1.t1_id, TAB2_t2_id,
    ISNULL((select top 1 val_num
    from values where values.val_id = TAB1.val_id ) ,0),
    TAB1.date,
         (select top 1 TAB3.t3_id from TAB3 where TAB3.name = TAB1.name)
    FROM TAB1, TAB2
    WHERE TAB1.org_id = TAB2.org_id
         AND TAB1.date > TO_DATE('2006-01-01', 'YYYY-MM-DD')
         TAB2.required IS NOT NULL
    If I would remove in each subquery the "top 1" and add "and rownum = 1", it will not work.
    Any suggestions?
    Thanks,
    Paul

    http://www.ispirer.com/doc/sqlways38/Output/SQLWays-1-044.html

  • SQL for self foreign key has me baffled

    Hi guys,
    This is probably really simple. I am wanting to write an sql
    for a dropdown menu for my top nav in my application. What it is,
    is I have one column for ID ( primary ) and another for subID and a
    page name ( txt) - seems like it would be simple , but I can't seem
    to get it to work.
    <cfquery name="getNav2" datasource="#application.db#">
    SELECT ID, subID, pagetype, dapage, menuText, title, dasorter
    FROM masterPager
    ORDER by ID, subID, dasorter, menuText, dapage
    </cfquery>
    I have tried a where statement ( WHERE ID = subID ) and that
    brings up nothing.
    There is a diagram of what I want here -
    http://www.interaktonline.com/Products/Dreamweaver-Extensions/MXCSSMenus/Documentation/Art icles/Design+Your+Database-Databases+By+Example.html?id_art=24&id_asc=222
    ( all one line ) They show the table, but not the SQL
    The group on the output ( am a little confused )
    What I want is for it to look like a tree - then I can apply
    my CSS dropdown code.
    Home
    About Us
    About_sub1
    About_sub2
    Contact
    Contact_sub1
    Contact_sub2
    Products
    Products_sub1
    Products_sub2
    Products_sub3
    Disclaimer
    Privacy
    Any help would surely be appreciated.
    Thanks in advance

    I'm not sure what database you are using, but assuming SQL
    Server, the query below will select all rows and order them either
    by their sub_ID, or if the subID is NULL, the ID field would be
    used in its place. Items with a NULL subID would be the "primary"
    (top level) menu items. This would output your items in the proper
    order. In the output, you would group by subID then loop through
    and check to see if the ID=subID (which woud indicate the top level
    menu items) and the ones following them would be the sub-menu
    items.
    <cfquery name="getNav2" datasource="#application.db#">
    SELECT ID, ISNULL(subID, ID) AS sub_id, pagetype, dapage,
    menuText, title, dasorter
    FROM masterPager
    ORDER by 2, 1, 3, 4, 5, 6
    </cfquery>
    Phil

  • ORA-01489 Received Generating SQL for Report Region

    I am new to Apex and I am running into an issue with an report region I am puzzled by. Just a foreword, I'm sure this hack solution will get a good share of facepalms and chuckles from those with far more experience. I welcome suggestions and criticism that are helpful and edifying!
    I am on Apex 4.0.2.00.07 running on 10g, I believe R2.
    A little background, my customer has asked an Excel spreadsheet be converted into a database application. As part of the transition they would like an export from the database that is in the same format as the current spreadsheet. Because the column count in this export is dynmic based on the number of records in a specific table, I decided to create a temporary table for the export. The column names in this temp table are based on a "name" column from the same data table so I end up with columns named 'REC_NAME A', 'REC_NAME B', etc. (e.g. Alpha Record, Papa Record, Echo Record, X-Ray Record). The column count is currently ~350 for the spreadsheet version.
    Because the column count is so large and the column names are dynamic I've run into a host of challenges and errors creating this export. I am a contractor in a corporate environmentm, so making changes to the apex environment or installation is beyond my influence and really beyond what could be justified by this single requirement for this project. I have tried procedures and apex plug-ins for generating the file however the UTL_FILE package is not available to me. I am currently generating the SQL for the query in a function and returning it to the report region in a single column (the user will be doing a text-to-column conversion later). The data is successfully being generated, however, the sql for the headers is where I am stumped.
    At first I thought it was because I returned both queries as one and they were joined with a 'union all'. However, after looking closer, the SQL being returned for the headers is about +10K+ characters long. The SQL being returned for the data is about +14k+. As mentioned above, the data is being generated and exported, however when I generate the SQL for the headers I am receiving a report error with "ORA-01489: result of string concatenation is too long" in the file. I am puzzled why a shorter string is generating this message. I took the function from both pages and ran them in a SQL command prompt and both return their string values without errors.
    I'm hopeful that it's something obvious and noobish that I'm overlooking.
    here is the code:
    data SQL function:
    declare
      l_tbl varchar2(20);
      l_ret varchar2(32767);
      l_c number := 0;
      l_dlim varchar2(3) := '''|''';
    begin
      l_tbl := 'EXPORT_STEP';
      l_ret := 'select ';
      for rec in (select column_name from user_tab_columns where table_name = l_tbl order by column_id)
      loop
        if l_c = 1 then
            l_ret := l_ret || '||' || l_dlim || '|| to_char("'||rec.column_name||'")';
        else
            l_c := 1;
            l_ret := l_ret || ' to_char("' || rec.column_name || '")';
        end if;
      end loop;
        l_ret := l_ret || ' from ' || l_tbl;
      dbms_output.put_line(l_ret);
    end;header sql function:
    declare
      l_tbl varchar2(20);
      l_ret varchar2(32767);
      l_c number := 0;
      l_dlim varchar2(3) := '''|''';
    begin
      l_tbl := 'EXPORT_STEP';
      for rec in (select column_name from user_tab_columns where table_name = l_tbl order by column_id)
      loop
        if l_c = 1 then
            l_ret := l_ret || '||' || l_dlim || '||'''||rec.column_name||'''';
        else
            l_c := 1;
            l_ret := l_ret || '''' || rec.column_name || '''';
        end if;
      end loop;
        l_ret := l_ret || ' from dual';
      dbms_output.put_line(l_ret);
    end;-------
    EDIT: just a comment on the complexity of this export, each record in the back-end table adds 12 columns to my export table. Those 12 columns are coming from 5 different tables and are the product of a set of functions calculating or looking up their values. This is export is really a pivot table based on the records in another table.
    Edited by: nimda xinu on Mar 8, 2013 1:28 PM

    Thank you, Denes, for looking into my issue. I appreciate your time!
    It is unfortunately a business requirement. My customer has required that the data we are migrating to this app from a spreadsheet be exported in the same format, albeit temporarily. I still must meet the requirement. I'm working around the 350 columns by dumping everything into a single column, which is working for the data, however, the headers export is throwing the 01489 error. I did run into the error you posted in your reply. I attempted to work around it with the clob type but eneded up running into my string concatentation error again.
    I'm open to any suggestions at this point given that I have the data. I'm so close because the data is exporting, but because the columns are dynamic, the export does me little good without the headers to go along with it.

  • Pricing Procedure for diffrent unit of measure for diffrent product

    1) Existing Pricing procedure --> Condition type based on Quantity
    2) Existing Product --> Sales Unit & Base Unit of Measurement is in NOS ( Numbers )
    3) New Product ( Belt ) ---> Pricing of product based on weight
    ex :--> Rubber Belt -->   1 belt = 11.50 kg , Price = Rs. 100/ kg
    As the production of material will go on weight of Belt will reduce in range of 11.50 to 11 kg . For different batch of production weight will change
    every time weight of material will be calculated and price will be charged on basis of net weight ( Kg)
    4) New product is assigned to new division ( it will bw sold in new division only )
    Question
    1) What should be Base Unit / Sales Unit  of measurement ?
    2) Do we need to create new pricing procedure or existing pricing procedure will work ?
      for new product  we need to create new condition type for which calculation type will be Net Weight .
    3) do we need to do any customization for this ?
    Exice people say that if pricing is done in KG (Net weight ) they want to see stock in KG
    Management want to see stock in KG & Numbers

    May be you can Create a New Unit Of Measure called ZPC. For using ZPC you need to assign Additional Base Unti Of Measure as ZPC in your Material Masters as well.
    Use ZPC to create your condition records of pricing and in Sales order you will still have Unit of Measure as PC which the management wants to see..
    Similarly you can create Constion records for new product based on Kg.

  • TCS 2 on Windows 7 - "Licensing for this product has stopped working"

    I just spent the last 6 days (since 4/8) with Adobe Technical Support. I have a Dell Latitude 630 Laptop running Windows 7 32-bit. For no reason at all (as is usually the case), RH8 crashed after I ran  spell check. Unfortunately, unlike all the other times, it would not restart. The error message box I kept getting (and 4 says later am still getting) is "Licensing for this product has stopped working". The only thing I've learned from this 4-day ordeal is that no one at Adobe Technical Support knows how to do anything but uninstall and reinstall this product. And, for some reason, Adobe has released this software fully aware that it will not completely uninstall using Windows 7's uninstaller - You must also then run both the Windows Uninstaller Cleaner (after downloading & installing it) and their own CS3 Uninstaller Cleaner.
    After doing that twice (completely uininstalling and reinstalling), and waiting for 1) the first tech to open a case - it took him 4 days; and 2) the "top level" of support to contact me - that took 2 more days. After telling me how to completely uninstall the suite (yep, that's her fix, too), she has just advised me that the SW won't run because my computer is on a Domain. Yes, my company requires that all of our computers be connected to our Domain. What company doesn't?What is also interesting is that none of my co-workers, who are also running Windows 7, have had this problem. How many of you are successfully using TCS2 on Windows 7 32-bit AND are on a Domain? I'll bet that there are a lot of you out there. Congratulations to you all for still being able to do so! I envy you.
    THE FIX: (And this is from Adobe's top level of support, or so I was told.) I've been told that I must create a Local User Account on my laptop that has Admin privileges but is NOT on a Domain, and install the TCS2 software onto that account. This will fix my problem. Interestingly, the first tech had me log onto his Adobe software that allowed him to see my desktop. Didn't he see that I was on a Domain? Or maybe he just isn't privy to this information because he's not high up enough.
    I hope that this information keeps at least 1 other person from having to go thru 6 (or less or more) days of repeating your problem to countless Adobe techs who all tell you to do the exact, same thing. And, of course, hearing each one apologize for "the inconvenience" and being "so sorry you are experiencing difficulties".
    Here a thought - Don't release your software until it works.
    Here's another thought - Don't claim that your software works on a platform until it actually does. As my co-worker Ed says, "Got an Issue? Get a tissue!"
    Cheers,
    Critterlover1075

    Peter,
    The higher-tiered (supposedly) Tech had me go to that Web page and follow those instructions earlier this week. I followed all of them, and still had the same problem. That was when she told me that the problem is because my laptop is connected to a Domain (see first post).
    4/15/10 Update: My IT support gave me the password to log onto my laptop using the Administrator logon. This login is not connected to our Domain because it is used by our IT folks to troubleshoot problems with the laptop itself. I installed only Acrobat, RoboHelp, and FrameMaker from this login last night. Then I opened Acrobat 9 and "updated" everything. RoboHelop 8 now works (and it is accessible from my regular login), but FrameMaker is now giving an error message, something about the dictionaries, and it does not open. Here is the error dialog being thrown now by FrameMaker 9:
    I have updated my case with this info and the screenshot of the error dialog. If you know what is causing this error in FM, please let me know what to do to fix it.
    Thank you for your help!
    Marlo

  • Missing shared feature Reporting Services Sharepoint and Reporting Services Add-in for Sharepoint products

    Hi, when I try to install SQL Server 2012 SP1 (ISO from Microsoft Download website) on a Windows Server 2012 and try to select the shared feature options: 
    - Reporting Services Sharepoint
    - Reporting Services Add-in for Sharepoint products
    They are both missing from the list.
    How do I solve this? Help!

    Hello,
    Did you download the SQL Server 2012 Express with Advanced Services edition from the Microsoft website? If so, this edition did not support SharePoint Integration mode.
    Just as Alberto post above, Business intelligence features are not all available in all editions of SQL Server 2012. You can refer to the following link about support features in Editions of SQL Server 2012:
    Reference:http://technet.microsoft.com/library/cc645993(SQL.110).aspx#Reporting
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here.
    Fanny Liu
    TechNet Community Support

  • Custom report for TOP 10 CPU Utilization machines from any group in aggregation last seven days

    I want to create a custom report that contain list of TOP CPU Utilization of machines form any group.This report is create on last 7 days CPU utilization of all machine from a group.
    What  should be query for this report.

    Hi,
    Please refer to the links below:
    SQL Query for TOP 10 Average CPU
    https://social.technet.microsoft.com/Forums/systemcenter/en-US/8d9a2d0d-8761-4d1f-b194-b24aa65172e1/sql-query-for-top-10-average-cpu?forum=operationsmanagerreporting
    How to use Report Builder to create custom reports in SCOM 2007
    http://www.systemcentercentral.com/how-to-use-report-builder-to-create-custom-reports-in-scom-2007/
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Report for Monthly Quantiy sold by Customer (SOLD TO PARTY)

    Hi Gurus
    I had asked this question many times but no answer I got from the forum , I want to create a report which should show quantity , uom sold to customer(sold to party) by each month and plant (werks).
    I want to display monthly sales in the report when plant and delivery date is selected ( month = jan,feb,mar,apr,may......) and each quantity must display under jan,feb,mar,apr respectively.
    Can anyone help me please , I am still struggling with this stuff.
    Thanks in advanced
    Regards
    PE

    Hi Aatish
    I have developed the report for monthlywise quantity sold to party
    but it is giving some trouble in the calculation where there is zero value it is taking the above value and displaying in the report but when I search individually with sold to party it is comming correctly
    can you check my source and comment on it please
    REPORT soldtoparty
    line-size  170
    line-count 65 no standard page heading.
    TABLES : kna1,VBRP,vbrk.
    DATA:BEGIN OF itab OCCURS 0,
    kunag like VBRK-KUNAG,
    name1  like kna1-name1,
    werks LIKE vbrp-werks,
    vbeln LIKE vbrp-vbeln,
    fkdat LIKE VBRK-FKDAT,
    vrkme LIKE vbrp-vrkme,
    fkimg LIKE vbrp-fkimg,
    total like vbrp-fkimg,
    END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0,
    fkdat(2) TYPE c,
    kunag like VBRK-KUNAG,
    name1  like kna1-name1,
    werks LIKE vbrp-werks,
    vbeln LIKE vbrp-vbeln,
    vrkme LIKE vbrp-vrkme,
    fkimg LIKE vbrp-fkimg,
    total like vbrp-fkimg,
    END OF itab1.
    DATA : BEGIN OF itab2 OCCURS 0 ,
    fkdat like VBRK-FKDAT,
    fkimg like vbrp-fkimg,
    kunag like VBRK-KUNAG,
    name1  like kna1-name1,
    vrkme  like vbrp-vrkme,
    jan LIKE vbrp-fkimg,
    feb LIKE vbrp-fkimg,
    mar LIKE vbrp-fkimg,
    apr LIKE vbrp-fkimg,
    may LIKE vbrp-fkimg,
    jun LIKE vbrp-fkimg,
    jul LIKE vbrp-fkimg,
    aug LIKE vbrp-fkimg,
    sep LIKE vbrp-fkimg,
    oct LIKE vbrp-fkimg,
    nov LIKE vbrp-fkimg,
    dec LIKE vbrp-fkimg,
    TOTAL like vbrp-fkimg,
    END OF itab2.
    TOP-OF-PAGE.
      WRITE:/50(40) ' CUSTOMER SOLD BY QUANTITY' CENTERED   ,2 'Page', SY-PAGNO.
      WRITE:/50(40) '----
    ' CENTERED .
      FORMAT INTENSIFIED on.
      WRITE:/2 SY-DATUM COLOR 3, SY-UZEIT .
       "WRITE:/1 S903-SPMON ."p_yearf.
      ULINE.
      "CENTERED.
      skip.
      "FORMAT COLOR COL_HEADING.
      ULINE.
      FORMAT COLOR 3.
      WRITE:/1 SY-VLINE,
        0 'PARTY' ,10 SY-VLINE,
        11 'NAME' ,40 SY-VLINE,
        41 'JAN' centered  , 50 SY-VLINE,
        51 'FEB',60 SY-VLINE,
        61 'MAR',70 SY-VLINE,
        71 'APR',80 SY-VLINE,
        81 'MAY',90 SY-VLINE,
        91 'JUN',100 SY-VLINE,
        101 'JUL',110 SY-VLINE,
        111 'AUG',120 SY-VLINE,
        121 'SEP',130 SY-VLINE,
        131 'OCT',140 SY-VLINE,
        141 'NOV',150 SY-VLINE,
        151 'DEC',160 SY-VLINE,
        161'TOTAL',170 SY-VLINE.
      FORMAT COLOR 3 on.
      ULINE.
    END-OF-PAGE.
    data wa_itab1 like itab1.
    DATA : mm(2) TYPE c,
    value type p decimals 2,
    total type p decimals 2,
    sum1 type p decimals 1,sum2 type p decimals 1,sum3 type p decimals 1,
    sum4 type p decimals 1,sum5 type p decimals 1,sum6 type p decimals 1,
    sum7 type p decimals 1,sum8 type p decimals 1,sum9 type p decimals 1,
    sum10 type p decimals 1,sum11 type p decimals 1,sum12 type p decimals 1,
    sum13 type p decimals 1,
    t_s LIKE vbrp-fkimg.
    "g_total like vbrp-fkimg.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS: p_yearf TYPE SPMON,
    p_yeart type SPMON.
    SELECT-options:
                    p_kunag for VBRK-KUNAG , "no-extension no intervals,
                    s_werks for vbrp-werks no-extension no intervals obligatory,
                    s_vrkme for vbrp-vrkme no-extension no intervals obligatory.
    "p_matnr for vbrp-matnr no-extension no intervals,
    "p_augru for vbrp-augru_auft no-extension no intervals,
    "p_vbeln for vbrk-vbeln no-extension no intervals.
    RANGES : p_fkdat FOR sy-datum.
    RANGES: r_date FOR sy-datum.
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    PARAMETERS: NRW RADIOBUTTON GROUP g1,
    MWD RADIOBUTTON GROUP g1,
    RWS RADIOBUTTON GROUP g1,
    EDU RADIOBUTTON GROUP g1,
    Standard RADIOBUTTON GROUP g1 default 'X'.
    SELECTION-SCREEN END OF BLOCK blk2.
    SELECTION-SCREEN END OF BLOCK blk.
    start-of-selection.
    break developer.
    case 'X'.
    when mwd.
    CONCATENATE p_yearf(4) p_yearf+4(2) '01' INTO p_fkdat-low.
    concatenate p_yeart(4) p_yeart+4(2) '01' into p_fkdat-high.
    p_fkdat-sign = 'I'.
    p_fkdat-option = 'BT'.
    CALL FUNCTION 'RE_LAST_DAY_OF_MONTH'
    EXPORTING
    i_datum = p_fkdat-high
    IMPORTING
    e_tt = p_fkdat-high+6(2).
    APPEND p_fkdat.
    *start-of-selection.
    SELECT *
    from VBRK
    INNER JOIN vbrp ON vbrk~vbeln = vbrp~vbeln
    INNER JOIN kna1 on vbrk~kunag = kna1~kunnr
    INTO corresponding fields of TABLE itab
    where
    vbrp~werks in s_werks and
    VBRK~KUNAG in p_kunag and
    VBRP~vrkme in s_vrkme and " 'M3' and
    VBRK~fkdat in p_fkdat order by KUNAG.
    *left outer join kna1
    **from S903 INNER JOIN kna1
    *ON VBRKKUNAG = kna1kunnr
    *INTO corresponding fields of TABLE itab
    *where
    *"vbrp~werks in s_werks and
    *VBRK~KUNAG in p_kunag and
    *VBRP~vrkme in s_vrkme and " 'M3' and
    *VBRK~fkdat in p_fkdat order by KUNAG.
    LOOP AT itab.
    mm = itab-fkdat+4(2). " Monthly for Ageing
    clear itab2.
    Read table itab2 with key KUNAG = itab-KUNAG.
    *IF SY-SUBRC EQ 0.                      " Record for Customer exists so modify existing record updating the quantities
         PERFORM itab2_rec USING 'M' mm.
      ELSE.                                  " Record for Cusotmer does not exist so Append a new record for Customer
         PERFORM itab2_rec USING 'A' mm.
      ENDIF.
    itab1-fkdat = itab-fkdat+4(2).
    *itab1-vrkme = itab-vrkme.
    itab1-KUNAG = itab-KUNAG.
    itab1-name1 = itab-name1.
    itab1-fkimg = itab-fkimg.
    APPEND itab1.
    clear itab1.
    ENDLOOP.
    SORT itab1 BY KUNAG fkdat name1.
    "delete adjacent duplicates from itab1.
    LOOP AT itab1.
    move itab1 to wa_itab1.
    AT NEW KUNAG.
    t_s = 0  .
    ENDAT.
    t_s = t_s + itab1-fkimg .
    AT END OF KUNAG.
    mm = itab1-fkdat.
    "break angle.
      IF SY-SUBRC = 0.                     " Record for Customer exists so modify existing record updating the quantities
    CASE mm.
                         " Record for customer does not exit so append a new record for customer
      WHEN '01'.
      itab2-jan = t_s  .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum2 = sum2 + itab2-jan.
      APPEND itab2.
      WHEN '02'.
      itab2-feb = t_s  .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum2 = sum2 + itab2-feb.
      APPEND itab2.
      WHEN '03'.
      itab2-mar = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum3 = sum3 + itab2-mar.
      APPEND itab2.
      WHEN '04'.
      itab2-apr = t_s  .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum4 = sum4 + itab2-apr.
      APPEND itab2.
      WHEN '05'.
      itab2-may = t_s.
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
       sum5 = sum5 + itab2-may.
      APPEND itab2.
      WHEN '06'.
      itab2-jun = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
      sum6 = sum6 + itab2-jun.
      APPEND itab2.
      WHEN '07'.
      itab2-jul = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum7 = sum7 + itab2-jul.
      APPEND itab2.
      WHEN '08'.
      itab2-aug = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
      sum8 = sum8 + itab2-aug.
      APPEND itab2.
      WHEN '09'.
      itab2-sep = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum9 = sum9 + itab2-sep.
      APPEND itab2.
      WHEN '10'.
      itab2-oct = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
        sum10 = sum10 + itab2-oct.
      APPEND itab2.
      WHEN '11'.
      itab2-nov = t_s .
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
      sum11 = sum11 + itab2-nov.
      APPEND itab2.
      WHEN '12'.
      itab2-dec = t_s.
      itab2-KUNAG = wa_itab1-KUNAG.
      itab2-name1 = wa_itab1-name1.
      itab2-total = wa_itab1-total.
      sum12 = sum12 + itab2-dec.
      APPEND itab2.
    itab2-total = itab2-jan + itab2-feb + itab2-mar + itab2-apr + itab2-may + itab2-jun + itab2-jul + itab2-aug + itab2-sep
    + itab2-oct + itab2-nov + itab2-dec .
    total = sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8 + sum9 + sum10 + sum11 + sum12.
    IF MM = 'A'.  " Mode for Append
        APPEND itab2.
    ELSE.             " Mode for Modify
        itab2-KUNAG = itab1-KUNAG.
        itab2-name1 = itab2-name1.
        "MODIFY itab2 WHERE kunag = itab1-kunag.
    ENDIF.
    "loop at itab2  .
    on change of itab2-KUNAG." ,itab2-name1,itab2-jan,itab2-feb,itab2-mar,itab2-apr,itab2-may,itab2-jun,itab2-jul,itab2-aug,itab2-sep,itab2-oct.
              WRITE:/1 SY-VLINE,
                itab2-KUNAG   under   'PARTY' LEFT-JUSTIFIED ,0  SY-VLINE COLOR 2,
                itab2-name1   under     'NAME' LEFT-JUSTIFIED ,10 SY-VLINE,
                itab2-jan DECIMALS 1  under    'JAN' LEFT-JUSTIFIED,40 SY-VLINE,
                itab2-feb DECIMALS 1 under    'FEB' LEFT-JUSTIFIED,50 SY-VLINE,
                itab2-mar DECIMALS 1  under    'MAR' LEFT-JUSTIFIED,60 SY-VLINE,
                itab2-apr DECIMALS 1 under    'APR' LEFT-JUSTIFIED,70 SY-VLINE,
                itab2-may DECIMALS 1 under    'MAY' LEFT-JUSTIFIED,80 SY-VLINE,
                itab2-jun DECIMALS 1 under    'JUN' LEFT-JUSTIFIED,90 SY-VLINE,
                itab2-jul DECIMALS 1 under    'JUL' LEFT-JUSTIFIED,100 SY-VLINE,
                itab2-aug DECIMALS 1 under    'AUG' LEFT-JUSTIFIED,110 SY-VLINE,
                itab2-sep DECIMALS 1 under    'SEP' LEFT-JUSTIFIED,120 SY-VLINE,
                itab2-oct DECIMALS 1 under    'OCT' LEFT-JUSTIFIED,130 SY-VLINE,
                itab2-nov DECIMALS 1 under    'NOV' LEFT-JUSTIFIED,140 SY-VLINE,
                itab2-dec DECIMALS 1 under    'DEC' LEFT-JUSTIFIED,150 SY-VLINE,
                itab2-Total DECIMALS 1 under  'TOTAL' LEFT-JUSTIFIED,160 SY-VLINE COLOR 3,
                170 SY-VLINE COLOR 3.
                uline.
      "itab2-total = itab2-jan +value itab2-febitab3-maritab2-apritab2-mayitab2-junitab3-julitab2-augitab2-sepitab2-octitab3-nov+itab2-dec).
    "itab2-total = sum(itab2-jan)  .
    endon.
    "endloop.
    ENDCASE.
    ENDIF.
    "ENDFORM.
    ENDAT.
    ENDLOOP.
    ENDCASE.
    write:  sum1 DECIMALS 1  under    'JAN' LEFT-JUSTIFIED,40 SY-VLINE,
             sum2 DECIMALS 1 under    'FEB' LEFT-JUSTIFIED,50 SY-VLINE,
             sum3 DECIMALS 1  under    'MAR' LEFT-JUSTIFIED,60 SY-VLINE,
             sum4 DECIMALS 1 under    'APR' LEFT-JUSTIFIED,70 SY-VLINE,
             sum5  DECIMALS 1 under    'MAY' LEFT-JUSTIFIED,80 SY-VLINE,
             sum6 DECIMALS 1 under    'JUN' LEFT-JUSTIFIED,90 SY-VLINE,
             sum7 DECIMALS 1 under    'JUL' LEFT-JUSTIFIED,100 SY-VLINE,
             sum8 DECIMALS 1 under    'AUG' LEFT-JUSTIFIED,110 SY-VLINE,
             sum9 DECIMALS 1 under    'SEP' LEFT-JUSTIFIED,120 SY-VLINE,
             sum10 DECIMALS 1 under    'OCT' LEFT-JUSTIFIED,130 SY-VLINE,
             sum11 DECIMALS 1 under    'NOV' LEFT-JUSTIFIED,140 SY-VLINE,
             sum12 DECIMALS 1 under    'DEC' LEFT-JUSTIFIED,150 SY-VLINE,
             sum13 DECIMALS 1 under  'TOTAL' LEFT-JUSTIFIED,160 SY-VLINE COLOR 1.
    uline.
    regards
    Piroz

Maybe you are looking for

  • There is no sound in my laptop after the update. hp envy m6

    I updated my laptop with hp update and after that there is no sound in laptop. if i play something online only then i get the sound else whatever files or movies or music i have in my laptop there is no sound.  I use envy series.. windows 8.. i5 proc

  • Export to Microsoft Excel

    When we right click on an HTML page, we see an option "Export to Microsoft Excel", is there a way in java whereby i can invoke that option. For example i want a certain HTML page to be exported to an excel, i guess easiest option would be to have a b

  • Active Content - Flash - fix for Contribute Users

    Greetings, I have a group of users that use Contribute. Many of these users create Flash Paper forms and embed them in a standard template. These individuals do not work with HTML or JavaScript. Recently a security patch for IE has been applied to th

  • DW CS3 crashes on Mac Leopard

    Hi, I got used to the lame Fireworks CS3 version on the Mac but now am getting totally pissed with DW CS3. it keeps on crashing specifically when I return to it after doing something else for example working on Photoshop. it seems like this happens w

  • 4 libraries on 1 iMac HDD fallin' apart

    Hi There! I have an iMac 2.1 Ghz PowerPc G5 with 2.5GB in RAM and running OS X 10.4.11 I've created (since I bought it) 2 users (for my wife and myself) and we have Aperture and iPhoto libraries for each user. What would be the best way to consolidat