Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
5,848

Hi,

Often there is need to dynamic color a particular cell of a template in smartform.
This can be done by writing few lines of code in smartform.

In the template '%TEMPLATE1' ,  I need to color the second cell , dynamically through the color code that I pass  form driver program.

You can upload the smartform from attachment, if required.

The code written in 'Code1' program line are as :

   FIELD-SYMBOLS: <f_tab> TYPE tsftabdef.       " Table - Actual SF definitions


DATA: l_tabdef  TYPE ssftabdef,     " Work Area for the Table
      t_ltypes  TYPE tsfltype,      " Table - Line types
      l_ltypes  TYPE ssfltype,      " Work Area for the table
      t_colinfo TYPE tsfcolinfo,    " Table - Columns
      l_colinfo TYPE ssfcolinfo,    " Work area for the table
      t_border  TYPE tsfctaba,      " Tables - Borders
      l_border  TYPE ssfctaba.      " Work Area for the border


* Assign the table definition to the table field symbol
* Assiging by '(Program)Tablename' will give as the actual table
*   which contains the defination of the Smartform. We will change
*   respective table background color.

ASSIGN ('(SAPLSTXBC)TABDEFS') TO <f_tab>.

* Table definition table
LOOP AT <f_tab> INTO l_tabdef.
* Table line Types
  LOOP AT l_tabdef-tltype INTO l_ltypes.
    IF  l_ltypes-linetype = '%C1'.                                                               "Name of the tempalate line
      LOOP AT l_ltypes-tcolinfo INTO l_colinfo.
        IF sy-tabix = '2'.                                                                                 "If we reach the third cell then update the color parameters.
* Background color and borders for that cell
          LOOP AT l_colinfo-borders INTO l_border.
            l_border-fillcolor-used = 'X'.                         
            l_border-cfillcolor-color = 'X'.
"Assign the color code here , can passs the variable that you get from driver program,
"as here it is gv_color.                       
            l_border-cfillcolor-xred = 'FF'.                                                  "gv_color1.     (Variables from driver program)     
            l_border-cfillcolor-xgreen = '00'.                                               "gv_color2.
            l_border-cfillcolor-xblue = '11'.                                                 "gv_color3.   
            MODIFY l_colinfo-borders FROM l_border.
          ENDLOOP.
        ENDIF.
        MODIFY l_ltypes-tcolinfo FROM l_colinfo.
      ENDLOOP.
    ENDIF.
    MODIFY l_tabdef-tltype FROM l_ltypes.
  ENDLOOP.
  MODIFY <f_tab> FROM l_tabdef.
ENDLOOP.

The basis logic is to modify the 'cfillcolor' structure.

We need to change the value in the structure as :

The flow is  <f_tab> (which is having the defination of all the templates) ---> then goto line type ----> then colinfo ---> then borders --->cfillcolor structure.

5 Comments
Labels in this area