cancel
Showing results for 
Search instead for 
Did you mean: 

problem to set background color for configTable cell

Former Member
0 Kudos

Hi All,

I've a configTable displays some status fields, and I need to set yellow color when the status is in processing and green when finished and red when cancelled. I've searched the forum and decided to use iterator with method RENDER_CELL_START. Here are the steps that I've done.

Step 1: wrote a new class ZCL_ACTSTAT_ITERATOR implements interface IF_HTMLB_TABLEVIEW_ITERATOR.

this class has a private attribute ORDERS containing the search result internal table data, in the CONSTRUCTOR method I pass the search result to the attribute using the statement ME->ORDERS = ORDERS. Then in the method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START I check the p_column_key for the status fields and then get the status value and set p_style accordingly using the following statement:

CASE p_column_key.
    WHEN 'PREPAY_STATUS' OR 'DELVPLN_STATUS' OR 'DESIGN_STATUS'.
      READ TABLE me->orders 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>.
      ENDIF.
      IF wf_text = '00' OR wf_text = 'Initial'.
*        concatenate '<font color=""red"">' 
*         WF_TEXT '</font>' into html_str. 
*        create object html_bee.
*        html_bee->add( html = html_str ).
*        p_replacement_bee = html_bee.        "not work either
        p_style = 'celldesign:STANDARD'.
      ELSEIF wf_text = '10' OR wf_text = 'InProcessing'.
        p_style = 'celldesign:GOODVALUE_MEDIUM'.
      ELSEIF wf_text = '20' OR wf_text = 'Finished'.
        p_style = 'celldesign:GOODVALUE_LIGHT'.
*        p_style = 'background-color:#92D050'.
      ENDIF.
  ENDCASE.

Step 2: In the component controller ZL_ZACT_MYO_ORDERS_IMPL, create a public attribute GV_ITERATOR type ref to the class created in step 1 (ZCL_ACTSTAT_ITERATOR), then in the controller's DO_PREPARE_OUTPUT method, get the combined context data and convert them into internal table LT_ORDERS, then create the iterator GV_ITERATOR passing LT_ORDERS, after this step, the result data can be transfered into iterator class and then be used in the RENDER_CELL_START method.

The DO_PREPARE_OUTPUT method is like bellow:

lr_pro ?= me->typed_context->order->collection_wrapper->get_first( ).
    WHILE lr_pro is BOUND.
      lr_pro->get_properties( IMPORTING es_attributes = ls_order ).
      if ls_order is not initial.
        append ls_order to lt_order.
      endif.
      lr_pro ?= me->typed_context->order->collection_wrapper->GET_next( ).
    ENDWHILE.
    CREATE OBJECT lc_iterator
      EXPORTING
        orders = lt_order.
    me->GV_iterator = lc_iterator.

Step 3: in the .htm page, point iterator to controller's iterator

<chtmlb:configTable  id                    = "Table1"
                    table                 = "//ORDER/Table"
                    iterator              = "<%= controller->GV_ITERATOR %>"
                    ...
                     />

Step 4: in the GET method of status attributes in context node ORDER, do the translation to change the status code into status description

METHOD GET_PREPAY_STATUS 
    DATA: OLD_VALUE TYPE ZACT_STATU,
          LS_STATUS TYPE ZACT_STATUS_S.
    OLD_VALUE = VALUE.
    READ TABLE GT_STATUS INTO LS_STATUS WITH KEY STATUS = OLD_VALUE.   
    "Get status description from field domain definition
    IF SY-SUBRC = 0.
      VALUE = LS_STATUS-NAME.           "Show status description
    ENDIF.
ENDMETHOD.

I thought I could see the status fields change their styles for different status code. But it still refuse to work, although I can debug to see that p_style really set as I expect, so I think there must have something wrong after RENDER_CELL_START, but what is it?

Could anyone please help me sort it out or point out what's missing there or guide me the correct steps? Any post is greatly appreciated.

Thank you!

Jeff

Edited by: liu jinghui on Feb 9, 2012 6:37 PM

Accepted Solutions (1)

Accepted Solutions (1)

VishnAndr
Active Contributor
0 Kudos

Hi, Jeff.

Just don't want to cross post the same answer all over the forum. So I gave some inputs on the topic in this message: http://forums.sdn.sap.com/thread.jspa?messageID=11127647&#11127647

Hope this will help you.

Former Member
0 Kudos

This message was moderated.

Answers (0)