ALV rows coloring based on condition

Hai ,
I want Color the rows in the list based on some condition ..
Hope to get the helpful suggestion s on this asap
regards,

Hi shishupalreddy,
1. Not only the full row color,
  we can also manipulate the color in each cell,
  based upon conditions.
2.
IMPORTANT THINGS
a. Extra field in internal table
clr TYPE slis_t_specialcol_alv,
(this field will contain the colour codes)
b. assign fieldname to alv layout
alvly-coltab_fieldname = 'CLR'
c. work area for colour
DATA : clrwa TYPE slis_specialcol_alv.
d. Populating the color
Once again
Loop at ITAB.
*********logic
if itab-field < 0 "---negative
clrwa-fieldname = 'FIELDNAME'. "<--- FIELDNAME FOR COLOR
clrwa-color-col = 6. <------- COLOUR 0-9
APPEND clrwa TO itab-clr.
MODIFY ITAB.
endif.
ENDLOOP.
5. just copy paste in new program
6.
REPORT abc .
NECESSARY / MUST
TYPE-POOLS : slis.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
ITAB DECLARATION
DATA : prg TYPE sy-repid.
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : clname(3) TYPE c,
clr TYPE slis_t_specialcol_alv,
END OF itab.
DATA : clrwa TYPE slis_specialcol_alv.
PARAMETERS : a TYPE c.
DATA : flname TYPE slis_fieldname.
SELECT
START-OF-SELECTION.
SELECT * FROM t001
INTO CORRESPONDING FIELDS OF TABLE itab..
LOOP AT itab..
IF SY-TABIX <= 5.
itab-clname = 'C50'.
ELSE.
itab-clname = 'C30'.
ENDIF.
MODIFY itab.
ENDLOOP.
LOOP AT ITAB.
check itab-bukrs = '1000'
clrwa-fieldname = 'BUTXT'.
clrwa-color-col = 6.
APPEND clrwa TO itab-clr.
MODIFY ITAB.
clrwa-fieldname = 'LAND1'.
clrwa-color-col = 4.
APPEND clrwa TO itab-clr.
MODIFY ITAB.
ENDLOOP.
prg = sy-repid.
flname = 'CLNAME'.
alvly-info_fieldname = 'CLNAME'.
alvly-coltab_fieldname = 'CLR'.
LOOP AT ITAB.
if sy-tabix = 3.
clrwa-fieldname = 'BUTXT'.
clrwa-color-col = 6.
APPEND clrwa TO itab-clr.
MODIFY ITAB.
clrwa-fieldname = 'LAND1'.
clrwa-color-col = 1.
APPEND clrwa TO itab-clr.
MODIFY ITAB.
endif.
ENDLOOP
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = prg
i_internal_tabname = 'ITAB'
i_inclname = prg
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
minimum
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
extra
sy-uname = 'XYZAB'.
prg = sy-repid.
Excluding
DATA : excl TYPE slis_t_extab.
DATA : exclwa TYPE slis_extab.
exclwa = '&OUP'.
APPEND exclwa TO excl.
exclwa = '&ODN'.
APPEND exclwa TO excl.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid
is_layout = alvly
i_callback_user_command = 'ITAB_USER_COMMAND'
it_excluding =
excl
i_save = 'A'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form itab_user_command
text
-->WHATCOMM text
-->WHATROW text
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
BREAK-POINT.
ENDFORM. "itab_user_command
regards,
amit m.

Similar Messages

  • Change the row colors based on column values in MOSS 2007.

    Hi Team,
    I am using MOSS 2007 environment. In that I am having one SharePoint list. In that list based on column values rows colors need to change.
    Kindly help me anyone on this.
    Thanks,
    Ashok

    Hi Ashok,
    Please follow the below link:
    http://www.contentmaster.com/sharepoint-2010/conditional-formatting-of-list-views-for-sharepoint-2010-changing-the-font-colour/
    http://sharepoint.stackexchange.com/questions/7478/highlight-row-color-based-on-field-values-in-sharepoint-2010-list-view
    Best Regards,
    Brij K

  • Color in ALV grid output based on condition

    Hi,
    I have generated a ALV Grid output.
    I have a internal table ITAB1. It has 2 fields - field1 and field2.
    Now, my requirement is if field1 is 'X', the row should be colored in RED, else if field1 is 'Y', the row should be colored in GREEN.
    How can it be done?
    Thanks,
    Shivaa.........

    Hi,
    add another field in the internal table with the type of char04.
    use the code given below....
    DATA : begin of itab occurs 0,
                  field1(10) type c,
                  field2(10) type c,
                  color(4) type c,
              end of itab.
    " fetch records in itab..
    loop at itab.
      if itab-field1 = 'X'.
          itab-color = 'C700'.         " Trial and error to get the color you want...
      elseif itab-field1 = 'Y'.
          itab-color = 'C300'.         " Trial and error to get the color you want...
      endif.
    endloop.
      fs_fcat-fieldname = 'FIELD1'.
      fs_fcat-col_pos = 1.
      fs_fcat-coltext = 'FIRST FIELD'.
      APPEND fs_fcat TO t_fcat.
      fs_fcat-fieldname = 'FIELD2'.
      fs_fcat-col_pos = 2.
      fs_fcat-coltext = 'SECOND FIELD'.
      APPEND fs_fcat TO t_fcat.
        fs_layo-sel_mode = 'A'.
        fs_layo-INFO_FNAME = 'COLOR'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_callback_program    = sy_cprog
          is_layout_lvc         = fs_layo
          it_fieldcat_lvc       = t_fcat
        TABLES
          t_outtab              = itab
        EXCEPTIONS
          program_error         = 1
          OTHERS                = 2.
    This resolves you issue....
    Cheers,
    Siddarth

  • JTable row color based on a certain value

    Can anyone please show some code on how
    I can change the background color of an entire
    row based on a string value from the first column ?
    Every time that the first column contains the
    string "TOTAL", I want the entire row to have
    another background color.
    Thanks a lot

    Override getTableCellRendererComponent in Table celll renderer.
    public class MyTableCellRenderer extends DefaultTableCellRenderer
    public MyTableCellRenderer()
    super();
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
    Component comp = super.getTableCellRendererComponent(table, value, isSelected,
    hasFocus, row, column);
              ((JLabel)comp).setOpaque(true);
    if(value.equals("TOTAL")
    comp.setBackGround(color);
    else
    set whatever the default background color

  • [php+mysql] nextensio list: how to change row color based on field content?

    Hi all
    I have a nextensio list on a page.
    is there a way to change the background color of a whore row based on
    a specific field content?
    example I have a field containing the values 0 or 1.
    If the field content is 1 the row background color should be RED.
    ANy suggestion?
    TIA in advance.
    tony

    DataBoundAPI's you can refer to achieve this.
    Search for OLD threads also. Here are some links:
    Can we colour the rows in the column of a table
    Advanced table row font color- result based change.
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • Changing row color according to condition statement

    Hi,
    Is there a way that I can color a row or field in a report according to a condition? For example, can I color red all rows where an amount is over 1,000? Or can I just highlight the field that answers to the criteria?
    Thank you.
    Leah

    Hi,
    The row cannot be colored
    just the cell that match the criteria
    tamir

  • Row Color Based on DB Field

    Hi there. 1st, thanks for taking time to read this and hopefully help.
    I have been given this website to work on an its pretty much done in java. Unfortunately I know very little about Java. Over the weeks I have been learning more and more, however I have been asked to do something and I not sure the track that I need to go.
    Here is my code
    <%
    for (int r=0; r<vW.size(); r++) {
    W = new Workorder();
    W = (Workorder) vW.elementAt(r);
    %>
    <tr valign="top" class="WOList">
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getInvoiceNum());%>
    </div></td>
    <td valign="top" class="WOList"><% out.println(W.getSWhoUser());%></td>
    <td valign="top" class="WOList"><% out.println(W.getLocationName());%></td>
    <td valign="top" class="WOList"><% out.println(W.getProblemDescription());%></td>
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getSTech());%>
    </div></td>
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getOpenCloseDate());%>
    </div></td>
    </tr>
    <%
    The variable W.getStech needs to be output with a different color row for each Tech. The Tech may have multiple rows and it will vary from day to day.
    This is the printable copy of our work orders.
    Can someone assist me in trying to solve this, if not at least point me in the right direction.
    Thank you.

    Hey Everyone. I am still having sooo much trouble on this. I was told (and I need to find a way) to do this without altering the database.
    Even if I can't do a color, even having a bold line seperating the people's work orders.
    Any help would greatly be appreciated.
    I did find this javascript code, and I'm not sure if I could incoporate that into the database.
    Heres' the JS
    <script type="text/javascript">
    <!--
    var table = document.getElementById("user");
    var tbody = table.getElementsByTagName("tbody")[0];
    var rows = tbody.getElementsByTagName("tr");
    // add event handlers so rows light up and are clickable
    for (i=0; i < rows.length; i++) {
    var value = rows.getElementsByTagName("td")[0].firstChild.nodeValue;
    if (value == 'mraible') {
    rows[i].style.backgroundColor = "red";
    //-->
    </script>
    Now here's the actual java work order
    </tr>
              <%
                   for (int r=0; r<vW.size(); r++) {
                        W = new Workorder();
                        W = (Workorder) vW.elementAt(r);
              %>
    <tr valign="top" class="WOList">
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getInvoiceNum());%>
    </div></td>
    <td valign="top" class="WOList"><% out.println(W.getSWhoUser());%></td>
    <td valign="top" class="WOList"><% out.println(W.getLocationName());%></td>
    <td valign="top" class="WOList"><% out.println(W.getProblemDescription());%></td>
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getSTech());%>
    </div></td>
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getSDateRequested());%>
    </div></td>
    </tr>
              <%
              %>
    </table></td>
    Thanks Again !!

  • Setting JTable Background Row Color based on cell Value

    I am new to Java and JDeveloper (so bear with me). I have managed to create a Swing form using BC4J (Jdev 10g preview) which contains a scrollpane with a view object represented as a table. I would like to be able to color the rows that are displayed within the table differently depending on the value of a cell/column within the row. Its not obvious to me from the property inspector how to do this - I assume it is possible as all the other bells and whistles appear to be in place.
    Thanks in advance
    Simon

    Simon,
    in Swing this is not done through properties but a custom cell renderer. You can check the Swing tutorial on http://java.sun.com for how to modify the default behavior of a JTable component. A very good book to learn Swing is "Java Swing" from O'Reilly (ISBN 0-596-00408-7).
    ADF JClient uses Swing components and therefore everything you can do in Swing you can do with JClient.
    Frank

  • Row colored based on db field

    Hi there. 1st, thanks for taking time to read this and hopefully help.
    I have been given this website to work on an its pretty much done in java. Unfortunately I know very little about Java. Over the weeks I have been learning more and more, however I have been asked to do something and I not sure the track that I need to go.
    Here is my code
         <%
                   for (int r=0; r<vW.size(); r++) {
                        W = new Workorder();
                        W = (Workorder) vW.elementAt(r);
              %>
    <tr valign="top" class="WOList">
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getInvoiceNum());%>
    </div></td>
    <td valign="top" class="WOList"><% out.println(W.getSWhoUser());%></td>
    <td valign="top" class="WOList"><% out.println(W.getLocationName());%></td>
    <td valign="top" class="WOList"><% out.println(W.getProblemDescription());%></td>
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getSTech());%>
    </div></td>
    <td valign="top" class="WOList"><div align="center">
    <% out.println(W.getOpenCloseDate());%>
    </div></td>
    </tr>
              <%
    The variable W.getStech needs to be output with a different color row for each Tech. The Tech may have multiple rows and it will vary from day to day.
    Can someone assist me in trying to solve this, if not at least point me in the right direction.
    Thank you.

    You problem related to jsp.
    Oh I do not want to get into jsp now so post it here to get better help http://forums.sun.com/forum.jspa?forumID=45
    Before doing so, Why you are doing so
    W = new Workorder();
    W = (Workorder) vW.elementAt(r);
    instead of
    Workorder W = (Workorder) vW.elementAt(r);
    then you for loop does not seems to have an end clause "}"
    the how did you created vW which is a list of WorkOrder? where did you get the list from ?
    if you want each row (<tr>) needs a different color, then you need need to make the workOrder has a color attribute and in the <tr> you
    do
    <tr valign="top" bgcolor=<% out.println(W.getRowColor());%>">
    or you can put a java list which contains different html color standard
    Just a start for you
    Hope this could help

  • Alternate row color for table question

    I'm alternating the row color on a table, and if I have a
    <a href> in
    the table, the background behind the <a href> isn't the
    same as the row
    color based on:
    <tr bgcolor="###iif(currentrow mod
    2,de('ffffff'),de('efefef'))#">
    Is there a way to have the CSS that formats the <a
    href> change at the
    same time as the background color for the row??

    How about a way to do it without having to learn something
    else (like a
    framework??)
    Anyone done something like what I'm looking to do? Just
    change the <a href>
    formatting to go along with the inline iif shown below?
    <tr bgcolor="###iif(currentrow mod
    2,de('ffffff'),de('efefef'))#">
    Steve
    "Daverms" <[email protected]> wrote in
    message
    news:fgn5vi$83b$[email protected]..
    > Hi,
    >
    > Try implementing the "JQuery" framework in your
    application. It really
    > minimizes the coding time and enables you to concentrate
    on development
    > alone.
    >
    > (Try Googling, You can find more JQuery solutions for
    this TR alternative
    > bgcolor issues, ).
    >
    >
    >
    >

  • Change Column Header / Column Background color based on a value in a specific row in the same column

    SSRS 2012
    Dataset (40 columns) including the first 3 rows for Report layout configuration (eg: the <second> row specifies the column background color).
    Starting from the 4th row, the dataset contains data to be displayed.
    I would like to change the background color of the ColumnHeader/Column based on the value in the same column in the <second> row.
    How can I accomplish the this requirement? (this must be applied for all the columns)
    Thanks

    Hi Fasttrck2,
    Per my understanding that you want to specify the background color of all the columns/column header based on the value in one special column of the special row, right?
    I have tested on my local environment and you can add expression to condition show the background color in the columns properties or the column header properties.
    Details information below for your reference:
    Specify the background color in the Column header: you can select the entire column header row and in the properties add expression in the Background color :
    If you want to specify the background color for the entire column, you can select the entire column and add the expression, repeat to add background color for other columns.
    If you want to specify the background color based on the value in the specific columns and row, you can create an hidden parameter to get the list of values from the  specific column, specify the Available values and default values by select "Get
    values from a query", finally using the expression as below to get the specific value you want:
    Expression(Backgroud Color):
    =IIF(Parameters!Para.Value(1)="1221","red","yellow")
    If your problem still exists, please try to provide some smaple data of the report and also the snapshot of the report structure to help us more effective to provide an solution.
    Any problem, please feel free to ask.
    Regards
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • Conditional Row Colors

    Hello everyone,
    I have a column in a table that can have 3 different values. I'd like the font on the row in the APEX Report to change based on the value. I have the following case statement:
    CASE
    WHEN "PRIORITY" = 1
    THEN '<span style="color:red:'
    || 'font-weight:bold;font-size:14">'
    || "PRIORITY"
    || '</span>'
    WHEN "PRIORITY" = 2
    THEN '<span style="color:orange:'
    || 'font-weight:bold;font-size:14">'
    || "PRIORITY"
    || '</span>'
    WHEN "PRIORITY" = 3
    THEN '<span style="color:black:'
    || 'font-weight:bold;font-size:14">'
    || "PRIORITY"
    || '</span>'
    ELSE "PRIORITY"
    END
    I'm getting the error "Columns that use HTML need alias names".
    I've tried to add "PRIORITY as "Priority" above the case statement, in the main select statement, but then it gives me "ORA-00923: FROM keyword not found where expected".
    I basically want the whole row to be colored based on the priority. The column name is supposed to be "Priority".
    If anyone can help, or knows of a better way to do this, let me know!
    Thanks,
    Joe

    Hi,
    As long as you are not using the "Alternating Row Colors" report template, then there is an easier way. Go to Shared Components, Templates and click Create. Create a new Report template based on a copy of an existing template - perhaps the Standard report template. When created, click on the link for your new template to edit it. You will see four Column Template settings numbered 1, 2, 3 and 4. In the Column Template 1, you will see the currently defined template for each TD in a row. Copy this into the other three Column Template settings. Now, in the Condition settings for 1, 2 and 3, select "Use Based on PL/SQL Expression". In the Column Template 1 Expression, enter the following:
    #PRIORITY# = 1Repeat that, using the correct PRIORITY values, for the Expression settings for 2 and 3. Leave Column Template 4's conditions empty (this makes it unconditional).
    Now, in each Column Template, you can apply your style to the TD tag according to the condition you have set.
    Finally, on your page's report, set it to use your new template.
    Andy

  • How to give color to the display of keyfigure based on condition using exception.

    Dear Friends.
       I am trying to color "BAD3" in exception based on condition but my problem is in exception I can have only formula variable to compare the value, How to assign a value to formula variable in BEx Query designer.
    What I am trying to do is :
       in Query designer :
       I have PO Quantity and Delivered Quantity. 
      if PO Qnantity > Delivered Quantity
        then Delivered Quantity field should be colored as "BAD3" in exception.
    but here proble is in exception
      I have alert level , operator, and  value fields for Delivered Quantity keyfigure ( Under definition tab - Exception is defined on = Delivered Quantity ).
    but for value field I dont have PO Quantity for that I have to supply one formula variable,
    When I created a forumula  and did this way
    FV_PO_QUANTITY = PO_QUANTITY formula editor throws errors. I dont understand How to assign a value of key figure to formula variable and use it in EXceptions.
    Please help me How I can solve my problem
    I will greatly appreciate your any help.
    Thanking you
    Regards
    Naim

    Thank you so much for your replies,
      I did following way and it helped me to solve my issues.
      I created one formula and under formula I use boolean < funtion to compare the values.
    like following way.
    ( 'PO Quantity' > 'Delivered Quantity' ) * ( FV_PO_QNT + PO_QUANTITY')
    here fv_po_qnt is formula variable I supply that variable to exception and since I have the value in it.. it compares with Delievered Quantity value and colored the perticular cell.
    Thanks again for your replies
    Regards
    Naim

  • Table Control - Input Enabling/Diabling of Rows based on Condition.

    Hi,
    In the TC, I want to Input Enable/Disable the rows based on Conditions. The First row is input enabled always. But the other rows, (2nd onwards) need to be Input Enabled/Disabled based on some conditions. It is possible to make this working. Can you please provide me a suitable solution for this?
    Appreciate Your Help.
    Thanks,
    Kannan

    Hi Kannan...
    If we are talking about "Rows"...
    then identify based on some conditions the row numbers and in PBO...loop at screen with screen name..set thier input properties and modify screen (make them input only)
    If we are taking into consideration "columns"
    There is an internal structure COLS where we can identify column number of screen name ...or we can take except for one particular column..
    if some condition satisfied....
    loop at screen where screen-name <> "Column which is input'.
    Loop at screen...and make other columns display only.
    modify screen
    endif.
    Regards
    Byju

  • 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

  • How do i put 'photo library' and photo folders onto my pc?

    A while ago I had over 6000 photos in camera, mostly screen shots. So i imported them and sorted them out into photos taken by the camera and screen shots, put them into different folders then put them onto my phone. So i have Camera Roll & Photo Str

  • Can't delete grayed-out DNS server addresses

    I want to replace two grayed-out DNS server addresses from the Network panel (under the DNS tab in "Advanced-"), to replace them with OpenDNS settings. But they can't be selected/deleted. How do I get around this problem?

  • Ios 6 update causing errors

    After updating my ipad 3 on Friday my ipad is not working properly. I can not access iMessage, it will not verify my appleID at all, my facebook app will not allow me to make a status update or read messages and the app store will not load. Safai wil

  • Email marked as read on outlook without actually reading

    Hi, When I get an email in outlook it shows as unread. Once the email is sent to my blackberry the status on outlook changes to read (even without me ever opening the email on outlook or the blackberry). How can I stop this? I did a lot of research b

  • Setting connection timeout

    Anyone know how to set a timeout for a HttpURLConnection? Thanks, Ross