Sub totals and Totals

I am developing a query using SQVI.
How do I insert subtotals and totals for certain fields at the end of the query report.
Thanks
Sandeep

hI SANDEEP  .....
if you  go with  layou mode   then    there will be   3  pops  like   delete  ,  TOOL BAR  , SORT FIELDS ....etc ..
there is  TOOL BAR   with the following  options   ...
Background
Heading
Normal
<b>Subtotals</b>
Key Columns
Positive
Negative
Control Levels
Background (intensified
Header (intensified)
Normal (intensified)
Sum totals (intensified
Keys (intensified)
Positive (intensified)
Negative (intensified)
Control lev.(intensifie
so  that  by selecting the  fields   .....  liek sub total   acrros the  Fiscal  year  can be done  ....  Document wise   sub total  ..... vendor wise   , customer wise  ... like  based  on the fields   selection for sub total  and   total can  be  done ...
Girish

Similar Messages

  • Interactive Report Sub-total and total

    Hi friends,
    I have an employee interactive report with group by job name and also showing the salary sub-total for each and every job(group by).
    I have an requirement like to highlight the sub-total for each and every job with a background color so that the user can identify the sub-total with the color, and also whether it is possible to display an overall total @ last in the report with a label named "Total Salary" in which it calculates the overall salary is also to be highlightened with the background color.
    Also is it possible to display a text "Sub-total" besides each and every salary sub-total  of job(group by). Currently if we display a sum for the salary then im getting the total's but with out a text named total.
    Since i can see the highlighted feature in interactive report but im not sure how to apply it for the sub-total and total column.
    I have reproduced the example in apex.oracle.com
    http://apex.oracle.com/pls/apex/f?p=4550:1:0:::::
    In the application 9494 named "test" in page1.
    Thanks in advance.
    Brgds,
    Mini

    Hi, Mini,
    style=background-color:red;
    But that Total region color dint change.The code for style should be in "Form HTML Element Attributes". However, this changes the background color only for the Total value not for the whole row.
    If you want to change for the whole row, you need to change the template that is selected for the region.
    I changed the region template in your application to "Borderless Region" and made the changes to the "Borderless Region" template, it now shows the background color for Total Value.
    <table class="t20Region t20Borderless #REGION_CSS_CLASSES#" id="#REGION_STATIC_ID#" border="0" cellpadding="0" cellspacing="0" summary="" #REGION_ATTRIBUTES#>
    <thead><tr><th class="t20RegionHeader" id="#REGION_STATIC_ID#_header">#TITLE#</th></tr></thead>
    <tbody id="#REGION_STATIC_ID#_body">
    <tr><td class="t20ButtonHolder">#CLOSE##PREVIOUS##NEXT##DELETE##EDIT##CHANGE##CREATE##CREATE2##EXPAND##COPY##HELP#</td></tr>
    <tr><td class="t20RegionBody" style="background-color:orange">#BODY#</td></tr>
    </tbody>
    </table>The below does the trick. :)
    <tr><td class="t20RegionBody" style="background-color:orange">#BODY#</td></tr>Note: I made the changes to "Borderless Template", but you can copy the template to your own and apply this change.
    Regards,
    Natarajan

  • Sub-total and Total for a column having checkboxes in WD ABAP ALV

    Hello Experts,
    I have used ALV in We bdynpro ABAP to display my output. There are 2 columns that are checkboxes in Output. I want a sub-total and total for those two columns. I know tht total and sub-total functionality is available only for numeric fields .
    Is there any other indirect way by which i can achieve the same ?

    Hi Ragini,
    Please refer this thread: [alv total and subtotal|How to display graphs;.
    I hope it helps.
    Regards
    Arjun

  • Sub-totals and Totals calculations....?

    How to Calculate the Sub-totals and Grand totals in ABAP Programs.

    Hi Bhaskar,
    In my opinion this can be acheived in two ways:
    1. Using ALV GRID DISPLAY
    2. Using AT NEW  , ON CHANGE OF  , etc events.
    1. In the ALV field catalogue u create entries for all the fileds to b
    displayed in the output list.
    Here, we need to put DO_SUM = 'X' .
    eg
      ****************fieldcatalog*********************
    data:anytab type slis_t_fieldcat_alv with header line.
    **************pgm name**********************
    data:anypgnm type sy-repid.
    **************events*************************
    anytab-fieldname   = 'MATNR'.
      anytab-seltext_m   = 'Material Number'.
      anytab-col_pos     = 0.
      anytab-outputlen   = 20.
      anytab-emphasize   = 'X'.
      anytab-do_sum = 'X' .                  <----
    here it is.
      append anytab to anytab .
      clear  anytab .
    Now wen u call the fm REUSE_ALV_GRID_DISPLAY , plz pass anytab ie fieldcatalog  and  the tabel with records to  b displayed .
    this would  sum the fields at the end.
    2.  Alternately ....for SUb-totals ;
       Sort itab in an ascending manner.
    Data : wa_itab    like line of itab,
              wa_subtotal type i.
    " fieldname1 in itab is the key field
    " fieldname2 is the value field
    LOOP at itab into wa_itab .
      wa_subtotal = wa-subtotal  + itab-<fieldname2>.
      AT END OF <fieldname1> .
          " your programming logic for subtotal
           Write :/ wa_itab-fieldname1 , wa_subtotal.
           Clear  wa_subtotal.
       ENDAT.
       " write :/  ....if u need to write any lofgic values ....
    ENDLOOP .
    Note : plz sc if a field in itab that is left of fieldname1 changes
              the AT END OF event is triggered.
             Therefoe , see that  pur key fields towards left in itab.
    FYI : u can try ON CHANGE OF....ENDON....
                          AT NEW .....ENDAT
                           AT LAST....ENDAT
                           AT FIRST ......ENDAT  events for ur own understanding
    i hope this helps u.
    Regards
    panakj

  • Caculating page wise sub totals and totals

    Friends,
    I am working on an ADOBE form,  where i need to calculate subtotals and grand totals for the invoice lines displayed.
    I achieved the functionality in the smartforms by defining a different window under the main window(this contains line amounts). For the new window where the subtotal is expected to print i triggerred the event 'Before the end of main window' to print the totals before the lines flow to the next page by auto page break in the main window.
    I tried in the forms putting different content area(other than the main content area where table lines are printed) for the subtotals in the layout designer and manipulated using all the pagination options avialable in the table properties, but in vain. 
    What exatly is the equivalent for the event 'Before the end of main window' as that of smart forms.
    Any inputs on this?
    regards
    Nalinikanth.

    Hi Nalinikanth,
    assumed you have a table created with subforms like
    MyTable
    - Header
      (text elements)
    - Data
      (repeating subform with line elements)
    you can create a line with subtotal as following:
    1. Define a new line below "MyTable" for the subtotals with name e.g. "Subtotals" and insert elements (similar to the ones in "Data").
    2. In subform "Data": palette Object -> Pagination -> Overflow Trailer: "Subtotals"
    3. In Hierarchy palette, right-click on "Subtotals" -> Insert Script Object
    4. name this script object "tableCalcs" and insert following code
    *   Table Calculation Functions
    *     To invoke these functions:
    *   syntax:     scriptObjectSOM.obj.functionName(sFieldName, [startPage], [endPage]);
    *   example:     tableCalcs.Sum("Field1", 2, 3);
    *   notes:           
    *                    -The SOM expression of the Script Object may vary upon its position in the Hierarchy.
    *                    -The start and end page arguments are 0-based numbers or a reference to an XFA object.
    DO NOT MODIFY THE CODE BEYOND THIS POINT - 705.20051114114126.253659.250577 - tableCalcs.xfo
    var obj = new CalcObject();
    function CalcObject()
         this.Sum = _doSum;
         this.Average = _doAverage;
         this.Count = _doCount;
    *     Calculate the sum of all fields with the same name.
    *      NUMBER Sum(STRING sFieldName, [NUMBER pageNum])
    *      NUMBER Sum(STRING sFieldName, [OBJECT xfaObject])
    *      NUMBER Sum(STRING sFieldName, [NUMBER startPage], [NUMBER endPage])
    *      NUMBER Sum(STRING sFieldName, [OBJECT xfaObject], [OBJECT xfaObject])
    *     param1:     STRING; Name of field to calculate sum of
    *     param2:     NUMBER; Start page for calculation
    *     param2:     OBJECT; XFA object on the page calculation will start on
    *     param3:     NUMBER; End page for calculation
    *     param3:     OBJECT; XFA object on the page calculation will end on
    *     return: NUMBER; Sum of all fields
    function _doSum(fieldName)
         var fieldSum = null;
         var startPage = 0;
         var endPage = 0;
         var lengthOfDecimal = 0;
         if (arguments.length == 2) {
              startPage = _GetPageNum(arguments[1]);
              endPage = startPage;
         } else if (arguments.length == 3){
              startPage = _GetPageNum(arguments[1]);
              endPage = _GetPageNum(arguments[2]);
         } else {
              startPage = 0;
              endPage = xfa.layout.pageCount() - 1;
         if ((startPage < 0) || (endPage < 0) || (startPage > endPage))
              throw new PageNumberException(startPage, endPage);
         var curPage = startPage;
         while (curPage <= endPage) {
              // Get the field containers on the current page
              var oFields = xfa.layout.pageContent(curPage, "field");
              var fieldCount = oFields.length;
              // Continue if fields were found on the page
              if (fieldCount > 0) {
                   var i = 0;
                   for (i=0; i < fieldCount; i++) {
                        if (oFields.item(i).name == fieldName) {
                             //only count non-empty/numeric fields
                             var fieldVal = _GetFieldVal(oFields.item(i));
                             if (fieldVal != null) {                         
                                  fieldSum += fieldVal;
                             if (_GetLengthOfField(oFields.item(i)) > lengthOfDecimal) {
                                  lengthOfDecimal = _GetLengthOfField(oFields.item(i));
              curPage++;
         if (fieldSum == null)
              throw new FieldNotFoundException(fieldName);
         if(lengthOfDecimal > 0) {
              return fieldSum.toFixed(lengthOfDecimal);
         return fieldSum;
    *     Calculate the average of all fields with the same name.
    *      NUMBER Average(STRING sFieldName, [NUMBER pageNum])
    *      NUMBER Average(STRING sFieldName, [OBJECT xfaObject])
    *      NUMBER Average(STRING sFieldName, [NUMBER startPage], [NUMBER endPage])
    *      NUMBER Average(STRING sFieldName, [OBJECT xfaObject], [OBJECT xfaObject])
    *     param1:     STRING; Name of field to calculate average of
    *     param2:     NUMBER; Start page for calculation
    *     param2:     OBJECT; XFA object on the page calculation will start on
    *     param3:     NUMBER; End page for calculation
    *     param3:     OBJECT; XFA object on the page calculation will end on
    *     return: NUMBER; Average of all fields
    function _doAverage(fieldName)
         var fieldCount = null;
         var fieldSum = null;
         var startPage = 0;
         var endPage = 0;
         var lengthOfDecimal = 0;
         if (arguments.length == 2) {
              startPage = _GetPageNum(arguments[1]);
              endPage = startPage;
         } else if (arguments.length == 3){
              startPage = _GetPageNum(arguments[1]);
              endPage = _GetPageNum(arguments[2]);
         } else {
              startPage = 0;
              endPage = xfa.layout.pageCount() - 1;
         if ((startPage < 0) || (endPage < 0) || (startPage > endPage))
              throw new PageNumberException(startPage, endPage);
         var curPage = startPage;
         while (curPage <= endPage) {
              // Get the field containers on the current page
              var oFields = xfa.layout.pageContent(curPage, "field");
              var allFields = oFields.length;
              // Continue if fields were found on the page
              if (allFields > 0) {
                   var i = 0;
                   for (i=0; i < allFields; i++) {
                        if (oFields.item(i).name == fieldName) {
                             //only count non-empty/numeric fields
                             var fieldVal = _GetFieldVal(oFields.item(i));
                             if (fieldVal != null) {
                                  fieldCount ++;
                                  fieldSum += fieldVal;
                             if (_GetLengthOfField(oFields.item(i)) > lengthOfDecimal) {
                                  lengthOfDecimal = _GetLengthOfField(oFields.item(i));
              curPage++;
         if (fieldCount == null)
              throw new FieldNotFoundException(fieldName);
         if (fieldCount != null && fieldSum != null && fieldCount > 0) {
              var average = fieldSum / fieldCount;
              if(lengthOfDecimal > 0) {
                   return average.toFixed(lengthOfDecimal);
              return average;
         else {
              return null;
    *     Calculate the number of fields with the same name.
    *      NUMBER Count(STRING sFieldName, [NUMBER pageNum])
    *      NUMBER Count(STRING sFieldName, [OBJECT xfaObject])
    *      NUMBER Count(STRING sFieldName, [NUMBER startPage], [NUMBER endPage])
    *      NUMBER Count(STRING sFieldName, [OBJECT xfaObject], [OBJECT xfaObject])
    *     param1:     STRING; Name of field to calculate number of
    *     param2:     NUMBER; Start page for calculation
    *     param2:     OBJECT; XFA object on the page calculation will start on
    *     param3:     NUMBER; End page for calculation
    *     param3:     OBJECT; XFA object on the page calculation will end on
    *     return: NUMBER; Number of fields found
    function _doCount(fieldName)
         var fieldCount = null;
         var startPage = 0;
         var endPage = 0;
         if (arguments.length == 2) {
              startPage = _GetPageNum(arguments[1]);
              endPage = startPage;
         } else if (arguments.length == 3){
              startPage = _GetPageNum(arguments[1]);
              endPage = _GetPageNum(arguments[2]);
         } else {
              startPage = 0;
              endPage = xfa.layout.pageCount() - 1;
         if ((startPage < 0) || (endPage < 0) || (startPage > endPage))
              throw new PageNumberException(startPage, endPage);
         var curPage = startPage;
         while (curPage <= endPage) {
              // Get the field containers on the current page
              var oFields = xfa.layout.pageContent(curPage, "field");
              var allFields = oFields.length;
              // Continue if fields were found on the page
              if (allFields > 0) {
                   var i = 0;
                   for (i=0; i < allFields; i++) {
                        if (oFields.item(i).name == fieldName) {
                             //only count non-empty/numeric fields
                             var fieldVal = _GetFieldVal(oFields.item(i));
                             if (fieldVal != null) {
                                  fieldCount ++;
              curPage++;
         if (fieldCount == null)
              throw new FieldNotFoundException(fieldName);
         return fieldCount;
    function _GetFieldVal(obj)
         var fieldVal = obj.rawValue;
         if (typeof fieldVal != "number") {                         
              if (typeof fieldVal == "string" && fieldVal.length > 0) {
                   fieldVal = parseFloat(fieldVal);
                   if (isNaN(fieldVal))
                        fieldVal = null;
              } else {
                   fieldVal = null;
         return fieldVal;
    function _GetPageNum(val)
         var pageNum = -1;
         if (typeof val == "number") {                         
              pageNum = val;
         else if (typeof val == "object") {
              if (val != null) {               
                   pageNum = xfa.layout.page(val) - 1
         return pageNum;
    function _GetLengthOfField(obj)
         var fieldVal = obj.rawValue;
         if (fieldVal != null) {
              if (typeof fieldVal == "number") {
               fieldVal = new String(fieldVal);
              var index = fieldVal.indexOf(".");
              if (index > -1) {
                   return fieldVal.length - index - 1;
         return 0;
    function getExceptionString() { return this.message; }
    function FieldNotFoundException(fieldName)
         this.message = "Calculation failed: No non-empty fields found called '" + fieldName + "'.";
         this.name = "FieldNotFoundException";
         this.toString = getExceptionString;
    function PageNumberException(startPage, endPage)
         this.message = "Calculation failed: Incorrect page references (start page = " + startPage + ", end page = " + endPage + ").";
         this.name = "PageNumberException";
         this.toString = getExceptionString;
    // END OF DO NOT MODIFY     
    5. In the subtotal fields, add script for event "calculate":
    this.rawValue = this.parent.variables.tableCalcs.obj.Sum("AMOUNT", 0, this);
    where "AMOUNT" is the name of the referenced field.
    HTH & best regards,
    Carlo

  • Grand total and total in all page

    page 1
    colum1 | cloum2
    4 | 55
    1 | 6
    in Footer page1
    5 | 61
    page 2
    colum1 | cloum2
    2 | 3
    1 | 6
    in Footer page2
    3 | 9
    --------- i want
    in Footer page2
    8 | 70
    plez help me
    Message was edited by: azmi
    user490620

    What do you want exactly?
    Your subject says other thing then your actual question.
    Any how it snot difficult.
    Put summery Columns calculating the SUM of both fields (reset at report)
    & Set there property "print object on" to "last page".
    Hope it 'll work.
    Capri...

  • Totals and Sub-Totals in ALV GRID

    Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
    Ex:           value1    value2
                      100        50
                      200        50
        subtotal   300      100
        total                    400
    Thanks in advance...

    Refer below demo code and see perform Sort_list..
    it wil serve ur purpose.
    REPORT  ZGILL_ALV    message-id rp                           .
    type-pools slis.
    tables: zgill_main,zgill_details.
    data z_fieldcat type slis_t_fieldcat_alv.
    data begin of itab occurs 0.
    DATA ICON TYPE ICON-ID.
         include structure zgill_main.
    data salary like zgill_details-salary.
    data end of itab.
    *data itab1 like table of itab with header line.
    data : WA_SORT TYPE SLIS_SORTINFO_ALV,
           IT_SORT TYPE SLIS_T_SORTINFO_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
           IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
           WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    PARAMETERS: p_list  radiobutton group A1,
                P_GRID  RADIOBUTTON GROUP A1.
    SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
    start-of-selection.
    perform fill_itab.
    perform sort_list.
    **************Start of scenario without container******************************************
    *********Method 1***********
    perform fill_fieldcat.  " Manuallly Preparing Fiedl Catalog
    *********Method 2***********
    *perform fill_fieldcat1 changing z_fieldcat.   "Preparing field catalog with merge function
    perform display_alv.
    *****************end of scenario without container*****************************************
    *&      Form  fill_itab
          text
    -->  p1        text
    <--  p2        text
    form fill_itab .
    *select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
    *ITAB1[] = ITAB[].
    select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
           from zgill_main as a join zgill_details as b on apernr = bpernr
           WHERE A~PERNR IN S_PERNR.
    LOOP AT ITAB.
    IF ITAB-PERNR < 1111.
    ITAB-ICON = '@08@'.
    ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
    ITAB-ICON = '@09@'.
    ELSEIF ITAB-PERNR GE 11111111.
    ITAB-ICON = '@0A@'.
    ENDIF.
    MODIFY ITAB INDEX SY-TABIX.
    ENDLOOP.
    endform.                    " fill_itab
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    form display_alv .
    data repid like sy-repid.
    REPID = SY-REPID.
    WA_LAYOUT-ZEBRA = 'X'.
    WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
    WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
    WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    IF P_GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ELSEIF P_LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ENDIF.
    endform.                    " display_alv
    *&      Form  fill_fieldcat1
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat1  changing d_fcat type slis_t_fieldcat_alv.
    data repid like sy-repid.
    data d_fcat1 type slis_t_fieldcat_alv with header line.
    REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_STRUCTURE_NAME             = 'ZGILL_MAIN'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   =
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
    CHANGING
        ct_fieldcat                  = d_fcat[]
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3.
    IF sy-subrc <> 0.
       message e016 with 'Error in preparing fiedl catalog'.
    ENDIF.
    loop at d_fcat into d_fcat1.
    case d_fcat1-fieldname.
    when 'NAME'.
    d_fcat1-reptext_ddic = 'Emp Name'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'PERNR'.
    d_fcat1-reptext_ddic = 'Emp Num'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'ORG'.
    d_fcat1-reptext_ddic = 'Org Unit'.
    MODIFY D_FCAT FROM D_FCAT1.
    endcase.
    clear d_fcat1.
    endloop.
    endform.                    " fill_fieldcat1
    *&      Form  sort_list
          text
    -->  p1        text
    <--  p2        text
    form sort_list .
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'DOB'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    WA_SORT-SUBTOT = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'NAME'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    endform.                    " sort_list
    *&      Form  fill_fieldcat
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat .
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ICON'.
    WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
    WA_FIELDCAT-ICON = 'X'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 1.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'PERNR'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 2.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    when 'maktx'.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'NAME'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 3.
    WA_FIELDCAT-OUTPUTLEN = 15.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ORG'.
    WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
    WA_FIELDCAT-COL_POS = 4.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'DOB'.
    WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
    WA_FIELDCAT-COL_POS = 5.
    WA_FIELDCAT-OUTPUTLEN = 12.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'SALARY'.
    WA_FIELDCAT-SELTEXT_L = 'SALARY'.
    WA_FIELDCAT-COL_POS = 6.
    WA_FIELDCAT-OUTPUTLEN = 25.
    WA_FIELDCAT-do_sum = 'X'.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    endform.                    " fill_fieldcat

  • Calculate totals and sub totals

    hi everybody
    can u plz suggest me how to write code for getting sub totals and totals
    regards
    hridhaya

    Hello hridhayanjili
    SAP provides us with the ABAP statement <b>COLLECT</b> to summarize totals.
    I will give you an example from which you should be able to develop you own solution.
    Let's assume we have an itab containing materials. The itab has the following line structure: MANDT, MATNR, QUANTITY. To calculate subtotals we require a second itab that is identical to the first one.
    Now here is the coding:
    data:
      gt_itab          TYPE STANDARD TABLE OF <structure>,
      gt_itab_collect  TYPE STANDARD TABLE OF <structure>,
      gt_itab_total    TYPE STANDARD TABLE OF <structure>.
      gs_entry         TYPE <structure>.
    * NOTE: <structure> stands for a named DDIC structure or
    * a type definition, not a field symbol.
    * gt_itab contains our materials
      LOOP AT gt_itab INTO gs_entry.
        COLLECT gs_entry INTO gt_itab_collect.
      ENDLOOP.
    * NOTE: Assuming we had 10 entries in gt_itab of
    * 3 different materials we end up with 3 entries in
    * gt_itab_collect that contain the quantities summarized.
    * To calculate the total one could LOOP over
    * gt_itab_collect and summarize the values. Another way
    * is shown here:
      CLEAR: gs_entry-matnr.
      MODIFY gt_itab FROM gs_entry
        TRANSPORTING matnr
        WHERE ( matnr IS NOT INITIAL ).
    * We clear the material no.
      LOOP AT gt_itab INTO gs_entry.
        COLLECT gs_entry INTO gt_itab_total.
      ENDLOOP. 
    * NOTE: because we have the same value for CLIENT and
    * MATNR in every line we will end up with a single line
    * in gt_itab_total.
    Please read the documentation of the COLLECT statement carefully because the structure of your itab (i.e. the order of the fields, especially those that will be summarized) is important.
    Regards
       Uwe

  • Page break,sub total and grand total  in adobe forms

    hi,
    In adobe forms, i am displaying purchase order details in table format. internal table contains 150 records but it displaying
    only 50 records in single page. how i have to call a new page,how i have to create a page preak and i want to display only
    5 records for a page with carry forward,page total and total net value.

    Hi Sivaprasath,
    For the table content to flow onto the next pages please make sure that the outermost subform is NOT with the content property "Positioned".
    For having only 5 records per page, you can design a deep structure with fields:
    Table 1 (The table which will hold 5 records per page)
    Page total
    total net value
    Have the table type of it defined in the form.
    Put the logic for filling the table in such a way that each row of this nested table has 5 records and pagetotal and total net value.
    then put it inside a subform and check the checkbox for "rpeat subformt for each data item".
    Another way is to use Conditional breaks in Pagination tab.
    Thanks and regards,
    Priyanka

  • Weekly Group Total and associated YTD total

    Hello,
    I need to show current week group total and total year to date of the same group.  My columns are Model, Department, Issue.  Currently, the report is grouped on Model, Department and Issue with a filter for date.  Can this be done?   Thank you

    Create a formula field, say {@Current Week Amount} as (basic syntax):
    if datepart("ww", {datefield}) = datepart("ww", CurrentDate) then
      formula = {amount}
    else
      formula = 0
    end if
    You can then sum() this, or place it in a detail line, or whatever.  It will only have a (non-zero) value when the date field is in the current week.
    HTH,
    Carl

  • Query generator used to make general total and row total

    Dear experts/gurus,
    I have a problem how to create general total and total field in row by using query generator. In inventory in warehouse report of SBO 2004A SP 00 PL 41, there are total row of price x quantity / warehouse (if selection criteria is warehouse) and general total. I have made query report that quite similar with inventory in warehouse report using query generator and put selection criteria and item but I still can't find out the solution. is it possible using query generator to do that or if I use query analyzer, what is the code that I have to put ? is it compute sum(qty x price) by itemcode or there is stil another ? i appreciate your answer. TIA
    Rgds,

    Hi Jimmy,
    Here's one approach to solve your problem:
    = = = = = = =
    select oitm.itemcode, oitm.itemname, whs.whscode, whs.quantity
    from oitm inner join
    (select itemcode, sum(onhand) as quantity, whscode from oitw group by itemcode, whscode) whs
    on oitm.itemcode=whs.itemcode
    = = = = = = =
    ...the main query refers to the subquery as it was another table. The subquery calculates quantity per warehouse from the oitw table.
    Of course you could create a view in SQL Server instead of a subquery. That would make the query inside B1 query generator more simple and would also make it faster to execute.
    Henry

  • Alv - sub  totals and avg

    Hi gurus,
    I have a problem, please help me out.
    Iam doing an report program with alv display. In that iam calculating the AVG for the workcenter wise for the field TAT.
    please observe my below o/p in general ALv  format.
    work center-- TAT- Tat(Yes/no)
    qm0010------ 1 --  yes
    qm0010-------2 --  yes
    qm0010------ 4 -- yes
    qm0010------ 7 -- No (because >5)
    Subtotal(qm0010)--3  (avg caluculated)
    qm0020--  4 --- yes
    qm0020-7-- No (because >5)
    qm0020--10 - No (because >5)
    qm002010- No (because >5)
    Subtotal(qm0020)-- 7 (avg caluculated).
    this is the rough o/p iam getting . this is acheived by programming the Field catalog for TAT field i.e... do_sum  = 'C'.
    then giving the sort table to REUSE_ALV_GRID_DISPLAY.
    Now my problem is:
    I want the avg to be calcuted by the business formula which is:
    avg  =  sum of(TAT within 5 days) / total no of the entries .
    Ex:
    work center-- TAT- Tat(Yes/no)
    qm0010------ 1 --  yes
    qm0010-------2 --  yes
    qm0010------ 4 -- yes
    qm0010------ 7 -- No (because >5)
    Subtotal(qm0010)---*7/4=2 (avg caluculated for tat<5)*
    qm0020--  4 --- yes
    qm0020-7-- No (because >5)
    qm0020--10 - No (because >5)
    qm002010- No (because >5)
    Subtotal(qm0020)--4/4=1 (avg caluculated for tat<5).
    How can i acheive the above, since in field catalog and alv, i think we cannot pass any conditions(like for TAT which is less than 5). So is there any other way to acheive the above.
    Please understand the problem and give me(please directly dont suggest any programs , since iam not a expert to understand)..
    Please explain me in detail.  Points will be duly rewarded.
    Thanks in advance........Chaitu
    Edited by: chaitanya on May 30, 2008 12:33 PM
    Edited by: chaitanya on May 30, 2008 12:38 PM
    Edited by: chaitanya on May 30, 2008 12:39 PM

    Hi Chaitanya,
       You can display in your report with totals and sub-totals using alv, but not average. That functionality has not provided by sap. Do one thing add one more extra column Average in your output, do the calculation for average and pass the value in the coding itself. Then last display your report with Average field.
    Rgds,
    Bujji

  • How to create a sub total and grand total using my query.

    How can I create a sub total for each section and grand total for using my query like this.  your help is appreciated. I am working with 9g
    WITH  BidItemsInformation  AS
    ( SELECT DISTINCT q.iplineno "Line Number", q.section "Section Number",
             i.item "Item Number",
             initcap(i.idescr) "Description" ,
             i.iunits "Unit",
             q.qty "Quantity" ,q.price  "Engineers Unit Price",
           (q.price * q.qty) "Engineers Estimate"
         FROM letprop l,
            proposal p,
            propitem q,
            bidlet b,
            bidtabs c,
            itemlist i,
            vendor v,
            bidders d 
         WHERE(l.letting = b.letting
                And b.letting = c.letting
                And p.cspecyr = i.ispecyr)
                AND q.prpitem = i.item
                AND p.contid = l.lcontid
                AND q.contid = p.contid
                AND c.vendor = l.avendor
                AND l.CALL = c.CALL
                AND q.lineflag = c.lineflag
                AND q.iplineno = c.iplineno
                AND l.letting = d.letting 
                AND c.letting = l.letting
                AND c.CALL = d.CALL
                AND v.vendor = d.vendor
                --  AND AND l.letstat = 'A'
                AND c.lineflag = 'L'
                AND  l.letting ='&letting'
                AND l.CALL = '&call'
    ), BiddersInformation  AS
    -- This is where you make your changes for vendor name and vendor number Do not touch the above code
    -- It is always the same for any call number and letting date
    ( SELECT IPLINENO "BLine Number",
            MAX(CASE WHEN VENDOR='K020'  THEN bidprice ELSE NULL END) "K020:: Unit Price",
            MAX(CASE WHEN VENDOR='K020'  THEN bidprice ELSE NULL END) K,
            MAX(CASE WHEN VENDOR='H438'  THEN bidprice ELSE NULL END) "H438:: Unit Price",
            MAX(CASE WHEN VENDOR='H438'  THEN bidprice ELSE NULL END) H,
            MAX(CASE WHEN VENDOR='U010'  THEN bidprice ELSE NULL END) "U010:: Unit Price",
            MAX(CASE WHEN VENDOR='U010'  THEN bidprice ELSE NULL END) U,
            MAX(CASE WHEN VENDOR='G110'  THEN bidprice ELSE NULL END) "G110:: Unit Price",
            MAX(CASE WHEN VENDOR='G110'  THEN bidprice ELSE NULL END) G,
            MAX(CASE WHEN VENDOR='H530'  THEN bidprice ELSE NULL END) "H530:: Unit Price",
            MAX(CASE WHEN VENDOR='H530'  THEN bidprice ELSE NULL END) H1
        FROM  BIDTABS
        WHERE LETTING='&letting'
              AND CALL='&call'
              AND BIDPRICE <> 0
        GROUP BY IPLINENO
    SELECT BidItemsInformation."Line Number",
           BidItemsInformation."Section Number",
           BidItemsInformation."Item Number",
           BidItemsInformation."Description",
           BidItemsInformation."Unit",
           BidItemsInformation."Quantity",
           BidItemsInformation."Engineers Unit Price",
           BidItemsInformation."Engineers Estimate",
           BiddersInformation."K020:: Unit Price",
            (BidItemsInformation."Quantity" * K) "KGM CONTRACTORS INC",
           BiddersInformation."H438:: Unit Price",       
            (BidItemsInformation."Quantity" * H) "HOFFMAN CONSTRUCTION COMPAN",
           BiddersInformation."U010:: Unit Price",       
            (BidItemsInformation."Quantity" * U) "ULLAND BROTHERS INC",
           BiddersInformation."G110:: Unit Price",      
            (BidItemsInformation."Quantity" * G) "GLADEN CONSTRUCTION INC",
           BiddersInformation."H530:: Unit Price",      
            (BidItemsInformation."Quantity" * H1) "HOOVER CONSTRUCTION CO"
    FROM   BidItemsInformation,BiddersInformation
    WHERE  BidItemsInformation."Line Number" = BiddersInformation."BLine Number";
    Line Number     Section Number     Item Number     Description     Unit     Quantity     Engineers Unit Price     Engineers Estimate     K020:: Unit Price     
    0010     0001     2011601/00003     Construction Surveying     LS       1     143,000     143,000     75,000     75,000     67,080     67,080
    0013     0001     2013601/00010     Survey Equipment     LS       1     25,000     25,000     25,000     25,000     30,000     30,000
    0020     0001     2015601/00030     Blast Monitor/Survey     LS       1     50,000     50,000     30,000     30,000     35,000     35,000
    0030     0001     2021501/00010     Mobilization     LS       1     382,250     382,250     809,000     809,000     704,000     704,000
    0040     0001     2021602/00010     Well Survey     EACH     60     500     30,000     2,150     129,000     1,600     96,000
    0050     0001     2031501/00040     Field Office Type D     EACH     1     6,367     6,367     4,000     4,000     25,000     25,000
    sub total:
    1610     0002     2401501/01143     Structural Concrete (1a43)     C Y      46     350     16,100     408     18,768     400     18,400
    1620     0002     2401501/01362     Structural Concrete (1c62)     C Y      68     200     13,600     204     13,872     200     13,600
    1630     0002     2401501/03643     Structural Concrete (3y43)     C Y      60     600     36,000     592     35,520     580     34,800
    1640     0002     2401512/03633     Bridge Slab Concrete (3y33)     S F      1,876     24     45,024     28     51,778     27     50,652
    1650     0002     2401521/00030     Structure Excavation Class R     C Y      17     125     2,125     1,000     17,000     500     8,500
    1660     0002     2401541/00010     Reinforcement Bars     LB       2,490     2     3,735     1     3,312     1     3,237
    1670     0002     2401541/00011     Reinforcement Bars (Epoxy Coated)     LB       12,380     2     18,570     1     17,703     1     17,332
    1680     0002     2401601/00010     Structure Excavation     LS       1     2,500     2,500     2,000     2,000     5,000     5,000
    1690     0002     2402583/00020     Ornamental Metal Railing Type Special     L F      284     150     42,600     194     55,096     190     53,960
    sub total
    1820     0003     2401513/00346     Type Curb Railing Concrete (3y46)     L F      135     25     3,375     16     2,093     15     2,025
    1830     0003     2401513/07447     Type Mod P-4 (Tl-4) Railing Conc (3y46)     L F      302     85     25,670     72     21,593     70     21,140
    1840     0003     2401541/00010     Reinforcement Bars     LB       14,780     1     18,475     1     13,598     1     13,302
    1850     0003     2401541/00011     Reinforcement Bars (Epoxy Coated)     LB       76,720     1     103,572     1     85,926     1     84,392
    1860     0003     2401601/00010     Structure Excavation     LS       1     10,000     10,000     116,000     116,000     115,000     115,000
    1870     0003     2402583/00020     Ornamental Metal Railing Type Special     L F      132     150     19,800     184     24,288     180     23,760
    sub total
    total

    You can accomplish that using decode with the grouping function. It returns 1 when that column passed as argument was grouped (or is in some total) and 0 otherwise.
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> with t as
      2  (select 'New York' city, 'US' country, 1 num from dual
      3  union all select 'Los Angeles' city, 'US' country, 2 num from dual
      4  union all select 'London' city, 'GB' country, 2 num from dual
      5  union all select 'London' city, 'GB' country, 2 num from dual
      6  union all select 'London' city, 'GB' country, 7 num from dual)
      7  select decode(grouping(country), 0, country, 'GRAND TOTAL') country,
      8         decode(grouping(city), 0, city, decode(grouping(country), 0, 'SUBTOTAL')) city,
      9         sum(num) num_total
    10   from t
    11  group by rollup(country, city)
    12  /
    COUNTRY     CITY         NUM_TOTAL
    GB          London              11
    GB          SUBTOTAL            11
    US          New York             1
    US          Los Angeles          2
    US          SUBTOTAL             3
    GRAND TOTAL                     14
    6 linhas selecionadas.
    SQL>

  • Regarding totals  and sub totals text in alv

    Hi all,
    i am displaying Totals and subtotals ......but i want to display the text before the the Totals and Subtotals.
    Please help me in regarding this..
    Thanks in advance,
    S.Gangi reddy.

    hi,
    check this report.
    *& Report  ZGM_ALV_SUBTOTAL_TEXT                                       *
    *& Author :
    *& Date :
    *& Description :
    *& Modification History
    REPORT  ZGM_ALV_SUBTOTAL_TEXT                   .
    *& Table declaration
    TABLES: ekko.
    *& Type pool declaration
    TYPE-POOLS: slis. " Type pool for ALV
    *& Selection screen
    SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
    *& Type declaration
    Type declaration for internal table to store EKPO data
    TYPES: BEGIN OF x_data,
           ebeln  TYPE char30,  " Document no.
           ebelp  TYPE ebelp,   " Item no
           matnr  TYPE matnr,   " Material no
           matnr1 TYPE matnr,   " Material no
           werks  TYPE werks_d, " Plant
           werks1 TYPE werks_d, " Plant
           ntgew  TYPE entge,   " Net weight
           gewe   TYPE egewe,   " Unit of weight                          
           END OF x_data.
    *& Internal table declaration
    DATA:
      i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
    Internal table for storing field catalog information
      i_fieldcat TYPE slis_t_fieldcat_alv,
    Internal table for Top of Page info. in ALV Display
      i_alv_top_of_page TYPE slis_t_listheader,
    Internal table for ALV Display events
      i_events TYPE slis_t_event,
    Internal table for storing ALV sort information
      i_sort TYPE  slis_t_sortinfo_alv,
      i_event TYPE slis_t_event.
    *& Work area declaration
    DATA:
      wa_ekko TYPE x_data,
      wa_layout     TYPE slis_layout_alv,
      wa_events         TYPE slis_alv_event,
      wa_sort TYPE slis_sortinfo_alv.
    *& Constant declaration
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    *& Start-of-selection event
    START-OF-SELECTION.
    Select data from ekpo
      SELECT ebeln " Doc no
             ebelp " Item
             matnr " Material
             matnr " Material
             werks " Plant
             werks " Plant
             ntgew " Quantity
             gewei " Unit
             FROM ekpo
             INTO TABLE i_ekpo
             WHERE ebeln IN s_ebeln
             AND ntgew NE '0.00'.  IF sy-subrc = 0.
        SORT i_ekpo BY ebeln ebelp matnr .
      ENDIF.
    To build the Page header
      PERFORM sub_build_header. "* To prepare field catalog
      PERFORM sub_field_catalog. "* Perform to populate the layout structure
      PERFORM sub_populate_layout."* Perform to populate the sort table.
      PERFORM sub_populate_sort."* Perform to populate ALV event
      PERFORM sub_get_event.
      END-OF-SELECTION.
    * Perform to display ALV report
      PERFORM sub_alv_report_display.
    *&      Form  sub_build_header
          To build the header
          No Parameter
    FORM sub_build_header .
    Local data declaration
      DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE char10,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    Title  Display
      l_r_line-typ = c_header.               " header
      l_title = 'Test report'(001).
      l_r_line-info = l_title.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR l_r_line.
    * Run date Display
      CLEAR l_date.
      l_r_line-typ  = c_item.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'(002).
      l_r_line-info = l_date.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.ENDFORM.                    " sub_build_header
    *&      Form  sub_field_catalog
          Build Field Catalog
          No Parameter
    FORM sub_field_catalog .
    Build Field Catalog
      PERFORM sub_fill_alv_field_catalog USING:     '01' '01' 'EBELN'
      'I_EKPO' 'L'
         'Doc No'(003) ' ' ' ' ' ' ' ',     '01' '02' 'EBELP' 'I_EKPO' 'L'
         'Item No'(004) 'X' 'X' ' ' ' ',     '01' '03' 'MATNR' 'I_EKPO' 'L'
         'Material No'(005) 'X' 'X' ' ' ' ',     '01' '03' 'MATNR1' 'I_EKPO'
         'L'
         'Material No'(005) ' ' ' ' ' ' ' ',
         '01' '04' 'WERKS' 'I_EKPO' 'L'
         'Plant'(006) 'X' 'X' ' ' ' ',     '01' '04' 'WERKS1' 'I_EKPO' 'L'
         'Plant'(006) ' ' ' ' ' ' ' ',     '01' '05' 'NTGEW' 'I_EKPO' 'R'
         'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM.
    " sub_field_catalog*&----
    *&     Form  sub_fill_alv_field_catalog
    *&     For building Field Catalog
    *&     p_rowpos   Row position
    *&     p_colpos   Col position
    *&     p_fldnam   Fldname
    *&     p_tabnam   Tabname
    *&     p_justif   Justification
    *&     p_seltext  Seltext
    *&     p_out      no out
    *&     p_tech     Technical field
    *&     p_qfield   Quantity field
    *&     p_qtab     Quantity table
    FORM sub_fill_alv_field_catalog  USING  p_rowpos    TYPE sycurow
                                            p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_tabnam    TYPE tabname
                                            p_justif    TYPE char1
                                            p_seltext   TYPE dd03p-scrtext_l
                                            p_out       TYPE char1
                                            p_tech      TYPE char1
                                            p_qfield    TYPE slis_fieldname
                                            p_qtab      TYPE slis_tabname.
                                           Local declaration for field
                                           catalog
      DATA: wa_lfl_fcat    TYPE  slis_fieldcat_alv.
      wa_lfl_fcat-row_pos        =  p_rowpos.     "Row
      wa_lfl_fcat-col_pos        =  p_colpos.     "Column
      wa_lfl_fcat-fieldname      =  p_fldnam.     "Field Name
      wa_lfl_fcat-tabname        =  p_tabnam.     "Internal Table Name
      wa_lfl_fcat-just           =  p_justif.     "Screen Justified
      wa_lfl_fcat-seltext_l      =  p_seltext.    "Field Text
      wa_lfl_fcat-no_out         =  p_out.        "No output
      wa_lfl_fcat-tech           =  p_tech.       "Technical field
      wa_lfl_fcat-qfieldname     =  p_qfield.     "Quantity unit
      wa_lfl_fcat-qtabname       =  p_qtab .
      "Quantity table
      IF p_fldnam = 'NTGEW'.
        wa_lfl_fcat-do_sum  = 'X'.
      ENDIF.
      APPEND wa_lfl_fcat TO i_fieldcat.
      CLEAR wa_lfl_fcat.
    ENDFORM.
    " sub_fill_alv_field_catalog*&----
    *&      Form  sub_populate_layout
          Populate ALV layout
          No Parameter
    FORM sub_populate_layout .  CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'.
    " Optimization of Col width
    ENDFORM. " sub_populate_layout*&----
    *&      Form  sub_populate_sort
          Populate ALV sort table
          No Parameter
    FORM sub_populate_sort .
    Sort on material
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    Sort on plant
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.
    " sub_populate_sort*&----
    *&      Form  sub_get_event
          Get ALV grid event and pass the form name to subtotal_text
          event
          No Parameter
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
    'SUBTOTAL_TEXT'.  DATA: l_s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    Subtotal
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.ENDFORM.
    " sub_get_event*&----
    *&      Form  sub_alv_report_display
          For ALV Report Display
          No Parameter
    FORM sub_alv_report_display .
      DATA: l_repid TYPE syrepid .
      l_repid = sy-repid .
    This function module for displaying the ALV
    report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          it_sort = i_sort
          it_events                = i_event
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = i_ekpo
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
       MESSAGE i000 WITH 'Error in ALV report display'(055).
      ENDIF.
      ENDFORM.
    " sub_alv_report_display*&----
          FORM sub_alv_top_of_page
          Call ALV top of page
          No parameter
    FORM sub_alv_top_of_page.                                   "#EC CALLED*
    *To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_alv_top_of_page.
    ENDFORM.
    "alv_top_of_page*&----
    *&      Form  subtotal_text
          Build subtotal text
          P_total  Total
          p_subtot_text Subtotal text info
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'MATNR'.
        p_subtot_text-display_text_for_subtotal
        = 'Material level total'(009).
      ENDIF.
    Plant level sub total
      IF p_subtot_text-criteria = 'WERKS'.
        p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
      ENDIF.
    ENDFORM.                    "subtotal_textSelection screen:
    \[removed by moderator\]
    Edited by: Jan Stallkamp on Sep 3, 2008 6:17 PM

  • What's the best way to create sub-totals & grand-total in SQL2008 R2 (and beyond)?

    What is the easiest way to get sub totals and a grand total on data that is being grouped?  It looks like RollUp might work, but it's being depreciated.
    My query is:
    SELECT
    COMPANY
    ,INVSTR_CD
    ,STATE_C
    ,SUM(CO_SHARE_TOTBAL) as CO_SHARE_TOTBAL
    FROM #ASSET AS A
    WHERE A.D_GETIT = 'Y'
    GROUP BY COMPANY, STATE_C, INVSTR_CD
    ORDER BY COMPANY, INVSTR_CD, STATE_C
    I need to provide a sub-total of the SUM'd field (SUM(CO_SHARE_TOTBAL) as CO_SHARE_TOTBAL), at the change of the COMPANY field.
    Then a Grand Total of all the SUM'd fields (SUM(CO_SHARE_TOTBAL).
    Thanks in advance!!
    -Al H

    If you post DDL of your table (only relevant columns) and some data and desired output, I may try to reproduce it. Did you check Jacob's blog post and the very last query? It does take a few trials before getting this correct. 
    Naomi,
    I did try the last query on Jacob's post.  I couldn't get the first column to populate.
    Thanks for the offer of help.
    DML is:
    Create Table #ASSET2 (
    [COMPANY] [varchar] (5) NULL
    ,[INVSTR_CD] [varchar](5) NULL
    ,[STATE_C] [char](2) NULL
    ,[SHARE_TOTBAL] [decimal] (15,2) NULL)
    Data is:
    Insert into #ASSET2 VALUES ('00000','099 ','FL','115226.77')
    Insert into #ASSET2 VALUES ('22222','030 ','CA','309899.43')
    Insert into #ASSET2 VALUES ('00000','010 ','CA','524296.89')
    Insert into #ASSET2 VALUES ('00000','099 ','IL','51699.70')
    Insert into #ASSET2 VALUES ('00000','789 ','PA','90856.04')
    Insert into #ASSET2 VALUES ('22222','010 ','CA','66951.33')
    Insert into #ASSET2 VALUES ('00000','099 ','CA','310046.03')
    Insert into #ASSET2 VALUES ('00000','010 ','AZ','178062.08')
    Insert into #ASSET2 VALUES ('00000','099 ','NY','278489.10')
    Desired results would be the following:
    COMPANY INVSTR_CD STATE_C SHARE_TOTBAL
    00000 010 AZ 178062.08
    00000 010 CA 524296.89
    00000 099 CA 310046.03
    00000 099 FL 115226.77
    00000 099 IL 51699.70
    00000 099 NY 278489.10
    00000 789 PA 90856.04
    TOTAL COMPANY 00000 1548676.61
    22222 010 CA 66951.33
    22222 030 CA 309899.43
    TOTAL COMPANY 22222 376850.76
    GRAND TOTAL 1925527.37
    -Al H

Maybe you are looking for

  • Error while importing a dump file in my local database

    Hi, I have a dump file named *"system_21Sep2010_DVSD.DMP"* which i'm trying to import in my local database named *"nandita1"*. The dump file is found under the following path *"C:\DevSuiteHome_1\BIN"* and i executed the following command for importin

  • FI link with pricing procedure in mm

    In MM in pricing procdure there are two fileds  Account key and Accruals key. I want to know how to create them and how to link them to the G/L account.  These fields can be found in the "Calcualtion of pricing procedure" in the pricing of MM. Anybod

  • Query Regarding IDOC  "WMMBID02"

    Hi, I have a follwoing requirement that makes use of a standart IDOC WMMBID02. This IDOC WMMBID02 has data stored within into different segments that have structures. I need to read that data and store it into an INTERNAL Table. Is there any specific

  • HP laptop with 52" LCD TV

    I have this 52" lcd tv and am toying with the thought of using it as a monitor with my laptop. Has anyone tried this setup, and if you did, does it funtion well. Thanks HP P2-1117BC x64 G460 HP dv7-1247cl X64 AMD 72 Windows 7 Home Premium AVIRA &Wind

  • Creative Video Converter

    I am looking for the program Creative Video Converter. I had it on my PC, but then I had to reinstall the System and lost the program. I have been looking for it all over, but no success. The program is needed to convert Videos for my ZEN XFi 2. BADA