Alternate row Addition in ALV

HI friends,
    I have come across a situation where I have to sum the alternate rows for a column in ALV display.
Can somebody help me to resolve this problem..
Thanks in Advance
Regards,
Rajesh
Edited by: Rajesh Akarte on May 16, 2008 10:16 AM

Before displaying the internale table in ALV, can you add it ?
If yes..then apply this logic.
CLEAR W_FLAG.
LOOP AT ITAB.
IF W_FLAG IS INITIAL..
  W_SUM = ITAB-VALUE + W_SUM.
  W_FLAG = 'X'.
ELSE.
CLEAR W_FLAG.
ENDIF.
ENDLOOP.
And while displaying ALV, add a last record with this value.
Edited by: Swastik Bharati on May 16, 2008 10:28 AM

Similar Messages

  • How Alternate rows to be colored  in an ALV Grid report?

    How Alternate rows to be colored  in an ALV Grid report?

    hi,
    try this
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) TYPE c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE slis_layout_alv,
          gd_repid     LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-info_fieldname =      'LINE_COLOR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = gd_repid
          is_layout          = gd_layout
          it_fieldcat        = fieldcatalog[]
          i_save             = 'X'
        TABLES
          t_outtab           = it_ekko
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekko.
    *Populate field with color attributes
      LOOP AT it_ekko INTO wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
              i.e. wa_ekko-line_color = 'C410'
        ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
        IF ld_color = 8.
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
        MODIFY it_ekko FROM wa_ekko.
      ENDLOOP.
    ENDFORM.                    " DATA_RETRIEVAL

  • Row Select in ALV

    I have an alv that displays data from a few tables.
    If I select a row from teh ALV, then the following screen should display some of the fields of the row along with additional information..
    I understand that the ON_CLICK event should be used once the row is selected..However,  I would appreciate it if someone gave me more info on the same..
    Thanks!

    Hi,
    Tray this:
    <i>  DATA: lr_table  TYPE REF TO cl_salv_wd_table_lead_select,
                   lr_node  TYPE REF TO if_wd_context_node,
                   lv_field1 TYPE (field1 of your alv table ).
      lr_table ?= r_param.
      lr_node ?= wd_context->get_child_node( 'NODE_TABLE' ).
      CALL METHOD lr_node->get_attribute
        EXPORTING
          index = lr_table->IF_SALV_WD_TABLE_LEAD_SELECT~INDEX
          name  = 'FIELD1'
        IMPORTING
          value = lv_field1.
      </i>
    With this code, you will have the value of the field 1 of the selected row.

  • Track add row button in alv

    Hello
    I would like to track the code of add row button in alv grid. When user cliks add row in avl toolbar what is the code? Is there some PAI module calls in that moment ? I found something about slis_selfield and something like mc_fc_loc_insert_row. I have tried write a code:
    data button type ui_func.
    button = gr_alvgrid -> mc_fc_loc_insert_row.
    After that, in PAI module of screen where alv is, I have tried to read that button. But no results.
    Frankly speaking I don't know how to use that all. Can anybody tell me how.
    I will be gratefully.

    Hi Sri,
    I think there is no standard way for this.
    Maybe with java script.
    Actually the users do not need to save data before they get the additional lines, A refresh is enough.
    So maybe you should just define a button calling the refresh command and just name the button different.
    regards
    Cornelia

  • How to show alternate rows in different colors?

    How to show alternate rows in different colors?
    Thanks

    you should put these kind of stmt in the if condition for even row and odd row
    <xsl:attribute xdofo:ctx="block" name="background-color">yellow</xsl:attribute>
    this should help you
    Re: About highlight row
    http://blogs.oracle.com/xmlpublisher/2007/08/09
    http://garethroberts.blogspot.com/2007/09/bi-publisher-color-list-and-cell.html

  • How to get all rows in table to red using alternate rows properties option

    How to get all rows in table to red using alternate rows properties option

    Hi Khrisna,
    You can get all rows red by selecting the color red in the "Color" and "frequency" to 1 under the "Alternate Row/Column colors".
    I tried doing it and the colors freaked me out (all red) :-D
    Kindly tell me if im missing something.
    Regards,
    John Vincent

  • Using alternate rows with Spry Data Set

    Can anyone provide more information on how to implement alternate row colors with a Spry Data Set?  What I have done is:
    Create spry data set using HTML page as the data set
    The html page that displays the data set is:  <div spry:region="equipment">
    In the default.css page that is linked, I added the info in note #1 below
    When the page displays, no colors appear. Tried changing the colors and still no luck.  Is there another step to do?
    Note #1:
    within the default.css, the following are declared:
    #equipment odd {
    background-color: #CCC;
    #equipment even {
    background-color: “#F2F2F2;
    Note #2:
    Here is a link to see the actual pages referenced above.
    Any ideas? Getting frustrated!!  Thanks in advance for any advice.

    You are going to kick yourself, but, you haven't assigned any page element the ID #equipment. The region is called that but the table or the DIV does not have an idea and your selector matches nothing...

  • Scroll bar and alternate row color in Trinidad table

    I am using Jdeveloper 11g
    I have two question on tinidad table see below sample code
    *1)How to set scroll bar on table*
    *2)how to set different colors for alternate rows*
    <tr:form>
    <tr:panelGroupLayout>
    <tr:panelFormLayout inlineStyle="width:965px; height:512px; margin:50px;">
    <f:facet name="footer">
    <tr:table value="#{bindings.UserFavoriteVO.collectionModel}"
    var="row" rows="#{bindings.UserFavoriteVO.rangeSize}"
    binding="#{UserActionBean.table1}"
    emptyText="#{bindings.UserFavoriteVO.viewable ? 'No rows yet.' : 'Access Denied.'}"
    rowSelection="multiple" id="table"
    inlineStyle="border-width:none; outline-color:ActiveCaption; outline-style:groove; border-color:Navy; color:MenuText; font-size:medium;"
    horizontalGridVisible="true" verticalGridVisible="false">
    Thanks for all help
    Jaydeep

    Hi Sireesha,
    Thanks for reply.
    I forgot to mentioned that i already tried that option *(rowBandingInterval)*
    <tr:table value="#{bindings.UserFavoriteVO.collectionModel}"
    var="row" rows="#{bindings.UserFavoriteVO.rangeSize}"
    binding="#{UserActionBean.table1}"
    emptyText="#{bindings.UserFavoriteVO.viewable ? 'No rows yet.' : 'Access Denied.'}"
    rowSelection="multiple" id="table"
    inlineStyle="border-width:none; outline-color:ActiveCaption; outline-style:groove; border-color:Navy; color:MenuText; font-size:medium;"
    horizontalGridVisible="true" verticalGridVisible="false"
    rowBandingInterval="1">
    but no any success.
    *@ scroll* I found in Frank post it is related to ADF table .So i just want to ask will it be applicable to Trinidad table too.

  • Can we adjust ROW height in ALV report as like of Excel ?

    Dear all,
    Can we adjust ROW height in ALV report as like of Excel sheet ?
    Can we increase/decrease the row height in the output display ?
    How ?

    kps204020 wrote:
    Thanks a lot for your response.
    I've tried your proposal, but it has no affect. The report cells show all their content using as much lines as necessary for this.This is the default behaviour for HTML table data (tables and cells expand to fit their content).
    So I still have rows with lots of lines and rows with only a few lines mixed in my IR dependant on the cell content. Because some rows filling nearly the whole screen, it is difficult to get an overview with regard to adjacent rows.
    I'm using Application Express 4.1.1.00.23. with Theme 21. Scarlet and Firefox 17.0.1.Are all users using Firefox?
    Actually I'm working on my first APEX Solution for usage in my company and the customers demanding a solution for this topic . So I'm very keen to find a solution.
    I'm very much looking forward to your response.I've been involved with similar issues in the past. My first response is simple: Does this data have to be shown in the report? Can the offending column(s) be removed from the primary report? They will still be visible in the single row view, and the detail view if there is one.
    The second option is to create a detail view for the report with a structure that is better suited to the data involved, and make this the default view. (For an example of this, see the treatment of the PRODUCT_DESCRIPTION column in the detail view of the Products report in the Sample Database Application: click on the View Detail button on the Products page.)
    The third possibility is some kind of customization of the presentation of the data. This will involve using some combination of HTML/CSS/Dynamic Actions/Plug-ins/JavaScript that you may not be familiar with: do you have experience of these? To go down that route you need to describe in detail how you want to present the data, or what behaviour is required when the data is too long, and share an example of the report on apex.oracle.com that we can work with.

  • Alternate rows with different number of columns in JTable or similar

    Hi Guys,
    I have tried searching google and these forums, but have not been able to find what I am looking for.
    Looking for ideas, on how to do the following
    I have a swing application, that I would like to have alternate rows
    eg.
    1st row has 10 columns
    2nd row has 1 column, that expands all 10 columns of the 1st row
    and keeps alternating like this for the rest of the records in the table.
    Is there a special JTable that can do this for me, or has anyone had to do this before.
    Thanks,
    Mac

    an example of merging cells is here
    [http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples4.html]
    scroll down to 'Multi-Span Cell'
    run the program, highlight some cells, click combine.
    if that's the type of thing you're after, modify your code per what's in 'combine'
    note: the original code (now) produces a stack overflow error (don't know if it's been fixed in the above link),
    but if you get that error, in AttributiveCellTableModel's setDataVector( Vector newData, Vector columnNames )
    change
    setColumnIdentifiers(columnNames);
    to
    columnIdentifiers = columnNames;

  • Alternate Row Shading or Formatting

    Hello,
    I have a report in which I want to shade the backgroud color for alternate rows.  More specifically, I'm trying to do this for a group footer (the details are suppressed and the group footer is the most detailed level displayed).  When I do this, not every other line is shaded.  Sometimes it is three in a row, sometimes once, etc.  I'm assuming this is because groups with a $0 value are suppressed.  This is the formula I'm using:  
    if (recordnumber mod 2) > 0 then Color (238,238,238) else crwhite
    Any suggestions would be greatly appreciated.
    Thanks,
    Dan

    Try this
    //Place this formula in the  group header/footer section that you with to be shaded and only in that group
    Whileprintingrecords;
    global numbervar shading;
    shading := shading + 1
    ///place the following formula in the section expert for group footer/header you wish to shade
    Whileprintingrecords;
    global numbervar shading;
    if remainder(shading,2)=1 then Color (238,238,238) else crwhite

  • Alternate row different dynamic BGcolor

    I cannot find the way to handle the Dynamic BgColor
    change....
    Because in my calender report got 600 field each fields
    depend on the flag to change the Bgcolor...
    i found the lousy way is each field have to set a duplicate
    color field overlap the data fields(set transparent)...then the
    color field
    set in the property "Print when" qeury.Flg eq 1 then show
    color.....
    is it got anyway like the HTML + CFM to set every alternate
    row set the BgColor...?
    if dun have choose i need to use this lousy way...
    i Need helps...

    utardylan wrote:
    > THX FOR UR replyed Daverms...
    > Actually i also using such way to make it....
    > bcoz i have 600++ query.fields in my report....so it too
    tedious to use this
    > way...
    >
    > So i'm finding the easy way to set it...
    >
    > but anyway thanks for ur reply
    >
    assuming you want to alternate 2 colours of rows returned by
    your query:
    <cfoutput query="yourquery">
    <table>
    <cfif yourquery.currentrow MOD 2 is 1>
    <cfset bgc = "##cccccc">
    <cfelse>
    <cfset bgc = "">
    </cfif>
    <tr style="background-color:#bgc#;">
    <td></td>
    <td>...
    </tr>
    </cfoutput>
    </table>
    Azadi Saryev
    Sabai-dee.com
    Vientiane, Laos
    http://www.sabai-dee.com

  • Can we hide the lines between the columns and rows of an alv in wd abap

    HI all ,
      I know that we can colour cell/column/row in an alv in wd abap.
       but, can we hide the lines between the columns and rows of an alv in wd abap.
         i have checked this link [hiding lines b/n rows and columns of an  alv|http://help.sap.com/saphelp_nw04/helpdata/en/91/e7eb40c4f8712ae10000000a155106/content.htm]
         but didn't  understand, can please anybody provide some example or any material..? it will be very helpful.
                                                                         THANK  YOU.
    Edited by: arfat111 on Feb 15, 2010 7:05 AM

    Code some like this in the WDDOINIT method of your view which defines the ALV component as used component.
    instansiate the ALV component
    data lo_cmp_usage type ref to if_wd_component_usage.
    lo_cmp_usage = wd_this->wd_cpuse_usage_alv().
    if lo_cmp_usage->has_active_component() is initial.
       lo_cmp_usage->create_component().
    endif.
    data lo_interfacecontroller type ref to iwci_salv_wd_table.
    lo_interfacecontroller = wd_this->wd_cpifc_usage_alv().
    data lo_value type ref to cl_salv_wd_config_table.
    lo_value = lo_interfacecontroller->get_model().
    hide the grid lines
    lo_value->if_salv_wd_table_settings~SET_GRID_MODE( value = '01' ).
    Thanks,
    Abhishek

  • How to shade alternate rows in deski

    Hi all,
    I am new to business objects. I have a requirement from the client that I need to differentiate the alternate rows by different shadings.
    Can anyone help me out.
    Thanks & Regards,
    BO

    larryc wrote:
    Yes... The value of LineShading is 1.00 for every row...
    Something is strange, then. I use this Code:
    =Mod(LineNumber() , 2)
    all the time, and it should work okay. Not to beat a dead horse, but are you absolutely sure that's the calculation that you are doing?
    If Linenumber() is working, then the Mod() function should be fine. But here's an alternate calculation you can try...
    Code:
    =If (Even(LineNumber())) Then 1 else 0
    That should also give you alternating rows, based on whether the Line Number value is even or not. Perhaps give that a try...
    All the best,
    Praveen

  • Change  row color on alv

    hi
    how can i change row color on alv.

    Hi
    thanks your answer  Uday Gubbala         
    i was examinated this link  [https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapWebDynproALV-ChangeCellColourbasedonContent]
    but i don't  do   this row  wd_this->m_alv_model = lo_value. error message : m_alv_model unknow.
    and this sample change column color but i want to row
    Thanks.

Maybe you are looking for