LINQ Group and Sum table

I can't figure how to group those records 
EmpID
ClientId
HourIn
   HourOut
        Date
TotalHours
12345
9999
8:00 AM
12:00 PM
01/05/2015
4
12345
9999
1:00 PM
3:00 PM
01/05/2015
2
12345
9999
3:30 PM
6:00 PM
01/05/2015
2.5
12345
9999
8:00 AM
5:00 PM
01/06/2015
9
12345
9999
8:00 AM
5:00 PM
01/07/2015
9
12345
9999
8:00 AM
5:00 PM
01/08/2015
9
12345
9999
8:00 AM
5:00 PM
01/09/2015
9
I want to group by date and sum total hours and hourin in the first and hour out is the last one. 
FYI (date can be datetime) (eg i can make date to be (1/18/2014 12:00:00 AM)
EmpID
ClientId
HourIn
HourOut
Date
TotalHours
12345
9999
8:00 AM
6:00 PM
01/05/2015
8.5
12345
9999
8:00 AM
5:00 PM
01/06/2015
9
12345
9999
8:00 AM
5:00 PM
01/07/2015
9
12345
9999
8:00 AM
5:00 PM
01/08/2015
9
12345
9999
8:00 AM
5:00 PM
01/09/2015
9
Thanks in advance

Hope this helps..do a group by and then select ..change the below accordingly
DataTable objtable = new DataTable();
objtable.Columns.Add("EmpID", typeof(int)); objtable.Columns.Add("ClientId", typeof(int));
objtable.Columns.Add("HourIn", typeof(DateTime)); objtable.Columns.Add("HourOut", typeof(DateTime));
objtable.Columns.Add("Date", typeof(DateTime)); objtable.Columns.Add("TotalHours", typeof(double));
objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/05/2015 8:00 AM"), Convert.ToDateTime("01/05/2015 12:00 PM"), Convert.ToDateTime("01/05/2015"), 4);
objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/05/2015 1:00 PM"), Convert.ToDateTime("01/05/2015 3:00 PM"), Convert.ToDateTime("01/05/2015"), 2);
objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/05/2015 3:30 PM"), Convert.ToDateTime("01/05/2015 6:00 PM"), Convert.ToDateTime("01/05/2015"), 2.5);
objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/06/2015 8:00 AM"), Convert.ToDateTime("01/06/2015 5:00 PM"), Convert.ToDateTime("01/06/2015"), 9);
objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/07/2015 8:00 AM"), Convert.ToDateTime("01/07/2015 5:00 PM"), Convert.ToDateTime("01/07/2015"), 9);
objtable.Rows.Add(12345, 9999, Convert.ToDateTime("01/08/2015 8:00 AM"), Convert.ToDateTime("01/08/2015 5:00 PM"), Convert.ToDateTime("01/08/2015"), 9);
objtable.AcceptChanges();
var result = objtable.AsEnumerable().GroupBy(x => x.Field<DateTime>("Date")).Select(g => new
empId = g.First().Field<int>("EmpID"),
clientID = g.First().Field<int>("ClientId"),
hoursIn = g.Min(e => e.Field<DateTime>("HourIn")),
hourOut = g.Max(e => e.Field<DateTime>("HourOut")),
totalhours = g.First().Field<double>("TotalHours")
foreach (var row in result)
Console.WriteLine("{0} {1} {2} {3} {4} ", row.empId,row.clientID, row.hoursIn.ToString("HH:mm tt"), row.hourOut.ToString("HH:mm tt"),row.totalhours);

Similar Messages

  • Sql grouping and summing impossible?

    I want to create an sql query to sum up some data but i'm starting to think it is impossible with sql alone. The data i have are of the following form :
    TRAN_DT     TRAN_RS     DEBT     CRED
    10-Jan     701     100     0
    20-Jan     701     150     0
    21-Jan     701     250     0
    22-Jan     705     0     500
    23-Jan     571     100     0
    24-Jan     571     50     0
    25-Jan     701     50     0
    26-Jan     701     20     0
    27-Jan     705     0     300The data are ordered by TRAN_DT and then by TRAN_RS. Tha grouping and summing of data based on tran_rs but only when it changes. So in the table above i do not want to see all 3 first recods but only one with value DEBT the sum of those 3 i.e. 100+150+250=500. So the above table after grouping would be like the one below:
    TRAN_DT     TRAN_RS     DEBT     CRED
    21-Jan     701     500     0
    22-Jan     705     0     500
    24-Jan     571     150     0
    26-Jan     701     70     0
    27-Jan     705     0     300The TRAN_DT is the last value of the summed records. I undestand that the tran_dt may not be selectable. What i have tried so far is the following query:
    select tran_dt,
             tran_rs,
             sum(debt)over(partition by tran_rs order by tran_dt rows unbounded preceding),
             sum(cred)over(partition by tran_rs order by tran_dt rows unbounded preceding) from that_tableIs this even possible with sql alone, any thoughts?
    The report i am trying to create in BI Publisher.Maybe it is possible to group the data in the template and ask my question there?

    915218 wrote:
    Is this even possible with sql alone, any thoughts?It sure is...
    WITH that_table as (select to_date('10/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 100 debt, 0 cred from dual union all
                         select to_date('20/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 150 debt, 0 cred from dual union all
                         select to_date('21/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 250 debt, 0 cred from dual union all
                         select to_date('22/01/2012', 'dd/mm/yyyy') tran_dt, 705 tran_rs, 0 debt, 500 cred from dual union all
                         select to_date('23/01/2012', 'dd/mm/yyyy') tran_dt, 571 tran_rs, 100 debt, 0 cred from dual union all
                         select to_date('24/01/2012', 'dd/mm/yyyy') tran_dt, 571 tran_rs, 50 debt, 0 cred from dual union all
                         select to_date('25/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 50 debt, 0 cred from dual union all
                         select to_date('26/01/2012', 'dd/mm/yyyy') tran_dt, 701 tran_rs, 20 debt, 0 cred from dual union all
                         select to_date('27/01/2012', 'dd/mm/yyyy') tran_dt, 705 tran_rs, 0 debt, 300 cred from dual)
    , brk AS (
    SELECT     tran_dt,
            tran_rs,
         debt,
         cred,
            CASE WHEN Nvl (Lag (tran_rs) OVER (ORDER BY tran_dt, tran_rs), 0) != tran_rs THEN tran_rs || tran_dt END brk_tran_rs
      FROM that_table
    ), grp AS (
    SELECT     tran_dt,
            tran_rs,
             debt,
             cred,
            Last_Value (brk_tran_rs IGNORE NULLS) OVER  (ORDER BY tran_dt, tran_rs) grp_tran_rs
      FROM brk
    SELECT     Max (tran_dt),
            Max (tran_rs),
             Sum (debt),
             Sum (cred)
      FROM grp
    GROUP BY grp_tran_rs
    ORDER BY 1, 2
    Boneist
    MAX(TRAN_    TRAN_RS       DEBT       CRED
    21-JAN-12        701        500          0
    22-JAN-12        705          0        500
    24-JAN-12        571        150          0
    26-JAN-12        701         70          0
    27-JAN-12        705          0        300
    Me
    MAX(TRAN_ MAX(TRAN_RS)  SUM(DEBT)  SUM(CRED)
    21-JAN-12          701        500          0
    22-JAN-12          705          0        500
    24-JAN-12          571        150          0
    26-JAN-12          701         70          0
    27-JAN-12          705          0        300Edited by: BrendanP on 17-Feb-2012 04:05
    Test data courtesy of Boneist, and fixed bug.
    Edited by: BrendanP on 17-Feb-2012 04:29

  • Difference between the Field Group  and Internal Table.

    Hi all,
    Can anybody tell me the difference between the Field group and Internal table and when they will used?
    Thanks,
    Sriram.

    Hi
    Internal Tables: They are used to store record type data in tabular form temporarily in ABAP programming. Or we can say, it stores multiple lines of records for temporary use in ABAP programming.
    A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
    Use
    The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
    When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
    Regards
    Ashish

  • Select query with group and sum

    Friends I have a table which has a list of item that are sold in many provinces and their selling price.
    EMP_TABLE
    item_code
    item_desc
    item_province
    item_selling_price
    Now I want a query which a row containing
    distinct item code ,item desc,province ,sum of item_selling_price for Ontario,sum of item_selling_price for British Columbia,sum of item_selling_price for Quebec
    Can anyone please tell me how to do it.
    thx
    m

    Hello
    It's always usefull to provide some test data and create table scripts etc, but does this do what you're after?
    create table dt_test_t1
    (item_code                     varchar2(3),
    item_desc                    varchar2(10),
    item_province               varchar2(20),
    item_selling_price          number(3)
    ) tablespace av_datas;
    INSERT INTO dt_test_t1 VALUES('ABC','Item1','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item1','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item1','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item2','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item2','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item2','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item3','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item3','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item3','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item4','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item4','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item4','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item5','Province2',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item5','Province1',10);
    INSERT INTO dt_test_t1 VALUES('ABC','Item5','Province2',10);
    SQL> SELECT
      2     item_code,
      3     item_desc,
      4     SUM(DECODE(item_province,'Province1',item_selling_price,0)) province_1_total,
      5     SUM(DECODE(item_province,'Province2',item_selling_price,0)) province_2_total
      6  FROM
      7     dt_test_t1
      8  GROUP BY
      9     item_code,
    10     item_desc;
    ITE ITEM_DESC  PROVINCE_1_TOTAL PROVINCE_2_TOTAL
    ABC Item1                    10               20
    ABC Item2                    30                0
    ABC Item3                     0               30
    ABC Item4                    20               10
    ABC Item5                    10               20HTH
    David

  • Grouping and sum values in XI

    Hello,
    I 'm working with invoice and I have this source structure as XI input:
    Invoice
    -- |....
    -- |....
    -- |Item1
    |taxcode=01
    |Amount=12
    --|Item2
    |taxcode=08
    |Amount=10
    --|Item3
    |taxcode=01
    |Amount=24
    Now my scope is to map these fields to the IDOC segment E1EDP04 grouping by taxcode (MWSKZ taxcode)and putting the sum of the group amount (MWSBT amount).
    IDOC:
    --|...
    --|...
    --|E1EDP01
    |...
    |...
    |EIEDP04
    |MWSKZ=01
    |MWSBT=36
    |...
    --|E1EDP01
    |...
    |...
    |EIEDP04
    |MWSKZ=08
    |MWSBT=10
    |...
    How can I group by a field in XI?
    Thank you
    Corrado

    Hi Corrado,
    If You want to do it in graphical mapping then I will do it this way:
    1. sort by taxcode
    (taxcode) --> split by value (valuechanged) --> formatByExample (Amount, and splitted value) --> sum(amount) --> MWSBT
    I can send u a screenshot of something similar if u need.
    best regards
    Dawid

  • Group and Sum in Webi

    Hi,
    I have three objects Business Unit, Department and Revenue
    I would like to group by Business Unit and Departement; sum of Revenue.
    How to do this in report level?
    Please let me know?
    Thanks and Regards,
    Manjunath N Jogin

    Hi Pumpactionshotgun ,
    I did same thing in webi but revenue field is diplaying all records.
    It is not aggreagting (sum) based on Business Unit and Departement.
    How to  do 'aggregation seting for Revenue in the universe'
    I am waiting your replay.
    Thanks and Regards,
    Manjunath N Jogin

  • Expression Grouping and Summing

    I am working on a report where I have an expression that gets the Max value of a field in the detail row of my report.  I have four levels of grouping that I then need this expression to sum.  The expression is: 
    =Max(IIF(LEFT(Fields!JobNum.Value,1)="S" AND Fields!Week1STol.Value<>0, CDBL(Fields!Week1STol.Value), 0))
    I am using Max, because I need a value from a result set that is one of the non-zero values from the result set.  They will all be the same, or 0, so if there is a different way to get the non-zero value without using an aggregate I can change my expression
    to do that, but I have not found a way to do that yet.  Now since I am grouping this, and as each group rolls up I need the sum of the max values in the subgroup.  When I get is the Max value of the new group.
    I have tried various ways to try and get this to sum.  I have tried creating total rows, added custom code to collect running totals, etc., I have also tried wrapping the whole thing in a SUM aggregate, and that will work in the detail, but will not
    roll up into the groupings.
    Any help as to how this can be done will be greatly appreciated.
    Thank you,
    Chad 

    Ok, after continuing to search the internet I finally found the extra piece that I was missing that gave me the results I needed. The new expression looks like this:
    =runningvalue(Sum(Max(IIF(LEFT(Fields!JobNum.Value,1)="S" AND Fields!Week1STol.Value<>0, CDBL(Fields!Week1STol.Value), 0),"JobItem"),"JobItem"),SUM, "JobItem")
    In this I wrapped the original expression of Max in both a Sum and a runningvalue both at the JobItem level to get this rollup value. Now when I open the grouping I get the correct running value at each level.
    What this really gives to me is a running total at each of four groupings, even with a "max" value at the detail level. This also allows me to total a max value inline on the report, without needing a hidden row, or report footer.
    Thank you to everyone who looked at this, I hope it helps someone else. If this answer is not clear enough, please don't hesitate to add to the comments and I will try to clarify.
    Thank you, Chad

  • How to Group and Sum rtf elements

    Dear Friends,
    I am having limited knowledge of XML so looking for your help
    I am trying to create external template for Bill Presentment Architecture which is in .rtf. Template is having 3 section Invoice header, Lines and Tax summary.
    Invoice Header and line section is ok, but facing some issues with Tax section.
    LINE SECTION
    LINE_ID     ITEM     RATE     QTY     BASE_AMT     TAX_RATE     TAX_AMT     TOTAL_AMT
    1     P0001     20     10     200     21%     42     242
    3     P0003     40     30     1200     21%     252     1452
    4     P0004     20     100     2000     10%     420     2200
    5     P0005     50     10     500     10%     105     550
    2     P0002     50     20     1000     6%     210     1060
    EXPECTED RESULT IN TAX SUMMARY SECTION WHICH I AM LOOKING FOR
    TAX RATE           BASE_AMT          TAX_AMT          TOTAL_AMT
    21%          1400          294          1694
    10%          2500          525          2750
    6%          1000          210          1060
    Looking for your help, much appriciated.
    Regards,
    Jay
    Edited by: 992820 on Mar 9, 2013 5:20 AM

    >
    Tax Code Taxable amount
    VAT 6% 1200
    VAT 6% 1400
    VAT 7% 1000
    VAT 7% 2000
    I used you code
    <?for-each-group:LINE;./tax_code?> G tag
    and getting following result
    VAT 6% 1200
    VAT 7% 1000
    >
    because you have loop by tax_code and no loop and no aggregation function (e.g. sum) for amount, so amount will be from first row
    try add sum function for amount
    also http://docs.oracle.com/cd/E18727_01/doc.121/e13532/T429876T431325.htm#I_bx2Dcontent
    Summary Lines: Check this box if you want to display summarized transaction lines. Grouped lines are presented in the Lines and Tax area of the primary bill page.so it's may be not template problem but some settings?

  • Group and Sum/Average

    Hello.
    I have an excel structure here, this data is extracted from our company's software. The record was recorded from Dec 5, 2013 to Dec 11, 2013 
    Job   Operator
    Added
    Job Opened
    Job Revenue Recognition Date
    Shipment ID
    Joebeth Cañete
    05-Dec-13
    19-Dec-13
    IMM
    S00038408
    Joebeth Cañete
    05-Dec-13
    19-Dec-13
    IMM
    S00038412
    Joebeth Cañete
    05-Dec-13
    19-Dec-13
    IMM
    S00038414
    Joebeth Cañete
    05-Dec-13
    10-Dec-13
    IMM
    S00038440
    Sharlah Faye Solomon
    09-Dec-13
    09-Dec-13
    IMM
    S00038501
    Rachel Rosales
    09-Dec-13
    09-Dec-13
    IMM
    S00038502
    Sharlah Faye Solomon
    09-Dec-13
    09-Dec-13
    IMM
    S00038503
    Sharlah Faye Solomon
    09-Dec-13
    09-Dec-13
    IMM
    S00038504
    Sharlah Faye Solomon
    09-Dec-13
    09-Dec-13
    IMM
    S00038506
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038508
    May Jane Herrera
    09-Dec-13
    09-Dec-13
    IMM
    S00038509
    Joebeth Cañete
    09-Dec-13
    17-Dec-13
    IMM
    S00038510
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038512
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038513
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038514
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038515
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038516
    Sheena Dagandan
    09-Dec-13
    09-Dec-13
    IMM
    S00038518
    Joebeth Cañete
    10-Dec-13
    10-Dec-13
    IMM
    S00038523
    Sharlah Faye Solomon
    10-Dec-13
    10-Dec-13
    IMM
    S00038524
    May Jane Herrera
    10-Dec-13
    10-Dec-13
    IMM
    S00038525
    May Jane Herrera
    10-Dec-13
    10-Dec-13
    IMM
    S00038526
    Rachel Rosales
    10-Dec-13
    10-Dec-13
    IMM
    S00038528
    May Jane Herrera
    10-Dec-13
    10-Dec-13
    IMM
    S00038530
    May Jane Herrera
    10-Dec-13
    10-Dec-13
    IMM
    S00038531
    May Jane Herrera
    10-Dec-13
    10-Dec-13
    IMM
    S00038532
    Joebeth Cañete
    10-Dec-13
    10-Dec-13
    IMM
    S00038533
    Rachel Rosales
    10-Dec-13
    10-Dec-13
    IMM
    S00038534
    Sharlah Faye Solomon
    11-Dec-13
    11-Dec-13
    IMM
    S00038541
    Sharlah Faye Solomon
    11-Dec-13
    11-Dec-13
    IMM
    S00038542
    Sharlah Faye Solomon
    11-Dec-13
    11-Dec-13
    IMM
    S00038543
    Sharlah Faye Solomon
    11-Dec-13
    11-Dec-13
    IMM
    S00038544
    May Jane Herrera
    11-Dec-13
    11-Dec-13
    IMM
    S00038548
    May Jane Herrera
    11-Dec-13
    11-Dec-13
    IMM
    S00038549
    Rachel Rosales
    11-Dec-13
    11-Dec-13
    IMM
    S00038554
    Rachel Rosales
    11-Dec-13
    11-Dec-13
    IMM
    S00038555
    Rachel Rosales
    11-Dec-13
    11-Dec-13
    IMM
    S00038557
    Rachel Rosales
    11-Dec-13
    11-Dec-13
    IMM
    S00038558
    Now, my boss wants to have a matrix like this.
    Job Operator      Added      Job Opened        Shipment ID
    Employee A
    Total for (n) weeks [of Employee A]
    Average Shipment Daily: 
    Average Shipment Weekly:
    Employee B
    Total for (n) weeks [of Employee B]
    Average Shipment Daily: 
    Average Shipment Weekly:
    Inshort, he wants to group the records by Job Operator and get the average number of shipments daily and weekly. Is it possible to do this job?

    What' the define of the 'Week' you mentioned?
    It would be benefit for us to find the solution if you can provide the output you want.
    E.g..
    Job     Operator
    Total   for (n) weeks 
    Average   Shipment Daily
    Average Shipment Weekly
    Joebeth Cañete
    2
    1
    3.5
    But in any case, you can try to create a pivot table to analyze the data. 

  • Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount 28

    Post Author: tadj188#
    CA Forum: Formula
    Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
    Background:
    1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using  subreports.    A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report    with their respective detail lines).  I had multiple subreports and each subreport became one union.
    Created and tested, already:
    1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
    Issue:
    1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
    Other Ideas Appreciated:
    1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
    Thank you.
    Tadj

    export all image of each page try like this
    var myDoc = app.activeDocument;
    var myFolder = myDoc.filePath;
    var myImage = myDoc.allGraphics;
    for (var i=0; myImage.length>i; i++){
        app.select(myImage[i]);
        var MyImageNmae  = myImage[i].itemLink.name;
        app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
        app.jpegExportPreferences.exportResolution = 300;
           app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
        alert(myImage[i].itemLink.name)

  • "How to sum FKIMG in VBRK and VBRP Table with sample output

    Sir\Mam\Gurus ;
    I hardly found it difficult in resolving my program in getting the sum of FKIMG inside the VBRP and VBRK tables
    The scenario is that i have one Sales Order with multiple invoices . What i need to do is to sum up the fkimg or the quanitity of specific material regardless of how many invoices the material have in a particular SO
    Example I have Sales Order number 35678952 with
    3 invoices
    Invoice # 123 with material number mat1=12, mat2=5 , mat3=7
    345 with material number mat1=7, mat2=7
    678 with material number mat1=5, mat3=10
    Output shoud be
    salesorder# 35678952
    mat1 = 24
    mat2 = 12
    mat3 = 17
    Below is my Sample Codes:
    DATA : it_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    ls_vbrp_details TYPE wa_vbrp_details,
    ls_vbrp_details1 TYPE wa_vbrp_details,
    lsfinal_vbrp_details TYPE wa_vbrp_details,
    it2_vbrp_details TYPE STANDARD TABLE OF wa2_vbrp_details,
    ls2_vbrp_details TYPE wa2_vbrp_details,
    it3_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    itfinal1_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    itfinal2_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    itfinal3_vbrp_details TYPE STANDARD TABLE OF wa_vbrp_details,
    ls3_vbrp_details TYPE wa_vbrp_details,
    rtime1 TYPE i,
    rtime2 TYPE i,
    rtime3 TYPE i,
    s_erdate type d,
    scr_erdat type d,
    s_erdate = scr_erdat.
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
    EXPORTING
    months = 1 " Negative to subtract from old date, positive to add
    olddate = s_erdate
    IMPORTING
    newdate = new_date.
    """ This is another way manual adding by days
    CALL FUNCTION 'CALCULATE_DATE'
    EXPORTING
    days = +30
    start_date = s_erdate
    IMPORTING
    result_date = new_date.
    result_date = ddate.
    REFRESH: it_vbrp_details.
    SELECT
    vbrp~matnr
    vbrp~aubel
    vbrp~aupos
    vbrp~vbeln
    vbrp~kzwi1
    vbrp~kzwi2
    vbrp~kzwi3
    vbrp~kzwi4
    vbrp~kzwi5
    vbrp~kzwi6
    vbrp~mvgr1
    vbrp~mvgr2
    vbrp~mvgr3
    vbrp~mvgr4
    vbrp~mvgr5
    vbrp~knuma_pi
    vbrp~knuma_ag
    vbrp~mwsbp
    vbrp~vkaus
    vbrp~fkimg
    vbrk~vbeln
    vbrk~fkart
    vbrk~belnr
    vbrk~xblnr
    vbrk~vbtyp
    vbrk~kunag
    vbrk~fksto
    vbap~posnr
    INTO TABLE it_vbrp_details
    FROM vbrp INNER JOIN vbrk ON vbrkvbeln EQ vbrpvbeln
    where vbeln eq gt_data-vbeln
    where vbrpaubel eq vbapvbeln
    WHERE vbrp~posnr GE ''
    AND vbrk~vbtyp EQ 'M'
    AND vbrk~fksto NE 'X'
    AND ( vbrperdat GE s_erdate OR vbrperdat LE new_date OR vbrp~erdat IN s_erdat ) " + JP 09 19 2011 Additional Optimization
    ORDER BY aubel aupos .
    ORDER BY aubel aupos matnr.
    """" This where i need your help Sir\Mam\Gurus
    it3_vbrp_details = it_vbrp_details.
    SORT it3_vbrp_details BY aubel matnr fkimg kzwi1 kzwi2 kzwi3 kzwi4 kzwi5 kzwi6 aupos vbeln
    mvgr1 mvgr2 mvgr3 mvgr4 mvgr5 knuma_pi knuma_ag mwsbp vkaus fkart belnr vbtyp kunag fksto.
    LOOP AT it3_vbrp_details INTO ls_vbrp_details.
    COLLECT ls_vbrp_details INTO itfinal1_vbrp_details.
    APPEND ls_vbrp_details TO it_vbrp_details.
    ENDLOOP.
    kzwi1,kzwi2,kzwi3 is also been sum up
    Sir the output is something like this
    Sales Ord# Material Qty KWIZ1 KWIZ2 KWIZ3 MGVR1 VBELN
    1234       Mat1     24  23.2  22    12           LastInvoice#
    1234       Mat2     12  20.0  21    15           LastInvoice#  
    1234       Mat3     37  22.0  22    16           LastInvoice#
    5432       Mat1     30  25.0  23    15           LastInvoice#
    5432       Mat2     24  22.0  24    23           LastInvoice#
    5432       Mat3     20  18.0  20    12           LastInvoice#
    Hope you can help me as i cant hardy sleep thinking of this ...
    I will really appreciate your great help..
    Thanks !
    I will really appreciate your great help..
    Thanks !
    Moderator message: duplicate post locked.
    Edited by: Thomas Zloch on Sep 20, 2011 3:05 PM

    Hi,
      How you want to display the output?..
    If you want to display the output as mentioned below, then you have to use nested loop & dynamic field assignments to get result.
    Output column
    sales order     Mat1 Mat2 Mat3 ......
    1234               24    12     37
    Kindly let me know, if you have any questions
    Regards,
    S.Senthilkumar

  • Group and table visibility

    Hello Friends,
    I am facing a problem as follows:
    In an existing application I am trying to modify some code: there is a group which contains two tables the visibility of both tables are set to context element node also called visibility: and its elements table_1 is set to visibility property of first table and table_2 value attribute is set to visibility property of the second table.
    Now from the coading as far as I understood it is as follows:
    When the first table is set to NONE the second table is automatially visible and first table is disappered, and as soon as in coading it makes the first table visible the second table is automatically disappred ?
    Can any one pls help me in understanding how/what is going on ?
    Because the issue is I have to place now a third table and when this table is visible then the other two tables should not be visible, .......
    Regards

    Hi,
    In the wdDoModifyView:- Now put the if condition for tables that if one is VISIBLE then other two should be set as NONE.
    Regards,
    Praveen

  • Table name for Customer Account Group and created by Data

    Dear Gurus,
    Kindly le t me know the table name having a list of Customer a/c groups and created by data. if there is no such table thn pls let me know the alternatives for fetching the same data.
    Wishes
    Abhishek

    hI
    Go to Se11 and give table name KNA1 and go to display
    you can able to see the Customer AccountGroup field :KTOKD
    Thanks
    Vasu

  • Table name for Internal order group and Profit center group

    Hello Friends,
    Could any one provide me the table for Internal order group and Profit center group.
    We are developing new customized report and user requested internal order group and Profit center group in the selection criteria.
    I have checked for this tables but found only these fields in structures.
    Thanks in advance,
    Ravi Kiran.

    Or use FM [G_SET_TREE_IMPORT|http://www.sdn.sap.com/irj/scn/advancedsearch?query=g_set_tree_import] to read the hierarchy/Group. (Read FM and FG documentation, you can also add break-point and call some S_ALRxxx transaction which use this FM for the objects you need).
    Regards,
    Raymond

  • Material Group Difference MM03  (Table MARA) and Reservation (Table RESB)

    Why material group at T-code MM03 (MARA-MATKL) difference at Table RESB ?
            Table MARA-MATKL = 04
            Table RESB-MATKL = 02
    I checking  MM03 not change about material group. I don't know some T-code can change material group link to table RESB.

    Dear Mr.Jutamas,
    As per to my understanding,initially when the reservation was made for the
    particular material ,material group - 02 in Basic Data 1 view  would have been
    present or maintained in the material master.
    After that a change might have occured,i.e someone must have changed the
    material group from 02 to 04.
    So in MARA table the value is showing as 04 and in RESB its showing as 04.
    Once after creating reservation ,if such changes are made,as far as i know that
    will not get updated or reflected in RESB.
    Better confirm the same,in MM03 - Display mode of the material and after going
    into any one of the view,in the top menu check Environment - Display Changes -
    you may get one or a list of changes that were made,along with the user,date &
    time details.
    <b>If useful reward points</b>
    Regards
    Mangal

Maybe you are looking for

  • When releasing a transp. req.not all object in the request could  be locked

    When trying to release a transport request I get error message that "not all object in the request could  be locked. Do you want to release them anyway" I found an unreleased request (from someone else) containing few objects from my request. However

  • How do I stop pdf viewer from printing 4 pages per page?

    When I print a file off pdf viewer in firefox, my printout comes out 4 pages per page, even though I check advanced settings and verify that it is set to 1 page per page. I do not know where else I can look to correct this problem.

  • Revert display driver on Mac Mini

    I made a mistake and installed a display driver on my Mac Mini, now I can't run iMovie because it requires a graphics adapter that supports Quartz Extreme.  How can I revert back to the original driver? Billy

  • BEX WAD 7.0:  Chart Takes Long Time to Display in Portal - Query runs FAST

    I have a BEx WAD 7.0 template which contains 3 column charts (each with it's own seperate DataProvider/Query).  When the page loads...two of the charts show up right away, but one of them takes almost a minute to display on the screen (I thought it w

  • Dimensions & Cubes in OWB

    I was just involved in the project of data warehouse using OWB-OBIEE, though in general I was often involved in data warehouse projects over the last few years. And, I am also new in this forum. I have several questions related to development using t