To bring dynamic color in smartform

Requirement

Based on GRN month dynamic color should come in GRN BAR code print.






COLOR_CODE

*&---------------------------------------------------------------------*
* 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
*
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
*  Line type TYPE1 from the table MAIN_TABLE
  LOOP AT L_TABDEF-TLTYPE INTO L_LTYPES WHERE LINETYPE = '%C3'.
*
* Coloum information
*   Column1 (cell) of the TYPE1
    LOOP AT L_LTYPES-TCOLINFO INTO L_COLINFO WHERE WIDTHV = '2.00'.
*
* Borders
*   Background color and borders for that cell
      LOOP AT L_COLINFO-BORDERS INTO L_BORDER.
*
* Clearing the color parameters for the cell
        CLEAR: L_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

        CASE WA_FINAL-DATE+0(3).

          WHEN 'JAN'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '255'.
            L_BORDER-FILLCOLOR-GREEN   =  '255'.
            L_BORDER-FILLCOLOR-BLUE    = '0'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = 'FF'.
            L_BORDER-CFILLCOLOR-XGREEN = 'FF'.
            L_BORDER-CFILLCOLOR-XBLUE  = '00'.

          WHEN 'FEB'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '0'.
            L_BORDER-FILLCOLOR-GREEN   =  '255'.
            L_BORDER-FILLCOLOR-BLUE    = '1'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '00'.
            L_BORDER-CFILLCOLOR-XGREEN = 'FF'.
            L_BORDER-CFILLCOLOR-XBLUE  = '01'.

          WHEN 'MAR'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '255'.
            L_BORDER-FILLCOLOR-GREEN   =  '153'.
            L_BORDER-FILLCOLOR-BLUE    = '52'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = 'FF'.
            L_BORDER-CFILLCOLOR-XGREEN = '99'.
            L_BORDER-CFILLCOLOR-XBLUE  = '34'.

          WHEN 'APR'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '255'.
            L_BORDER-FILLCOLOR-GREEN   =  '153'.
            L_BORDER-FILLCOLOR-BLUE    = '255'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = 'FF'.
            L_BORDER-CFILLCOLOR-XGREEN = '99'.
            L_BORDER-CFILLCOLOR-XBLUE  = 'FF'.

          WHEN 'MAY'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '202'.
            L_BORDER-FILLCOLOR-GREEN   =  '94'.
            L_BORDER-FILLCOLOR-BLUE    = '4'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = 'CA'.
            L_BORDER-CFILLCOLOR-XGREEN = '5E'.
            L_BORDER-CFILLCOLOR-XBLUE  = '04'.

          WHEN 'JUN'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '128'.
            L_BORDER-FILLCOLOR-GREEN   =  '100'.
            L_BORDER-FILLCOLOR-BLUE    = '161'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '80'.
            L_BORDER-CFILLCOLOR-XGREEN = '64'.
            L_BORDER-CFILLCOLOR-XBLUE  = 'A1'.

          WHEN 'JUL'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '214'.
            L_BORDER-FILLCOLOR-GREEN   =  '0'.
            L_BORDER-FILLCOLOR-BLUE    = '147'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = 'D6'.
            L_BORDER-CFILLCOLOR-XGREEN = '00'.
            L_BORDER-CFILLCOLOR-XBLUE  = '93'.

          WHEN 'AUG'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '0'.
            L_BORDER-FILLCOLOR-GREEN   =  '153'.
            L_BORDER-FILLCOLOR-BLUE    = '255'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '00'.
            L_BORDER-CFILLCOLOR-XGREEN = '99'.
            L_BORDER-CFILLCOLOR-XBLUE  = 'FF'.

          WHEN 'SEP'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '153'.
            L_BORDER-FILLCOLOR-GREEN   =  '51'.
            L_BORDER-FILLCOLOR-BLUE    = '255'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '99'.
            L_BORDER-CFILLCOLOR-XGREEN = '33'.
            L_BORDER-CFILLCOLOR-XBLUE  = 'FF'.

          WHEN 'OCT'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '119'.
            L_BORDER-FILLCOLOR-GREEN   =  '119'.
            L_BORDER-FILLCOLOR-BLUE    = '119'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '77'.
            L_BORDER-CFILLCOLOR-XGREEN = '77'.
            L_BORDER-CFILLCOLOR-XBLUE  = '77'.

          WHEN 'NOV'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '127'.
            L_BORDER-FILLCOLOR-GREEN   =  '128'.
            L_BORDER-FILLCOLOR-BLUE    = '0'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '7F'.
            L_BORDER-CFILLCOLOR-XGREEN = '80'.
            L_BORDER-CFILLCOLOR-XBLUE  = '00'.

          WHEN 'DEC'.
            L_BORDER-INTENSITY = '100'.
            L_BORDER-FILLCOLOR-RED = '51'.
            L_BORDER-FILLCOLOR-GREEN   =  '102'.
            L_BORDER-FILLCOLOR-BLUE    = '255'.
            L_BORDER-FILLCOLOR-USED = 'X'.
            L_BORDER-CFILLCOLOR-COLOR = 'X'.
            L_BORDER-CFILLCOLOR-XRED = '33'.
            L_BORDER-CFILLCOLOR-XGREEN = '66'.
            L_BORDER-CFILLCOLOR-XBLUE  = 'FF'.

        ENDCASE.

        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.

















Output



Share this

Related Posts