Calculating subtotal in table control

Hi all my requrement is like this
I am using one tabbed screen .
in the last tabbed screen i have used table control in that
screen there is one requirement so that to  calculate the subtotal as we can do in case of alv reporting by using the subtotal button .
can anybody help me how to do this .

HI,
subtotal_text
Use
Output text for subtotals in the grid control if the subtotal criterion (column used by the user for calculating the subtotal) is hidden. In the default setting, the ALV Grid Control outputs the column header of the subtotal criterion and the value to which the subtotal calculated refers.
Event parameters
Meaning
ES_SUBTOTTXT_INFO
Type LVC_S_STXT
Structure with information on the subtotal criterion
EP_SUBTOT_LINE
Type Ref To DATA
Reference variable to the inserted subtotal line in the grid control. Columns for which no total was calculated remain set to their initial value.
E_EVENT_DATA
Type Ref To CL_ALV_EVENT_DATA
Attribute M_DATA of this object is a reference to the subtotal text.
For an overview, see: Events of Class CL_GUI_ALV_GRID
Example
You display a table with data of structure SFLIGHT in an ALV Grid Control. We now change the pre-set subtotal text for subtotal criterion plane type of table SFLIGHT :
Define and implement an event handler method for event subtotal_text . Register this event with SET HANDLER .
Call a subroutine within this method and pass the event parameters to that subroutine.
Event parameters ep_subtot_line and e_event_data contain reference variables to generic data type DATA . This is why you must use field symbols in the subroutine:
FORM method_subtotal_text USING es_subtottxt_info TYPE lvc_s_stxt
                               ep_subtot_line TYPE REF TO data
                               e_event_data TYPE REF TO
                               cl_alv_event_data.
  DATA ls_sflight LIKE sflight.
  FIELD-SYMBOLS: <fs1> STRUCTURE sflight DEFAULT ls_sflight,
                <fs2>.
  IF es_subtottxt_info-criteria = 'PLANETYPE'.
    ASSIGN ep_subtot_line->* TO <fs1>.
    ASSIGN e_event_data->m_data->* TO <fs2>.
    CONCATENATE es_subtottxt_info-keyword ': '
                <fs1>-planetype INTO <fs2>.
  ENDIF.
ENDFORM. " METHOD_SUBTOTAL_TEXT
Result
Check your result as follows:
Calculate the total for a column.
Calculate subtotals for column plane type .
Hide column plane type . To do this, use either the standard context menu or a new layout.
The new text defined is displayed at the beginning of a subtotal line.

Similar Messages

  • How to do the calculations with currency fields in table control?

    Hi everybody,
    Can anyone tell me how to do the calculations (arithmetical) with the currency fields which have been assigned for a table control fields? Actually they should be fetched from the database table and need to do some calculations and after that the same should get updated at the database level.
    Here, i am getting the short dump after doing the calculations and trying to display at the table control field itself.....
    Can anyone help me in this issue........
    Thank you very much.....in advance,
    Somu.

    Hi,
    Thanks to your replies all,
    But, even though the sign check box is checked in the SAP domain WRTV7, in my program it is not showing the negative sign at all...
    I am keep trying for all the options...
    But still it is not working out...
    My requirement is after fetching the data from the database i need to do calculations and save back same to the customized table field, for which the domain i have checked the sign and have done it also...
    I'd be highly thankful to you, if you can help me out...
    Thank you,
    Somu.

  • Decimals in Qty and Price in Table control

    Hi All,
    I have having two issues with decimals in table control.
    1. I have a field defined as type KWMENG in the Internal table that is mapped to the table control. I also gave the REF FIELD in the
        field properties as it is a QTY field and FORMAT as QUAN.
        Issue: THe issue here is the data is displaying as 100.000. As this is a QTY field we want it to show just 100.
        I tried changing it to CHAR field and display but this will not work for me as i am using this data later in some calculations.
    2. The other issue is with the PRICE field. I have defined as type KWERT in the internal table mapping to the table control. I gave
        FORMAT as DEC in field properties.
        Issue: The issue here is when the calculated value is say 5.60 it is displaying as 5.00.
    Does anyone has any idea. I think i am missing something but not sure what it is.
    Thanks in advance,
    Karuna.

    hi,
    u can achieve it thru SP_TransactionNotification
    try this code
    --      Block GRPO if in Excess in PO Qty
    IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'20')
    begin
         if exists (SELECT T0.BaseEntry, SUM(T0.Quantity)
         FROM [dbo].[PDN1] T0 INNER JOIN [dbo].[POR1] T1 ON T1.DOCENTRY = T0.BASEENTRY
         WHERE T0.BaseType = 22 AND T0.ItemCode = T1.ItemCode AND T0.BaseLine = T1.LineNum and T0.DOCENTRY = @list_of_cols_val_tab_del
         GROUP BY T0.BaseEntry
         HAVING (SUM(T0.Quantity) > SUM(T1.Quantity)) or sum(t0.quantity) > sum(t0.BaseOpnQty))
         begin
              select @Error = 10, @error_message = 'GRPO quantity is greater PO quantity'
         end
    end
    fidel

  • Doubt in smartform table control

    hi,
      in my smartform i want to display the table control, i got that normal table control, but i want to change the table control format, that means in write side in the tabs column no need of calculation i need event tab, how to make that?
    Thanks and regards,
    Gowri.

    Hi Gowri,
    You cannt display Table control in smartform output. As it is reporting tool. Not Dialog Module.
    In data tab of table control you can have events.
    Reward if useful.

  • Negetive No in Table Control

    i am doing calculation in internal table as the result i am getting the negetive value stored in in internal table,
    But when i am display this table in table Control it give the run time error
    Screen name.............. "ZMPPR_MAT_ISSUE_PLAN"
    Screen number............ 9000                  
    Screen field............. "WA_MAT-ALLO_QTY"     
    Error text............... "FX015: Sign lost."   
    if i have a WA_MAT-ALLO_QTY positive value no error
    if WA_MAT-ALLO_QTY its has a negetive then RUN TIME ERROR
    PLEASE SOLVE MY PROBLEM

    Refer these threads:
    how to display negative values in a screen field of a screen
    and
    Re: Positive and Negative values for Amount fields on Screens
    Regards,
    Ravi

  • Table control: Line selection single issue

    Hi experts,
    I have created a table control and in the screen painter I have defined the line selection as "Single" for table control.
    The table control can display upto 20 lines in a screen and i can select a single record only which pertains to my requirement. if I try to select two records it will not allow.
    Issue: consider  i select a single record from the first 20 lines displayed in screen, then i scroll the records in the table control so that it displays the records from 21 to 40. if I select a single record now from line 21 to 40, the first record that i selected is not getting deselected. That is, totally two lines are getting selected.
    How to overcome this issue
    Thanks in advance
    Regards
    Anand

    Ok
    The "problem" is here:
    Types: Begin of ty_ic,
      ic(20),
      desc(20),
      sel(1)                                 <--------------------------------
    End of ty_ic.
    You've ha a field for selected line and that field is used in table control definition as you've written:
    "Note: wa_ic is the structure used in table control and wa_ic-sel is the mark field defined the table control attributes"
    So you're using the structure WA_IC as header line of internal table IT_IC and also as input/put field of your table control (I mean the screen fields of table control are based on WA_IC).
    You don't need any code in PBO to move the data from internal table to table control, because the headerline of IT_IC and field of table control are the same, infact you've implemented only the code in PAI to save the data from table control to IT_IC:
    Loop at it_ic.
    Modify it_ic from wa_ic index tc_ic-current_line
    Endloop
    t's a good solution if it needs to transfer all data to table control automatically: it doesn't need any code in PBO
    but, of course, there'll be a problem when you don't need to display something, in this case you have to think a solution, I mean you have to write a code in order to avoid to display those data.
    It's the case of the selected line: in your situation all selected lines keep the selection, because the code to clear IT_IC-SEL is missing: only the user can deselect a line, but if he doesn't do it, the line will remain selected after navigation.
    So you make to be sure to clear all selected lines are not displayed.
    You need to create a code in PAI out of the loop of table control where you clear the flag SEL, in order to do it you need to consider:
    - The index of the first record displayed in table control is stored in field TC_IC-TOP_LINE
    - The index of the last record displayed in table control can be calculated: the variable SY-LOOPC indicates how many rows can be displayed in table control, so the last record will be: TC_IC-TOP_LINE + SY-LOOPC.
    So you need to clear the field SEL for all records not displayed, a code like this:
    PROCESS PAI.
      LOOP AT IT_IC.
         MODULE GET_LOOPC.
      ENDLOOP.
      MODULE CLEAR_SEL.
      MODULE GET_LOOPC..
          TOT_LINE_DISPLAYED = SY-LOOPC.
      ENDMODULE
      MODULE CLEAR_SEL.
    * Here you need to clear the selection of the records before of TOP_LINE
           IF TC_IC-TOP_LINE > 1.
              LOOP AT IT_IC INTO WA_IC  TO TC_IC-TOP_LINE.
                 CLEAR WA_IC-SEL.
                 MODIFY IT_IC FROM WA_IC.
              ENDLOOP.
         ENDIF.
    * Here you need to clear the selection of the records after the last one:
          LAST_INDEX = TOT_LINE_DISPLAYED + TC_IC-TOP_LINE.
         DESCRIBE TABLE IT_IC LINES SY-TABIX,
         IF SY-TABIX > LAST_INDEX.
              LOOP AT IT_IC INTO WA_IC  FROM LAST_INDEX.
                 CLEAR WA_IC-SEL.
                 MODIFY IT_IC FROM WA_IC.
              ENDLOOP.
         ENDIF.
      ENDMODULE.

  • Dynamic Tool TIP in Table Control

    Dear Friends,
    Thanks in Advance.
    How to implement Dynamic Tool TIP in the Table Control for Particularly One Columnn.
    i.e rows in that Column.
    Note : Column contains Currency Type Data
    For that column, i am calculating the Quantity Multiplied with the Exchange Rate.
    That Calculation should be visible in the Tool TIP.
    Regards:
    Sridhar.J

    Hi
    Take Text Element Radio button there  and give any number and activate.
    If the Visible lenght of the Table Control Field is less than actual length of the Content, it automatically displays the Tool Tip.
    I just did it.
    Hope this serves your purpose.
    Get it fram Sam
    "  Hey Sreedhar, Let us know how can we do it , it will be helpful.
    Cheers
    Ram
    Edited by: Ramchander Krishnamraju on Jan 2, 2010 4:06 AM

  • How to get value on the table control in infotyp e0008

    Dear Freinds
                I have written a user exit ZXPADU02 for my requirement
    as per the requirement in i have calculated  wa-poo8-bet01 = wa_p0008-ansal/12 and i have passed on to the INNNN structure .
    Nowe when do a Create or Copy for a rcord in  infotype 0008  iam not
    getting value on Q0008-betrg field on the SCREEN , since it is table control how to get data on the table Control Cell .
    Please let me knlow
    regards

    Hi Syamala,
    The try to find the name of the table control and pass the values to it.
    Of course you have to loop and endloop, the table control and mofidy it from the work area.
    Message was edited by:
            Sera

  • How to find page subtotal in tables in a smartform?

    Hi All,
       Can anyone please help me how to find the page subtotal of any field thats populated in a table in a smartform?

    hi ,
    for sub-totals create int.table and work area of type your required db.table and go through the below steps.
    1. mention the field in <b>Sort Criteria</b> (you can find in DATA tab inTABLE)based on which you want subtotal for another field.And check the check-boxes Event on SortBegin,Event on SortEnd.
    2.then you will get 2 nodes with name of the field u have given.before and after main area. for ex.NTGEW Event on SortBegin
                              NTGEW Event on SortEnd
    ( for example you want subtotal based on the weight-wise i.eNTGEW and you want to add cases delivered i.e.LFIMG)
    3.pass the data to subtotal internal table from int.table which contains item data or from datadbase. in main area
    4.below the <b>NTGEW Event on SortEnd</b> node create one <b>loop</b> and under the loop create <b>programlines</b> there you have to write coding for subtotal like in reports,
    loop at it_sub into wa_sub.
    at end of <f>
    sum.
    endloop.
    and then create one <b>TEXT</b> and give the variable  for ex. &wa_sub-lfimg&(which contains subtotal value)
    5.and dont forget you should refresh the int.table of subtotal below the <b>NTGEW Event on SortBegin</b> node.
    for <b>totals</b> simply mention in the calculation tab.
    regards,
    rajkumar.
    Message was edited by:
            rajkumar

  • Table control column grayed

    I have a tc where it is validating the column zmsd_invtype_TC-out_type from db.
    I want that column of tc to be grayed out initially and when pressed append or insert button, it should be ready for input. but rest of the columns should be enabled.
    thanks,
    Abhijeet.

    Hi  Abhijeet ,
    this  is  link with  screen  shot of table control  creation 
    <a href="http://">http://www.sapdevelopment.co.uk/dialog/tabcontrol/tc_basic.htm</a>
    <b>Highlight individual table control field</b>
    The example below sets the EBELN field on the 3rd row of the table control to not be an input field. This is a fairly simple process which involves firstly calculating which row of the internal table is displayed at the top of the table control. From this you can work out which itab row is on the 3rd row and set its attributes using the LOOP AT SCREEN command.
    Based on the example table control the ABAP code for this will be as follows, resulting in a modified version of the PBO MODULE 'populate_screen'.
    MODULE populate_screen OUTPUT.
        DATA: ld_line TYPE i.
    *   Set which line of itab is at the top of the table control
        IF sy-stepl = 1.
          tc100-lines =
            tc100-top_line + sy-loopc - 1.
        ENDIF.
    *   move fields from work area to scrren fields
        MOVE-CORRESPONDING wa_ekko TO ztc_ekko.
        ld_line =  sy-stepl + tc100-top_line - 1.
    *   Changes individual field attributes of table control,
    *   Sets EBELN field on 3rd row of TC to not be an input field!
        LOOP AT SCREEN.
          IF ld_line EQ 3.
            IF screen-name EQ 'ZTC_EKKO-EBELN'.
              screen-input = 0.
              MODIFY SCREEN.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMODULE.                 " populate_screen  OUTPUT
    reward  points if it is usefull .....
    Girish

  • Execute Button in table control

    Hi All,
       can any one tell me how to insert the execute button in the table control because my requirement is for every row in the table control i have to use the execute button to call and execute custom program in the background.
    Thanks
    Prince

    Hi ,
         Only one user-command is enough to handle table control entries.To identify in which line of table control, the execute button is clicked, Use the following calculation.
    Data:v_line type i.
    CASE ok_code.
    WHEN 'EXE'.
    Get cursor line v_line.
    v_index = tc-top_line + v_line - 1.  -
    >  TC - Table control name
    Read table it_ekpo index v_index.
    ENDCASE.

  • Reg:How to delete the column in table control also from database table.

    Hi Experts,
    Once again thank u all for giving the responses.
    one more doubt is how to delete the columns of table control and also the record shold delete from ztable.
    With Regards,
    Saroja.P.

    Hi,
    If you want to delete the rows in the table control and simultaneously delete it from the database table, then you can implement a 'DELETE' functionality specific to your table control. Have a MARK field (you will find that in the screen attributes of the table control -> give a name for the MARK field, you will find an additional MARK column at the beginning of your table control). You can check whatever rows you want to delete from the table control, call the delete module.
    "This portion of code inside the LOOP...ENDLOOP.
    IF sy-ucomm eq 'F_DELETE'.
       gt_itab2-check = mark.  " Store the MARK field status into your internal table's correspoding field 'check'
      MODIFY gt_itab INDEX tabcontrol-current_line.
    ENDIF.
    iF sy-ucomm eq 'DELETE1'.
      DELETE gt_itab WHERE check eq 'X'. "Your internal table does not have rows that you want to delete
    ENDIF.
    Now you can modify your database table using the MODIFY statement.
    MODIFY ZDB FROM TABLE gt_itab.

  • How to delete the row in table control with respect to one field in module pool programming?

    Hi,
    Can I know the way to delete the row in table control with respect to one field in module pool programming
    Regards
    Darshan MS

    HI,
    I want to delete the row after the display of table control. I have created push button as delete row. If I click on this push button, the selected row should get deleted.
    I have written this code,
    module USER_COMMAND_9000 input.
    DATA OK_CODE TYPE SY-UCOMM.
    OK_CODE = SY-UCOMM.
    CASE OK_CODE.
         WHEN 'DELETE'.
            LOOP AT lt_source INTO ls_source WHERE mark = 'X'.
                APPEND LS_SOURCE TO LT_RESTORE.
                DELETE TABLE LT_SOURCE FROM LS_SOURCE.
                SOURCE-LINES = SOURCE-LINES - 1.
            ENDLOOP.
    But I'm unable to delete the selected rows, It is getting deleted the last rows eventhough I select the other row.
    So I thought of doing with respect to the field.

  • ISSUE IN THE TABLE CONTROL

    HAI FRIENDS,
    I HAVE DISPLAYED THE VALUES IN THE TABLE CONTROL
    I HAVE DEFINED 'CHECK'  FOR  SELECTING  THE FIELDS OF TABLE CONTROL
    THE ISSUE STARTS HERE
    WHEN I CHECK TOP FIELDS OF TABLE CONTROL
    THEN SCROLLED  VERTICALLY, THE TABLE CONTROL TO SELECT I.E CHECK THE
    BOTTOM FIELDS OF TABLE CONTROL.
    THE TOP FIELDS WATEVER  CHECK  WHERE CHECKS DISPAPEARS FOR TOP FIELDS  .
    BY THIS  I UNABLE TO SELECT THE FIELDS OF TABLE.
    PLZ HELP ME URGENTLY NEEDED.
    MY MONDAY I NEEDED

    You use an internal table for values in table control..
    One of the fields( very first field) in that itab is used for check - uncheck..
    u have make it 'X' when u click any row...
    I think this might be the problem in ur case.. when u scroll PAI starts... in that PAI check the value of check box for that particular field...
    Regards
    Prax

  • How to populate data in table control  .

    hi all,
    i put matnr no. in screen no. 103
    validation is done at that screen only.
    now when i want to modify dat record
    when i put matnr no. at screen 103
    so how i will get all  data of dat number to table control screen.

    Hi Darshan,
       Here is a detailed description of how to update data in table controll.
      Updating data in table control
    The ABAP language provides two mechanisms for loading the table control with data from the internal table and then storing the altered rows of the table control back to the internal table.
    Method 1: Read the internal table into the Table Control in the screenu2019s flow logic.  Used when the names of the Table Control fields are based on fields of the internal table.
    Method 2: Read the internal table into the Table Control in the module pool code. Used when the names of the Table Control fields are based on fields of the database table.
    Method 1 (table control fields = itab fields)
    In the flow logic we can read an internal table using the LOOP statement. Define the reference to the relevant able control by specifying WITH CONTROL <ctrl>
    Determine which table entry is to be read by specifying CURSOR <ctrl>-CURRENT_LINE.
    After the read operation the field contents are placed in the header line of the internal table. If the fields in the table control have the same name as the internal they will be filled automatically. Otherwise we need to write a module to transfer the internal table fields to the screen fields.
    We must reflect any changes the user makes to the fields of the table control in the internal table otherwise they will not appear when the screen is redisplayed after PBO processing, (eg, after the user presses Enter or scrolls) However, this processing should be performed only if changes have actually been made to the screen fields of the table control (hence the use of the ON REQUEST)
    PROCESS BEFORE OUTPUT.
    LOOP AT ITAB_REG WITH CONTROL TCREG
    CURSOR TCREG-CURRENT_LINE.
    ENDLOOP.
    PROCESS AFTER INPUT.
    LOOP AT ITAB_REG.
    MODULE MODIFY_ITAB_REG.
    ENDLOOP.
    MODULE MODIFY_ITAB_REG INPUT.
    MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
    ENDMODULE.
    Method 2 (table control fields = dict. fields)
    If using a LOOP statement without an internal table in the flow logic, we must read the data in a PBO module which is called each time the loop is processed.
    Since, in this case, the system cannot determine the number of internal table entries itself, we must use the EXIT FROM STEP-LOOP statement to ensure that no blank lines are displayed in the table control if there are no more corresponding entries in the internal table.
    PROCESS BEFORE OUTPUT.
    LOOP WITH CONTROL TCREG.
    MODULE READ_ITAB_REG.
    ENDLOOP.
    PROCESS AFTER INPUT.
    LOOP WITH CONTROL TCREG.
    CHAIN.
    FIELD: ITAB_REG-REG,
    ITAB_REG-DESC.
    MODULE MODIFY_ITAB_REG
    ON CHAIN-REQUEST.
    ENDCHAIN.
    ENDLOOP.
    MODULE READ_ITAB_REG OUTPUT.
    READ TABLE ITAB_REG INDEX TCREG-CURRENT_LINE.
    IF SY-SUBRC EQ 0.
    MOVE-CORRESPONDING ITAB_REREG TO TCREG.
    ELSE.
    EXIT FROM STEP-LOOP.
    ENDIF.
    ENDMODULE.
    MODULE MODIFY_ITAB_REG INPUT.
    MOVE-CORRESPONDING TCREG TO ITAB_REG.
    MODIFY ITAB_REG INDEX
    TCREG-CURRENT_LINE.
    ENDMODULE.
    Updating the internal table
    Method 1
    PROCESS AFTER INPUT.
    LOOP AT ITAB_REG.
    CHAIN.
    FIELD: ITAB_REG-REG,
    ITAB_REG-DESC.
    MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
    ENDCHAIN.
    ENDLOOP.
    MODULE MODIFY_ITAB_REG INPUT.
    ITAB_REG-MARK = u2018Xu2019.
    MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
    ENDMODULE.
    Method 2
    PROCESS AFTER INPUT.
    LOOP WITH CONTROL TCREG.
    CHAIN.
    FIELD: TCREG-REG,
    TCREG-DESC.
    MODULE MODIFY_ITAB_REG ON CHAIN-REQUEST.
    ENDCHAIN.
    ENDLOOP.
    MODULE MODIFY_ITAB_REG INPUT.
    MOVE-CORRESPONDING TCREG TO ITAB_REG.
    ITAB_REG-MARK = u2018Xu2019.
    MODIFY ITAB_REG INDEX TCREG-CURRENT_LINE.
    ENDMODULE.
    Updating the database
    MODULE USER_COMMAND_100.
    CASE OK_CODE.
    WHEN u2018SAVEu2019.
    LOOP AT ITAB-REG.
    CHECK ITAB_REG-MARK = u2018Xu2019.
    MOVE-CORRESPONDING ITAB_REG TO TCREG.
    UPDATE TCREG.
    ENDLOOP.
    WHEN u2026
    u2026
    ENDCASE.
    ENDMODULE.
    Hope this will solve your problem.
    Regards,
    Pavan.
    Edited by: PAVAN CHANDRASEKHAR GANTI on Aug 3, 2009 12:48 PM

Maybe you are looking for

  • Two IPads one Account Problem with some apps

    I have my Ipad2 and Ipad mini.  For some reason when I try to download my upgrades from the apps Wow and Master FX, to my new Ipad Mini, I am asked to repurchase.  I wrote to the Developer who said to uninstall and reinstall but no luck.  I have been

  • Exception while starting server P6 (EPPM 8.3.2) on Weblogic Server 11gR1

    I am a single user for learning purpose. I am trying to install EPPM 8.3.2 on my lenovo Window 7, 32 Bit Laptop. - I have installed weblogic server, - Installed databse and - EPPM 8.3.2. Unfortunately I am getting error "Exception while starting serv

  • Images on Portal Report

    I have images stored in a table (stu_pic long raw). How can I select the image to show on a portal Sql based report?

  • Is Apple Not Going to Release an Unlocked Version of the iPhone 5 in the USA?

    I am wondering if Apple is simply not going to release an unlocked version of the iPhone 5 in the USA as we are already in November and no news have been released. If I purchase a no commitment iPhone 5 with Verizon, will it be unlocked for all the c

  • Unable to install Lion

    I have installed Lion on my macbook pro without issue but when I tried to install it on my (newer) iMac it keeps crashing after the install.  I have tried 3 separate installations including a complete new download of the installer.  Whenever I start