Skip to Content


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.


* Table definition table
LOOP AT <f_tab> INTO l_tabdef.
* Table line Types
  LOOP AT l_tabdeftltype INTO l_ltypes.
    IF  l_ltypeslinetype = ‘%C1’.                                                               “Name of the tempalate line
      LOOP AT l_ltypestcolinfo INTO l_colinfo.
        IF sytabix = ‘2’.                                                                                 “If we reach the third cell then update the color parameters.
* Background color and borders for that cell
          LOOP AT l_colinfoborders INTO l_border.
            l_borderfillcolorused = ‘X’.                         
            l_bordercfillcolorcolor = ‘X’.
“Assign the color code here , can passs the variable that you get from driver program,
“as here it is gv_color.                       
            l_bordercfillcolorxred = ‘FF’.                                                  “gv_color1.     (Variables from driver program)     
            l_bordercfillcolorxgreen = ’00’.                                               “gv_color2.
            l_bordercfillcolorxblue = ’11’.                                                 “gv_color3.   
            MODIFY l_colinfoborders FROM l_border.
        MODIFY l_ltypestcolinfo FROM l_colinfo.
    MODIFY l_tabdeftltype FROM l_ltypes.
  MODIFY <f_tab> FROM l_tabdef.

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.


To report this post you need to login first.


You must be Logged on to comment or reply to a post.

Leave a Reply