cancel
Showing results for 
Search instead for 
Did you mean: 

How to set background color of cell to red

Former Member
0 Kudos

Hi Guys,

until now I could change the font color of the text inside a cell to red by using the following code:

CONCATENATE '<font color="red">' ls_ci_ti_compare-ci_value '</font>' INTO html_string.

CREATE OBJECT html_bee.
html_bee
->add( html = html_string ).
p_replacement_bee
= html_bee.

Can anybody tell me how is the code to set the background colour to red? I need really a code example how to

fill the variable html_string?

Thank you,

Oliver

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Oliver,

Great to hear you once more, i guess now you know how to color cell text with the help of threadhttp://scn.sap.com/message/14295856 , for background cell color just prepare the HTML code as below,

CASE p_column_key.

          WHEN 'DESCRIPTION'. "// Field (or Colunm) name

                    READ TABLE me->gt_result INTO ls_order INDEX p_row_index.

                    IF sy-subrc NE 0.

                              EXIT."==============>>>

                    ENDIF.

                    ASSIGN COMPONENT p_column_key OF STRUCTURE ls_order TO <col>.

                    IF sy-subrc = 0.

                              wf_text = <col>."// Field value

                    ENDIF.

                    CASE wf_text. "// Field value

                    WHEN 'TESTING'. "// Field value

                    CONCATENATE '<span style="background-color:#00FF00">' wf_text '</span>'

                    INTO html_str.     "// Setting background color for particular column

                    CREATE OBJECT html_bee.

                    html_bee->add( html = html_str ).

                    p_replacement_bee = html_bee.

                    WHEN 'TEST'. "// Field value

                    CONCATENATE '<span style="background-color:YELLOW">' wf_text '</span>'

                    INTO html_str.    "// Setting background color for particular column

                    CREATE OBJECT html_bee.

                    html_bee->add( html = html_str ).

                    p_replacement_bee = html_bee.

                    WHEN 'TEST123'. "// Field value

                    CONCATENATE '<span style="background-color:RED">' wf_text '</span>'

                    INTO html_str.    "// Setting background color for particular column

                    CREATE OBJECT html_bee.

                    html_bee->add( html = html_str ).

                    p_replacement_bee = html_bee.

                    WHEN 'HI'. "// Field value

                    CONCATENATE '<span style="background-color:PINK">' wf_text '</span>'

                    INTO html_str.   "// Setting background color for particular column

                    CREATE OBJECT html_bee.

                    html_bee->add( html = html_str ).

                    p_replacement_bee = html_bee.

                    ENDCASE.

ENDCASE.

NOTE: The table GT_RESULT will contain the table view records.

           Be careful WHEN 'DESCRIPTION' always taking the search result’s field

           name and WF_TEXT = 'TESTING' is taking the search result’s field value (in my

           case).

Please feel free to query again

Regards,

Vishal.

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Vishal,

Is any way how to make the row with color not just one cell.

Thanks

former_member210661
Active Contributor
0 Kudos

Hi Gezim Nesimi,

Read this blog you will come to know...

Thanks & Regards,

Srinivas.

kumar5
Active Contributor
0 Kudos

It will look like :-

concatenate '<span style="background-color:#FFFF00;font-weight:bold">' LV_DATA

         '</span>' into html_str.

        create object html_bee.

        html_bee->add( html = html_str ).

For more info  Check below threads:

http://scn.sap.com/thread/3164090

http://scn.sap.com/thread/2128064

http://scn.sap.com/message/11135446

Thanks

Kumar Gaurav.