Dynamic Background Colors in Smartforms

By | September 10, 2008 | Forms, Tricks | 13,674 | 3

We were having some specific background colors in our output generated by the SMartforms. This background colors are coming properly in the print-out. But, when we try to send them as FAX, we are getting the BLACK background whereever we have that background color.

I used Field-symbols to have an access of the table which stores the Smartforms definition. I replaced the background color with the White background.

Code Snippet for Dynamic Background Color

*&---------------------------------------------------------------------*
* This code will clear the specific background for specific conditions
*&---------------------------------------------------------------------*
* In line type TYPE1 under the MAIN_TABLE, we have two columns.
* Column 1 with RED background and border
* Column 2 with no background color and BLUE border
*
*
FIELD-SYMBOLS<f_tab> TYPE tsftabdef.    " Table - Actual SF definitions
*
DATAl_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
*  Line type TYPE1 from the table MAIN_TABLE
  LOOP AT l_tabdef-tltype INTO l_ltypes.
*
* Coloum information
*   Column1 (cell) of the TYPE1
    LOOP AT l_ltypes-tcolinfo INTO l_colinfo.
*
* Borders
*   Background color and borders for that cell
      LOOP AT l_colinfo-borders INTO l_border.
*
* Clearing the color parameters for the cell
        CLEARl_border-intensity,              " Intensity
        l_border-fillcolor-red,          " Red
        l_border-fillcolor-used,         " Color Used
        l_border-cfillcolor-color,       " Red color in Hexa
        l_border-cfillcolor-xred.        " Color used in Hexa
*
        MODIFY l_colinfo-borders FROM l_border.
      ENDLOOP.
*
      MODIFY l_ltypes-tcolinfo FROM l_colinfo.
    ENDLOOP.
*
    MODIFY l_tabdef-tltype FROM l_ltypes.
  ENDLOOP.
*
  MODIFY <f_tab> FROM l_tabdef.
ENDLOOP.

You can follow this link to have step-by-step explianation alongwith the Screenshots and SMartform XML file:
Dynamic Background Colors in Smartforms

This is one of my published WIKIes on SDN.

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

3 Comments

  • excellent one.
    how background colors be added in sapscript?

    regards,
    Buglu

  • Hello Buglu,

    You asked:
    how background colors be added in sapscript?

    We don't have capability to add colors in the sapscript.

    Regards,
    Naimesh Patel

  • Anonymous

    hi

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.