Displaying bold text in a particular cell in ALV

Hi,
I am using cl_salv_table class. My requirement is to display few cells in bold based on some condition,
we can get the column using      
gr_p_column ?= gr_p_columns->get_column( 'MENGE' ).
but how can we set bold text property to the cell?
Please help me.

SAMPLES CODES:
[Refer to this link|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_wiki&query=rajasekhar&searchmode=similar&similardocsuri=/wiki/sdn_wiki/wiki/display/snippets/top%2bof%2bpage%2band%2bend%2bof%2bpage%2bin%2bclass%2bcl_salv_table&start=1]
Regards,
Gurpreet

Similar Messages

  • HOW TO DISPLAY THE TEXT ON A PARTICULAR PAGE IN SAPSCRIPTS

    HI,
       HOW TO DISPLAY THE TEXT ON A PARTICULAR PAGE IN SAPSCRIPTS?

    in ur script main window
    /: IF &TTXSY-PAGE& = 15.              
    ur text or standard text           
    /: ENDIF.                             
    use this.
    hope it helps if any issues revert back

  • How to give color of particular cell in alv list display for dynamic table

    Dear Experts,
    i want to give color of a particular cell in alv list display (reuse_alv_list_display). Here i am passing data through dynamic table?

    Hi,
    Se this:
    DATA: lt_color    TYPE lvc_t_scol WITH HEADER LINE.
    DATA: BEGIN OF data_tab OCCURS 0.
             tabcolor     TYPE   lvc_t_scol,
          END OF data_tab.
    * Befone ALV call
      alv_layout-coltab_fieldname  = 'TABCOLOR'.
    * For each row in data_tab
    REFRESH: lt_color.
    CLEAR: lt_color.
    lt_color-color-col = 6.
    lt_color-color-int = 1.
    lt_color-fname = FIELD1'.
    APPEND lt_color.
    lt_color-color-col = 2.
    lt_color-color-int = 0.
    lt_color-fname = 'FIELD2'.
    APPEND lt_color.
    data_tab-tabcolor[] = lt_color[].
    append data_tab.
    Best regards,
    Leandro Mengue

  • To change the colour of the particular cell of ALV report in Grid display.

    Hai Friends,
                      I have created an Alv report in grid display .In that i want to change the colour of the particular cell.Plz provide the answer with a solved example.
             Thank u.

    This works for a Custom Control and OO ALV in a Dialog Module
    TABLES: kna1.
    * Data (for the ALV Grid)
    TYPES:
      BEGIN OF t_alv_data,
        cust_id    TYPE kunnr,        "Customer Number
        cust_name  TYPE name1_gp,     "Customer Name
        cust_color TYPE i,
    *   cell coloring field
        color     TYPE lvc_t_scol,   "Cell coloring
      END OF t_alv_data.
    DATA:
      v_alv_data TYPE t_alv_data,
      i_alv_data TYPE STANDARD TABLE OF t_alv_data.
    * ALV grid containers and objects
    DATA:
      o_alv_grid TYPE REF TO cl_gui_alv_grid,
      o_alv_cont TYPE REF TO cl_gui_custom_container.
    * ALV field catalog
    DATA:
      i_alv_fc TYPE lvc_t_fcat,
      v_alv_fc LIKE lvc_s_fcat.
    * ALV Layout (colors)
    DATA:
      v_alv_layout TYPE lvc_s_layo,
      i_alv_color TYPE lvc_t_scol,
      v_alv_color TYPE lvc_s_scol,
      v_alv_color_cell TYPE lvc_s_colo.
    * ALV variant
    DATA:
      v_alv_variant  TYPE disvariant.
    PARAMETERS:
      p_alvvar TYPE disvariant-variant DEFAULT 'DEFAULT'.
    DATA: ok_code LIKE sy-ucomm.
    * Class for event handling
    *       CLASS lcl_event_receiver DEFINITION
    * [+] Event listener for the ALV grid
    * [+] Handles hotspots and data changes
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
    *     Hotspot clicking
          hotspot_click
               FOR EVENT hotspot_click OF cl_gui_alv_grid
                 IMPORTING e_row_id
                           e_column_id
                           es_row_no,
    *     Data changed (such as checkbox clicking)
          handle_data_changed
            FOR EVENT data_changed OF cl_gui_alv_grid
                IMPORTING er_data_changed.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *       CLASS lcl_event_receiver IMPLEMENTATION
    * [+] Implementation of the ALV Grid event handler class
    CLASS lcl_event_receiver IMPLEMENTATION.
    *       METHOD hotspot_click                                          *
    * [+] Calls evvent_hotspot_click when a hotspot is clicked in the ALV
      METHOD hotspot_click.
        PERFORM event_hotspot_click
                      USING e_row_id
                            e_column_id.
      ENDMETHOD.                    "hotspot_click
    *       METHOD handle_data_changed                                    *
    * [+] Updates the source data when the data in the ALV display has
    * been changed, such as by clicking a checkbox.
      METHOD handle_data_changed.
        DATA: lv_changed TYPE lvc_s_modi.
        LOOP AT er_data_changed->mt_good_cells INTO lv_changed
          WHERE fieldname = 'CUST_NAME'.
          READ TABLE i_alv_data INTO v_alv_data INDEX lv_changed-row_id.
          IF sy-subrc = 0.
            MOVE lv_changed-value TO v_alv_data-cust_name.
            MODIFY i_alv_data FROM v_alv_data INDEX lv_changed-row_id.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    * Reference to the event listener class
    DATA: event_receiver TYPE REF TO lcl_event_receiver.
    *       FORM build_event_listener
    * [+] Set the event handler on the ALV Grid
    FORM build_event_listener.
    * Assigning the event listener to the ALV
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_data_changed FOR o_alv_grid.
      SET HANDLER event_receiver->hotspot_click       FOR o_alv_grid.
    ENDFORM.                    "build_event_listener
    *       AT SELECTION-SCREEN
    *         ON VALUE-REQUEST FOR p_alvvar
    * [+] Calls choose_alv_variant to ask the user to select an alv grid
    *     layout variant
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvvar.
      PERFORM choose_alv_variant
        CHANGING
          p_alvvar
          v_alv_variant.
    *       START_OF_SELECTION
    START-OF-SELECTION.
      PERFORM get_data.
      SET PF-STATUS 'ALVSCREEN' IMMEDIATELY.
      CALL SCREEN 2000.
    *       FORM get_data
    * [+] Gets the data for the ALV grid
    FORM get_data.
      SELECT kunnr name1
        INTO (v_alv_data-cust_id,
              v_alv_data-cust_name)
        FROM kna1.
        APPEND v_alv_data TO i_alv_data.
      ENDSELECT.
    ENDFORM.                    "get_data
    *       MODULE build_alv_grid
    *   THIS SHOULD BE IN THE "PROCESS BEFORE OUTPUT" OF THE ALV SCREEN
    * [+] Builds the ALV Grid objects
    * [+] Calls to build the field catalog table
    * [+] Loads the field catalog table into the ALV Grid
    * [+] Loads the table data into the ALV Grid
    MODULE build_alv_grid OUTPUT.
      SET TITLEBAR  '2000'.
    * Also enables layout saving
      PERFORM set_alv_variant
        USING
          p_alvvar
        CHANGING
          v_alv_variant.
    * Building the grid and container on the screen
    * NOTE: the container name MUST be upper-case
    * Also, we don't want the objects to be created if in batch mode!
      IF sy-batch IS INITIAL.
        CREATE OBJECT o_alv_cont
          EXPORTING
            container_name = 'O_ALV_TABLE'.
      ENDIF.
      CREATE OBJECT o_alv_grid
        EXPORTING
          i_parent = o_alv_cont.
    * builds the event listener
      PERFORM build_event_listener.
    * Color the cells
      PERFORM color_cells.
    * Build the field catalog
      PERFORM build_alv_fc.
    * Loads the data into the grid
      CALL METHOD o_alv_grid->set_table_for_first_display
        EXPORTING
          i_save          = 'A'
          i_default       = 'X'
          is_variant      = v_alv_variant
          is_layout       = v_alv_layout
        CHANGING
          it_outtab       = i_alv_data
          it_fieldcatalog = i_alv_fc.
    ENDMODULE.                    "build_alv_grid OUTPUT
    *       FORM build_alv_fc
    * [+] Constructs the ALV Grid field catalog table
    FORM build_alv_fc.
      CLEAR i_alv_fc.
      REFRESH i_alv_fc.
    * NOTE: the field name MUST be upper-case
    *                   field       heading         hide  hot
    *                   name                        zero  spot  just
      PERFORM:
        alv_field USING 'CUST_ID'    'Cust ID'        ' '  'X'  'R',
        alv_field USING 'CUST_NAME'  'Customer Name'  ' '  ' '  'L',
        alv_field USING 'CUST_COLOR' 'Color'          ' '  ' '  'R'.
    ENDFORM.                    "build_alv_fc
    *       FORM alv_field
    * [+] Describes and constructs a single field for the ALV Grid field
    *     catalog. The field length and type are both obtained from the
    *     actual field passed in to this method.
    * [+] Adds the constructed field to the ALV Grid field catalog table
    FORM alv_field
      USING
        p_field_name TYPE c
        p_heading    TYPE c
        p_hide_zeros TYPE c
        p_hotspot    TYPE c
        p_justify    TYPE c.
      CLEAR v_alv_fc.
      DATA:
        lv_type(1) TYPE c,
        lv_length TYPE i,
        lv_heading_length TYPE i.
    * get the type and length of this field
      FIELD-SYMBOLS <field>.
      ASSIGN p_field_name TO <field>.
      DESCRIBE FIELD <field> TYPE lv_type OUTPUT-LENGTH lv_length.
    * re-adjust the length to the length of the header, if too short
      lv_heading_length = strlen( p_heading ).
      IF lv_length < lv_heading_length.
        lv_length = lv_heading_length.
      ENDIF.
    * NOTE: the field name MUST be upper-case
      v_alv_fc-fieldname = p_field_name.
      TRANSLATE v_alv_fc-fieldname TO UPPER CASE.
      v_alv_fc-inttype   = lv_type.
      v_alv_fc-outputlen = lv_length.
      v_alv_fc-coltext   = p_heading.
      v_alv_fc-seltext   = p_heading.
      v_alv_fc-hotspot   = p_hotspot.
    * Determining which fields should show zeros
      IF p_hide_zeros = 'X'.
        v_alv_fc-no_zero = 'X'.
        v_alv_fc-lzero   = ' '.
      ELSE.
        v_alv_fc-no_zero = ' '.
        v_alv_fc-lzero   = 'X'.
      ENDIF.
      v_alv_fc-just = p_justify.
    * Add the field to the field catalog
      APPEND v_alv_fc TO i_alv_fc.
    ENDFORM.                    "alv_field
    *       FORM choose_alv_variant
    * [+] Shows a popup that allows the user to choose the layout variant
    *     for the alv grid of the current program
    * [+] Usually called by an AT SELECTION-SCREEN method.
    FORM choose_alv_variant
      CHANGING
        p_variant_name TYPE disvariant-variant
        p_variant      TYPE disvariant.
      CLEAR p_variant.
      DATA:
        p_exit_check(1) TYPE c.
      MOVE sy-repid TO p_variant-report.
      CALL FUNCTION 'LVC_VARIANT_F4'
           EXPORTING
                is_variant = p_variant
                i_save     = 'A'
           IMPORTING
                e_exit     = p_exit_check
                es_variant = p_variant
           EXCEPTIONS
                not_found  = 1
                OTHERS     = 99.
      IF sy-subrc = 0.
        IF p_exit_check <> 'X'.
          p_variant_name = p_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                    "choose_alv_variant
    *       FORM set_alv_variant
    * [+] Sets the alv grid layout variant. Used for setting the variant
    *     when its name is entered in a parameter rather than by using the
    *     popup, or when loading the variant from a variable of type C
    FORM set_alv_variant
      USING
        p_variant_name TYPE disvariant-variant
      CHANGING
        p_variant      TYPE disvariant.
      MOVE sy-repid TO p_variant-report.
      p_variant-variant = p_variant_name.
    ENDFORM.                    "set_alv_variant
    *       FORM color_cells
    * [+] Loop through the data and apply coloring
    FORM color_cells.
      DATA:
        my_color  TYPE i.
    * tell the ALV grid what field in v_alv_data contains color information
      v_alv_layout-ctab_fname = 'COLOR'.
      my_color = 0.
    * loop through each row of the table
      LOOP AT i_alv_data INTO v_alv_data.
    *   clear the variables
        CLEAR:
          v_alv_color,
          v_alv_color_cell,
          i_alv_color.
        REFRESH:
          i_alv_color.
        v_alv_data-cust_color = my_color.
        PERFORM color_cell USING 'CUST_COLOR' my_color. "negative
    *   apply the colors
    *    IF v_alv_data-cust_name = 'Testing Credit'.
    *      PERFORM color_cell USING 'CUST_NAME' 6. "negative
    *    ELSEIF v_alv_data-cust_name = 'Goober Goober Also'.
    *      PERFORM color_cell USING 'CUST_NAME' 5. "positive
    *    ENDIF.
    *   set the color data for this table row
        v_alv_data-color = i_alv_color.
        MODIFY i_alv_data FROM v_alv_data.
        my_color = my_color + 1.
        IF my_color GT 7.
          CLEAR my_color.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "color_cells
    *       FORM color_cell
    * [+] Colors a cell in the ALV grid
    FORM color_cell
      USING
        p_cellname TYPE c
        p_color    TYPE i.
      CLEAR:
        v_alv_color_cell,
        v_alv_color.
    * set the color for the cell
    *  IF p_color = 0.
    *    v_alv_color_cell-col = 0. "cl_gui_resources=>list_col_background.
    *  ELSEIF p_color = 1.
    *    v_alv_color_cell-col = 1. "cl_gui_resources=>list_col_heading.
    *  ELSEIF p_color = 2.
    *    v_alv_color_cell-col = 2. "cl_gui_resources=>list_col_normal.
    *  ELSEIF p_color = 3.
    *    v_alv_color_cell-col = 3. "cl_gui_resources=>list_col_total.
    *  ELSEIF p_color = 4.
    *    v_alv_color_cell-col = 4. "cl_gui_resources=>list_col_key.
    *  ELSEIF p_color = 5.
    *    v_alv_color_cell-col = 5. "cl_gui_resources=>list_col_positive.
    *  ELSEIF p_color = 6.
    *    v_alv_color_cell-col = 6. "cl_gui_resources=>list_col_negative.
    *  ELSEIF p_color = 7.
    *    v_alv_color_cell-col = 7. "cl_gui_resources=>list_col_group.
    *  ENDIF.
      v_alv_color_cell-col = p_color.
      v_alv_color-nokeycol = 'X'.
      v_alv_color-fname = p_cellname.
    *  v_alv_color-color = p_color.
      v_alv_color-color = v_alv_color_cell.
      APPEND v_alv_color TO i_alv_color.
    ENDFORM.                    "color_cell
    *       FORM event_hotspot_click
    * [+] What to do when clicking on a hotspot in the ALV Grid
    FORM event_hotspot_click
      USING
        p_row    TYPE lvc_s_row
        p_column TYPE lvc_s_col.
      DATA:
        lv_docnum TYPE kunnr.
      READ TABLE i_alv_data INTO v_alv_data INDEX p_row-index.
      IF p_column = 'CUST_ID'.
    *   call a transaction when the cust_id is clicked
        SET PARAMETER ID 'AUN' FIELD v_alv_data-cust_id.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDIF.
    ENDFORM.                    "event_hotspot_click
    *&      Module  USER_COMMAND_2000  INPUT
    *       text
    MODULE user_command_2000 INPUT.
      CASE ok_code.
        WHEN 'BACK'
          OR 'STOP'
          OR 'CANCEL'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_2000  INPUT

  • How to display multple line text in a single cell in ALV?

    Hi all,
    I have 'Material Detailed Description' field in my ALV report, and it's taken from a multiple line text table. Is there any way so I can get this whole text to fit in a single ALV cell (not in single, but multiple line, as in original text data)?
    Thank you.

    Hi
    If you want you can display this long text field in ALV but the allignment of the ALV not looks good. so generally we won't display them in the output,
    instead, in the interactive list write the code to call that MM03 transaction, and the user can see that text in the transaction when ever double clicked on that MATERIAL field.
    Reward points for useful Answers
    Regards
    Anji

  • N78 browser can't display bold text

    I found a problem with my N78 phone. I used the Nokia 6110 Navigator to access the webmail and it used to display the new messages in bold. However, after I changed the phone to N78, it no longer able to display the new messages in bold.
    I then write up a very simple HTML page to test the N78 built-in browser behaviour for bold text dislay and the result is negative. Both the normal text and bold text are displayed the same. Bold text are not bold when displayed in N78 browser.

    wait for firmware update
    If you find my post useful then click on
    Kudos!Nokia N96 (v20.050 / RM-247)
    www.shaysoft.net | Competitions!

  • How to color a particular cell in ALV.

    hi,
       I have a requirement where i need to select a particular cell of a column in ALV and upon selection , i need to change the color of the selected cell. I choose the color from the dropdown toolbar created by me.
    plz help, thanks.

       REPORT  ZTEST_DHR.
    TYPE-POOLS : SLIS.
    TYPES: BEGIN OF TY_MARA,
            FLAG  TYPE CHAR1,
            MATNR TYPE MARA-MATNR,
            ERSDA TYPE MARA-ERSDA,
            ERNAM TYPE MARA-ERNAM,
            WESCH TYPE MARA-WESCH,
            STYLE TYPE LVC_T_STYL,
            CELLCOLR TYPE LVC_T_SCOL,
          END OF TY_MARA.
    DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
    DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
           WA_MARA TYPE TY_MARA,
           WA_MARA1 TYPE TY_MARA.
    * for reuse alv grid display
    *DATA : IT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
    *        WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
    *        WA_LAYOUT       TYPE SLIS_LAYOUT_ALV,
    *        GV_REPID      TYPE SY-REPID.
    *for LVC Display
    DATA : WA_SETTINGS TYPE LVC_S_GLAY.
    DATA : WA_LAYOUT TYPE LVC_S_LAYO.
    DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
            WA_FIELDCATALOG TYPE LVC_S_FCAT.
    DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
    DATA: LS_EDIT TYPE LVC_S_STYL,
          LT_EDIT TYPE LVC_T_STYL.
    DATA : LS_CELL_COLOR TYPE LVC_S_SCOL.
    DATA : LT_CELL_COLOR TYPE LVC_T_SCOL.
    START-OF-SELECTION.
      SELECT MATNR ERSDA ERNAM WESCH
        FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
      UP TO 10 ROWS.
    END-OF-SELECTION.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM BUILD_LAYOUT.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATALOG
    *       text
    FORM BUILD_FIELDCATALOG .
      WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
      WA_FIELDCATALOG-OUTPUTLEN =  6.
      WA_FIELDCATALOG-CHECKBOX  = 'X'.           "as checkbox
      WA_FIELDCATALOG-EDIT      = 'X'.
      WA_FIELDCATALOG-SELTEXT = 'Check box'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Mat no'.
    *  wa_fieldcatalog-input = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
      WA_FIELDCATALOG-OUTPUTLEN =  15.
      WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Quantity'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
    ENDFORM.                    "build_fieldcatalog
    *&      Form  BUILD_LAYOUT
    *       text
    FORM BUILD_LAYOUT .
      CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
    *  WA_LAYOUT-NO_INPUT          = LC_X.
      WA_LAYOUT-CWIDTH_OPT = LC_X.
      WA_LAYOUT-ZEBRA             = LC_X.
      WA_LAYOUT-STYLEFNAME = 'STYLE'.
      WA_LAYOUT-CTAB_FNAME = 'CELLCOLR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       text
    FORM DISPLAY_ALV_REPORT .
      LS_EDIT-FIELDNAME = 'FLAG'.
      LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
      INSERT LS_EDIT INTO TABLE LT_EDIT.
      INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
      LS_CELL_COLOR-FNAME = 'MATNR'.
      LS_CELL_COLOR-COLOR-COL = '7'.
      LS_CELL_COLOR-COLOR-INT = '1'.
      INSERT LS_CELL_COLOR into table LT_CELL_COLOR.
      INSERT LINES OF LT_CELL_COLOR into TABLE WA_MARA1-CELLCOLR.
      LOOP AT IT_MARA INTO WA_MARA.
        IF WA_MARA-ERSDA EQ '20080625'.
          MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE CELLCOLR.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
       EXPORTING
    *      I_INTERFACE_CHECK                 = ' '
    *      I_BYPASSING_BUFFER                =
    *      I_BUFFER_ACTIVE                   =
         I_CALLBACK_PROGRAM                = SY-REPID
         I_CALLBACK_PF_STATUS_SET          = 'F_SET_STATUS'
         I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
    *      I_CALLBACK_TOP_OF_PAGE            = ' '
    *      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *      I_CALLBACK_HTML_END_OF_LIST       = ' '
    *      I_STRUCTURE_NAME                  =
    *      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = 'Example of select and deselect'
    *      I_GRID_SETTINGS                   =
          IS_LAYOUT_LVC                     = WA_LAYOUT
         IT_FIELDCAT_LVC                   = IT_FIELDCATALOG
        TABLES
          T_OUTTAB                          = IT_MARA
    *    EXCEPTIONS
    *      PROGRAM_ERROR                     = 1
    *      OTHERS                            = 2
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *    EXPORTING
    *      I_CALLBACK_PROGRAM       = GV_REPID
    *      I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
    *      I_CALLBACK_USER_COMMAND  = 'F_USER_COMMAND'
    *      I_GRID_TITLE             = 'Example of select and deselect'
    *      I_GRID_SETTINGS          = WA_SETTINGS
    *      IS_LAYOUT                = WA_LAYOUT
    *      IT_FIELDCAT              = IT_FIELDCATALOG[]
    *    TABLES
    *      T_OUTTAB                 = IT_MARA.
    *  IF SY-SUBRC <> 0.
    *    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *  ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  f_set_status
    *       text
    FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS1'.
    ENDFORM.                    " f_set_status
    *&      Form  f_user_command
    *       text
    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD.
    * BREAK-POINT.
      CASE R_UCOMM.
        WHEN 'ASEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = 'X'.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DSEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = ' '.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DELETE'.
    *      BREAK-POINT.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
          DELETE IT_MARA
                   WHERE FLAG = 'X'.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'INSERT'.
          CLEAR WA_MARA.
          APPEND WA_MARA TO IT_MARA.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
        WHEN 'SAVEDB'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
    * CODE TO BE WRITTEN TO SAVE in DB just an insert statement
    *ENDLOOP.
      ENDCASE.
    ENDFORM.
       REPORT  ZTEST_DHR.
    TYPE-POOLS : SLIS.
    TYPES: BEGIN OF TY_MARA,
            FLAG  TYPE CHAR1,
            MATNR TYPE MARA-MATNR,
            ERSDA TYPE MARA-ERSDA,
            ERNAM TYPE MARA-ERNAM,
            WESCH TYPE MARA-WESCH,
            STYLE TYPE LVC_T_STYL,
            CELLCOLR TYPE LVC_T_SCOL,
          END OF TY_MARA.
    DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
    DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
           WA_MARA TYPE TY_MARA,
           WA_MARA1 TYPE TY_MARA.
    * for reuse alv grid display
    *DATA : IT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
    *        WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
    *        WA_LAYOUT       TYPE SLIS_LAYOUT_ALV,
    *        GV_REPID      TYPE SY-REPID.
    *for LVC Display
    DATA : WA_SETTINGS TYPE LVC_S_GLAY.
    DATA : WA_LAYOUT TYPE LVC_S_LAYO.
    DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
            WA_FIELDCATALOG TYPE LVC_S_FCAT.
    DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
    DATA: LS_EDIT TYPE LVC_S_STYL,
          LT_EDIT TYPE LVC_T_STYL.
    DATA : LS_CELL_COLOR TYPE LVC_S_SCOL.
    DATA : LT_CELL_COLOR TYPE LVC_T_SCOL.
    START-OF-SELECTION.
      SELECT MATNR ERSDA ERNAM WESCH
        FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
      UP TO 10 ROWS.
    END-OF-SELECTION.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM BUILD_LAYOUT.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATALOG
    *       text
    FORM BUILD_FIELDCATALOG .
      WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
      WA_FIELDCATALOG-OUTPUTLEN =  6.
      WA_FIELDCATALOG-CHECKBOX  = 'X'.           "as checkbox
      WA_FIELDCATALOG-EDIT      = 'X'.
      WA_FIELDCATALOG-SELTEXT = 'Check box'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Mat no'.
    *  wa_fieldcatalog-input = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
      WA_FIELDCATALOG-OUTPUTLEN =  15.
      WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Quantity'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
    ENDFORM.                    "build_fieldcatalog
    *&      Form  BUILD_LAYOUT
    *       text
    FORM BUILD_LAYOUT .
      CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
    *  WA_LAYOUT-NO_INPUT          = LC_X.
      WA_LAYOUT-CWIDTH_OPT = LC_X.
      WA_LAYOUT-ZEBRA             = LC_X.
      WA_LAYOUT-STYLEFNAME = 'STYLE'.
      WA_LAYOUT-CTAB_FNAME = 'CELLCOLR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       text
    FORM DISPLAY_ALV_REPORT .
      LS_EDIT-FIELDNAME = 'FLAG'.
      LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
      INSERT LS_EDIT INTO TABLE LT_EDIT.
      INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
      LS_CELL_COLOR-FNAME = 'MATNR'.
      LS_CELL_COLOR-COLOR-COL = '7'.
      LS_CELL_COLOR-COLOR-INT = '1'.
      INSERT LS_CELL_COLOR into table LT_CELL_COLOR.
      INSERT LINES OF LT_CELL_COLOR into TABLE WA_MARA1-CELLCOLR.
      LOOP AT IT_MARA INTO WA_MARA.
        IF WA_MARA-ERSDA EQ '20080625'.
          MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE CELLCOLR.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
       EXPORTING
    *      I_INTERFACE_CHECK                 = ' '
    *      I_BYPASSING_BUFFER                =
    *      I_BUFFER_ACTIVE                   =
         I_CALLBACK_PROGRAM                = SY-REPID
         I_CALLBACK_PF_STATUS_SET          = 'F_SET_STATUS'
         I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
    *      I_CALLBACK_TOP_OF_PAGE            = ' '
    *      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *      I_CALLBACK_HTML_END_OF_LIST       = ' '
    *      I_STRUCTURE_NAME                  =
    *      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = 'Example of select and deselect'
    *      I_GRID_SETTINGS                   =
          IS_LAYOUT_LVC                     = WA_LAYOUT
         IT_FIELDCAT_LVC                   = IT_FIELDCATALOG
        TABLES
          T_OUTTAB                          = IT_MARA
    *    EXCEPTIONS
    *      PROGRAM_ERROR                     = 1
    *      OTHERS                            = 2
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *    EXPORTING
    *      I_CALLBACK_PROGRAM       = GV_REPID
    *      I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
    *      I_CALLBACK_USER_COMMAND  = 'F_USER_COMMAND'
    *      I_GRID_TITLE             = 'Example of select and deselect'
    *      I_GRID_SETTINGS          = WA_SETTINGS
    *      IS_LAYOUT                = WA_LAYOUT
    *      IT_FIELDCAT              = IT_FIELDCATALOG[]
    *    TABLES
    *      T_OUTTAB                 = IT_MARA.
    *  IF SY-SUBRC <> 0.
    *    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *  ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  f_set_status
    *       text
    FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS1'.
    ENDFORM.                    " f_set_status
    *&      Form  f_user_command
    *       text
    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD.
    * BREAK-POINT.
      CASE R_UCOMM.
        WHEN 'ASEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = 'X'.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DSEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = ' '.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DELETE'.
    *      BREAK-POINT.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
          DELETE IT_MARA
                   WHERE FLAG = 'X'.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'INSERT'.
          CLEAR WA_MARA.
          APPEND WA_MARA TO IT_MARA.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
        WHEN 'SAVEDB'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
    * CODE TO BE WRITTEN TO SAVE in DB just an insert statement
    *ENDLOOP.
      ENDCASE.
    ENDFORM.
    About Selecting a Color From Dropdown?  even i need to check for now this is the how u do cell color in alv

  • HOW TO GET VALUE OF A PARTICULAR CELL IN ALV GRID

    I HAVE 2 ALV GRID. IWANT WHEN I DOUBLE CLICK ON ANY PARTICULAR CELL OF FIRST GRID I WILL GET THE VALUE DISPLAYED ON THAT PARTICULAR CELL.
    THANKS IN ADVANCE

    Hi,
    If you are using a class alv, you only need to create a local class to control event and, before setting the screen to present the alv, you need to assign the class as a handler, like this:
        CREATE OBJECT event_handler.
        SET HANDLER event_handler->double_click FOR alv_grid.
    This event handler was defined before like below and a object was created for it:
    CLASS cl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS double_click FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column.
    ENDCLASS.                    "cl_event_handler DEFINITION
    Then you need to implement this class, creating the method double click and do a READ TABLE to the itab you presented in the alv to recover the data, like this:
        READ TABLE itab INTO wk_itab
          INDEX e_row-index.
    The e_row structure was sent to the method by the handler, setting it with the line index that you double clicked in the alv. After that, you can manipulate the data that you selected in your internal table to generate the data to the other ALV.
    Best Regards,
    -h

  • Regarding increasing width of particular cell in alv

    hi,
    i have created a simple ALV program. it is working properly but i want to increase size of a particular cell in this.pls tell me how can i do this.
    Thanx/Regards,
    Vaneet Thakur

    Hi ,
    You need to specify outputlen field of the field catalog and you need to pass the same
    field catalog in the Function Module .
    Please check the code - -
    fs_fcat-fieldname = 'FIELD_NAME'.
      fs_fcat-seltext_l = text-126.
      fs_fcat-outputlen = '35'.  " Output lenth according to ur Requirement
      fs_fcat-edit      = 'X'.
      fs_fcat-input     = 'X'.
      fs_fcat-col_pos   = 3.
      APPEND fs_fcat TO t_fcat.
      CLEAR fs_fcat.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_callback_pf_status_set = 'STATUS'
          i_callback_user_command  = 'UCOMMAND'
          i_structure_name         = 'FS_ITAB1'
          it_fieldcat              = t_fcat  " Pass the table populated all the information
          i_screen_start_column    = 2
          i_screen_start_line      = 5
          i_screen_end_column      = 70
          i_screen_end_line        = 20
        TABLES
          t_outtab                 = t_itab1
        EXCEPTIONS
          program_error            = 1.
    Regards
    Pinaki

  • Colouring one particular cell in ALV

    Hi All,
    I have one requirement where I have to colour one particular cell in the ALV report.Can any one help me in this regard.
    Waiting for your response.
    Raj

    CLEAR FS_FIELDCAT .
    FS_FIELDCAT-FIELDNAME = 'CONNID'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 2.
    FS_FIELDCAT-KEY = 'X'.
    FS_FIELDCAT-HOTSPOT = 'X'.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    CLEAR FS_FIELDCAT .
    FS_FIELDCAT-FIELDNAME = 'DISTANCE'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 3.
    FS_FIELDCAT-KEY = ' '.
    FS_FIELDCAT-EDIT = 'X'.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    CLEAR FS_FIELDCAT.
    FS_FIELDCAT-FIELDNAME = 'CITYFROM'.
    FS_FIELDCAT-REF_TABNAME = 'SPFLI'.
    FS_FIELDCAT-COL_POS = 4.
    FS_FIELDCAT-KEY = ' '.
    APPEND FS_FIELDCAT TO T_FIELDCAT.
    LOOP AT T_FIELDCAT INTO FS_FIELDCAT.
    IF FS_FIELDCAT-COL_POS EQ P_COL.
    FS_FIELDCAT-EMPHASIZE = P_COLOR.
    W_FIELDNAME = FS_FIELDCAT-FIELDNAME.
    IF P_ROW IS INITIAL AND P_COL GT 0.
    MODIFY T_FIELDCAT FROM FS_FIELDCAT TRANSPORTING EMPHASIZE.
    ENDIF.
    ENDIF.
    ENDLOOP.
    FS_CELL-FIELDNAME = W_FIELDNAME .
    FS_CELL-COLOR-COL = 6.
    FS_CELL-NOKEYCOL = 'X'.
    APPEND FS_CELL TO T_SPFLI-CELL.
    IF P_ROW IS NOT INITIAL AND P_COL IS NOT INITIAL.
    MODIFY T_SPFLI INDEX P_ROW TRANSPORTING CELL.
    ENDIF.
    FS_LAYOUT-INFO_FIELDNAME = 'COLOR'.
    FS_LAYOUT-BOX_FIELDNAME = 'CHECKBOX'.
    FS_LAYOUT-COLTAB_FIELDNAME = 'CELL'.
    FS_LAYOUT-F2CODE = '&ETA'.
    W_PROG = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = W_PROG
    IS_LAYOUT = FS_LAYOUT
    IT_FIELDCAT = T_FIELDCAT
    TABLES
    T_OUTTAB = T_SPFLI
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    Regards,
    Pravin

  • How to display bold text in JTextPane and how to get them?

    I need show some fonted text like BOLD, UNDER LINE, can some body tell how to do it? for example, how to show the following sentences?
    "This is <b><u><i>This is a test of the formatting option</b></i></u> end of"
    in JTextPane?

    Hi Juergen,
    I found Your blog and found it  really interesting... though I was not able to use it: I (like Jun Li is asking, I guess) need to use a dynamic text, containing formatting informations (according the xhtml syntax).
    I tried to pass it to the form by an ABAP-dictionary based interface and by means of the context (in a webdynpro page), but both tries failed.
    Some suggestion will be greatly appreciated.
    Thankyou
    Simone

  • Color  a particular cell  in ALV

    Hi all,
      I am working with ALV using class cl_salv_table. i can colorize a particular colomn  using cl_salv_column_table->set_color method. I was able to do it. I have done it for an amount column. Now I want to show the amount in some other color if it is 0. Let me know whether that possibility is there or not. If yes, please let me know the corresponding class and method and how we can implement it.
    Thank u.

    Hi ,
    fill  emphasize of field catelog
    wa_fcat-emphasize = color_code eg 'C400' .
    Colour code :                                               
    Colour is a 4-char field where :                             
                  - 1st char = C (color property)                 
                  - 2nd char = color code (from 0 to 7)           
                                      0 = background color        
                                      1 = blue                    
                                      2 = gray                    
                                      3 = yellow                 
                                      4 = blue/gray               
                                      5 = green                   
                                      6 = red                     
                                      7 = orange                  
                  - 3rd char = intensified (0=off, 1=on)         
                  - 4th char = inverse display (0=off, 1=on)      
    hope it helps .....

  • Making only particular cell of ALV editable

    Hi,
    I have a requirement where when the user clicks on an insert button a blank row should get appended to the ALV and only 1 of the cells in this row should be in editable mode. (Also the other rows of the ALV should be in display mode) I tried coding using the LVC_T_STYL properties but I come up with a screen of all non-editable rows. Please help suggest where I am going wrong. My coding is as below:
    My internal table is defined as:
    DATA: BEGIN OF it_mara OCCURS 1.
               INCLUDE STRUCTURE mara.
    DATA:   cellstyles TYPE lvc_t_styl,
                 END OF it_mara.
    My other important attribute definitions:
    data:   ls_cellstyles TYPE lvc_s_styl,
              ls_layout TYPE lvc_s_layo,
    In the PAI event for handling the INSERT button I have coded as:
    WHEN 'INSERT'.
          APPEND wa_mara TO it_mara. " Appending a blank row to ALV
          DESCRIBE TABLE it_mara LINES lv_count.
          read table it_mara index lv_count.
          ls_cellstyles-fieldname = 'MATNR'.
          ls_cellstyles-style = cl_gui_alv_grid=>mc_style_enabled. " Setting only MATNR field of the appended row as enabled
          insert ls_cellstyles into table it_mara-cellstyles.
          MODIFY it_mara INDEX lv_count transporting cellstyles.
          o_grid->refresh_table_display( ).
    Am also assigning cellstyles to the stylefname attribute of the layout & passing it to the SET_TABLE_FOR_FIRST_DISPLAY.
    Regards,
    Uday

    Hi Ranjith,
    Please find the coding as below. You need to create a screen 100 and place a custom control with name O_CONT & a pushbutton with the function code as INSERT.
    Regards,
    Uday
    *& Report  Z187442_OOALV5
    REPORT  z187442_ooalv5 NO STANDARD PAGE HEADING.
    DATA: BEGIN OF it_mara OCCURS 1.
            INCLUDE STRUCTURE mara.
    DATA:   cellstyles TYPE lvc_t_styl,
           END OF it_mara.
    DATA: it_fcat TYPE lvc_t_fcat,
          wa_fcat TYPE lvc_s_fcat,
          wa_mara LIKE LINE OF it_mara,
          o_cont TYPE REF TO cl_gui_custom_container,
          o_grid TYPE REF TO cl_gui_alv_grid,
          ls_cellstyles TYPE lvc_s_styl,
          ls_layout TYPE lvc_s_layo,
          okcode(20).
    START-OF-SELECTION.
      PERFORM build_fcat.
      PERFORM build_layout.
      PERFORM build_mara_data.
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'Z187442_OOALV4'.
      IF o_cont IS INITIAL.
        CREATE OBJECT o_cont
          EXPORTING
            container_name = 'O_CONT'.
        CREATE OBJECT o_grid
          EXPORTING
            i_parent = o_cont.
        CALL METHOD o_grid->set_table_for_first_display
          EXPORTING
            is_layout       = ls_layout
          CHANGING
            it_outtab       = it_mara[]
            it_fieldcatalog = it_fcat.
      ELSE.
        o_grid->refresh_table_display( ).
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE user_command_0100 INPUT.
      DATA lv_count TYPE i VALUE 0.
      CASE okcode.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          LEAVE PROGRAM.
        WHEN 'INSERT'.
          APPEND wa_mara TO it_mara.
          DESCRIBE TABLE it_mara LINES lv_count.
          READ TABLE it_mara INDEX lv_count.
          ls_cellstyles-fieldname = 'MATNR'.
          ls_cellstyles-style = cl_gui_alv_grid=>mc_style_enabled.
          INSERT ls_cellstyles INTO TABLE it_mara-cellstyles.
          MODIFY it_mara INDEX lv_count TRANSPORTING cellstyles.
          o_grid->set_ready_for_input( exporting I_READY_FOR_INPUT = '1' ).
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FCAT
    FORM build_fcat .
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'MARA'
        CHANGING
          ct_fieldcat      = it_fcat.
    ENDFORM.                    " BUILD_FCAT
    *&      Form  BUILD_MARA_DATA
    FORM build_mara_data .
      SELECT * FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara UP TO 10 ROWS.
    ENDFORM.                    " BUILD_MARA_DATA
    *&      Form  BUILD_LAYOUT
    FORM build_layout .
      ls_layout-stylefname = 'CELLSTYLES'.
    ENDFORM.                    " BUILD_LAYOUT

  • HOW TO CHANGE COLOR OF PARTICULAR CELL  IN ALV

    I HAVE DISPLAYED A REPORT IN ALV
    I WANT TO CHANGE THE COLOR OF VBELN FIELD  ON WHICH HOTSPOT IS ON?
    HOW TO DO THIS?

    Hi Lovleen,
    Check out the code
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display each row in a different     *
    *& colour                                                              *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) type c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
      gd_layout-info_fieldname =      'LINE_COLOR'.
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    data: ld_color(1) type c.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
              i.e. wa_ekko-line_color = 'C410'
      ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
      if ld_color = 8.
        ld_color = 1.
      endif.
      concatenate 'C' ld_color '10' into wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
      modify it_ekko from wa_ekko.
    endloop.
    endform.                    " DATA_RETRIEVAL
    Regards,
    Chandru

  • How to insert checkbox at a particular  cell  in jtable

    hello,
    I am a user of jdeveloper using jclient/swing .
    question:
    i am using jtable. i want that whenever i click on a specified cell then text at that particular cell get clear and a checkbox inserted in that cell . whenever i click on that checkbox i.e check the checkbox,
    again a text is inserted in that cell.
    thank you

    Did you ever get this to work? If I bind a JCheckbox to my attribute and add the checkbox to my JClient panel, the attribute value is properly bound to the checkbox with everything working correctly. Adding the checkbox as the TableCellEditor for the column doesn't work.
    Also, the link to using a Combobox as a table cell editor works, but the link doesn't tell where to donwload the sample code from. Doesn't anyone know the link?

Maybe you are looking for