Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

problem with Color Display for dynamic internal table

Former Member
0 Kudos
380

Hi Team,

I am facing problem with the color display for dynamic internal table. Here iam applying color display based on the field value. Here is my code.

declaration:

  DATA: v_st22_counts TYPE i.

  DATA: gd_layout    TYPE lvc_s_layo.


TYPES: BEGIN OF ty_st22_dumps,
        count TYPE char4,
        COLOR(4) TYPE c,
       END OF ty_st22_dumps.
DATA: w_st22_dumps  TYPE ty_st22_dumps.

Field catalogue:

   CALL FUNCTION 'RS_ST22_GET_DUMPS'
          EXPORTING
            p_day     = sy-datum
          IMPORTING
            p_infotab = t_st22_p_infotab.
*      GETING DUMP COUNTS
        DESCRIBE TABLE t_st22_p_infotab LINES v_st22_counts.
        REFRESH lt_lvc_fieldcatalogue.
        CLEAR ls_lvc_fieldcatalogue.
*             Build Fieldcatalog
        ls_lvc_fieldcatalogue-reptext    = 'ST22  ABAP Dump Analysis'.
        ls_lvc_fieldcatalogue-fieldname = 'COUNT'.
        ls_lvc_fieldcatalogue-col_opt   = 'X'.
        ls_lvc_fieldcatalogue-dd_outlen = '04'.
        ls_lvc_fieldcatalogue-emphasize = 'X'.
        APPEND ls_lvc_fieldcatalogue TO lt_lvc_fieldcatalogue.
        CLEAR ls_lvc_fieldcatalogue.
        ls_lvc_fieldcatalogue-reptext    = 'COLOR'.
        ls_lvc_fieldcatalogue-fieldname = 'COLOR'.
        ls_lvc_fieldcatalogue-INTLEN = '4'.
        ls_lvc_fieldcatalogue-NO_OUT = 'X'.

        APPEND ls_lvc_fieldcatalogue TO lt_lvc_fieldcatalogue.
        CLEAR ls_lvc_fieldcatalogue.

Dynamic display of values in the fieldcatalogue and color display:

        ASSIGN l_table->* TO <it_table>.
      CREATE DATA dyn_line LIKE LINE OF <it_table>.
      ASSIGN dyn_line->* TO <fs_wa>.
      ASSIGN COMPONENT 1 OF STRUCTURE <FS_WA> TO <FS_FIELD>.
      MOVE v_st22_counts TO <FS_FIELD>.
      ASSIGN COMPONENT 2 OF STRUCTURE <FS_WA> TO <FS_FIELD>.
      IF v_st22_counts  EQ 0.
       <FS_FIELD> = 'C511'.
      ELSE.
       <FS_FIELD> = 'C611'.
      ENDIF.
      APPEND <FS_WA> TO <it_table>.
      REFRESH: t_st22_p_infotab.
      gd_layout-INFO_fname = 'COLOR'.

     CALL METHOD g_alv_grid->set_table_for_first_display
        EXPORTING
          i_default                     = 'X'
          is_layout                     = gd_layout
        CHANGING
          it_outtab                     = <it_table>
          it_fieldcatalog               = lt_lvc_fieldcatalogue
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
      ENDIF.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR:    ls_lvc_fieldcatalogue,
                <it_table>.
      REFRESH : lt_lvc_fieldcatalogue.

    ENDIF.

Please help me with the solution. At the moment it is showing just the dump count not the count with the color display.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
338

Any Pointers please help

22 REPLIES 22

Former Member
0 Kudos
339

Any Pointers please help

0 Kudos
338

Hi

Probably the problem is in the value you're assigning to the the field with color

IF v_st22_counts  EQ 0.

       <FS_FIELD> = 'C511'.

      ELSE.

       <FS_FIELD> = 'C611'.

  ENDIF.

It should have 3 char: Xmn

X = C

m = color number from 1 to 9

n = 0 (intensified off) or 1 (intensified on)

Max

0 Kudos
338

Hi Durga,

Are you having a single field for output and also displaying single value?

If yes, then the code is correct, but since you have only one cell, its always selected.

Just try adding one more row and see.

thanks,
Shambu

0 Kudos
338

Hi Max,

Thanks with the reply..

I tried using 3 char as suggested still the same issue. No color display.

IF v_st22_counts  EQ 0.

       <FS_FIELD> = 'C51'.

      ELSE.

       <FS_FIELD> = 'C61'.

  ENDIF.

0 Kudos
338

Hi Shambu,

here my dynamic internal table is as follows:

0 Kudos
338

Hi Durga,

In the layout structure you also need to pass

gd_layout-REPORT     = sy-repid.

Also try with colour C600

regards,

Ashwin.

0 Kudos
338

Hi Durga,

And there is no need to Create fieldcatalouge for 'Color' when you dont want to show on the output.

regards,

Ashwin.

0 Kudos
338

Hi Durga,

This is because you are having single value in the ALV. The value displayed is selected by default.

You can see the change if you add one more entry to the internal table.

Thanks,

Shambu

0 Kudos
338

Hi Durga,

I have developed the program now and checked, it should showup colour for single entry also.

regards,

Ashwin.

0 Kudos
338

Hi

Durga is right

One thing the field for color has to be a CHAR 4 (not 3 I'm sorry)

I've created a new program based on yours, try it:

PARAMETERS: P_ERROR TYPE I,

             P_TIMES TYPE I.

*declaration:

TYPES: BEGIN OF TY_ST22_DUMP,

        COUNT TYPE CHAR4,

        COLOR(4) TYPE C,

       END OF TY_ST22_DUMP.

TYPES TY_ST22_DUMPS TYPE STANDARD TABLE OF  TY_ST22_DUMP.

DATA: V_ST22_COUNTS TYPE I.

DATA: GD_LAYOUT    TYPE LVC_S_LAYO.

DATA: W_ST22_DUMPS  TYPE TY_ST22_DUMPS.

DATA: T_ST22_P_INFOTAB TYPE RSDUMPTAB.

*Field catalogue:

DATA: LT_LVC_FIELDCATALOGUE TYPE LVC_T_FCAT,

       LS_LVC_FIELDCATALOGUE TYPE LVC_S_FCAT.

DATA L_TABLE  TYPE REF TO DATA.

DATA DYN_LINE TYPE REF TO DATA.

FIELD-SYMBOLS: <IT_TABLE> TYPE STANDARD TABLE,

                <FS_WA>    TYPE ANY,

               <FS_FIELD>  TYPE ANY.

DATA: G_ALV_GRID  TYPE REF TO CL_GUI_ALV_GRID.

DATA: G_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

START-OF-SELECTION.

   REFRESH LT_LVC_FIELDCATALOGUE.

   CLEAR LS_LVC_FIELDCATALOGUE.

*             Build Fieldcatalog

   LS_LVC_FIELDCATALOGUE-REPTEXT    = 'ST22  ABAP Dump Analysis'.

   LS_LVC_FIELDCATALOGUE-FIELDNAME = 'COUNT'.

   LS_LVC_FIELDCATALOGUE-COL_OPT   = 'X'.

   LS_LVC_FIELDCATALOGUE-DD_OUTLEN = '04'.

* LS_LVC_FIELDCATALOGUE-EMPHASIZE = 'C100'.

   APPEND LS_LVC_FIELDCATALOGUE TO LT_LVC_FIELDCATALOGUE.

   CLEAR LS_LVC_FIELDCATALOGUE.

   LS_LVC_FIELDCATALOGUE-REPTEXT    = 'COLOR'.

   LS_LVC_FIELDCATALOGUE-FIELDNAME  = 'COLOR'.

   LS_LVC_FIELDCATALOGUE-DATATYPE   = 'CHAR'.

   LS_LVC_FIELDCATALOGUE-INTTYPE    = 'C'.

   LS_LVC_FIELDCATALOGUE-INTLEN     = '4'.

   LS_LVC_FIELDCATALOGUE-NO_OUT     = 'X'.

   APPEND LS_LVC_FIELDCATALOGUE TO LT_LVC_FIELDCATALOGUE.

   CLEAR LS_LVC_FIELDCATALOGUE.

*Dynamic display of values in the fieldcatalogue and color display:

   CREATE DATA L_TABLE TYPE TY_ST22_DUMPS.

   ASSIGN L_TABLE->* TO <IT_TABLE>.

   CREATE DATA DYN_LINE LIKE LINE OF <IT_TABLE>.

   ASSIGN DYN_LINE->* TO <FS_WA>.

   ASSIGN COMPONENT 1 OF STRUCTURE <FS_WA> TO <FS_FIELD>.

   MOVE P_ERROR TO <FS_FIELD>.

   ASSIGN COMPONENT 2 OF STRUCTURE <FS_WA> TO <FS_FIELD>.

   IF P_ERROR  EQ 0.

     <FS_FIELD> = 'C511'. "Green

   ELSE.

     <FS_FIELD> = 'C611'. "Red

   ENDIF.

   IF P_TIMES = 0.

     APPEND <FS_WA> TO <IT_TABLE>.

   ELSE.

     DO P_TIMES TIMES.

       APPEND <FS_WA> TO <IT_TABLE>.

     ENDDO.

   ENDIF.

   GD_LAYOUT-INFO_FNAME = 'COLOR'.

   CALL SCREEN 100.

MODULE PBO OUTPUT.

   CHECK G_CONTAINER IS INITIAL.

   CREATE OBJECT G_CONTAINER

     EXPORTING

       CONTAINER_NAME = 'MY_CONTAINER'.

   CREATE OBJECT G_ALV_GRID

     EXPORTING

       I_PARENT = G_CONTAINER.

   CALL METHOD G_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY

     EXPORTING

       I_DEFAULT                     = 'X'

       IS_LAYOUT                     = GD_LAYOUT

     CHANGING

       IT_OUTTAB                     = <IT_TABLE>

       IT_FIELDCATALOG               = LT_LVC_FIELDCATALOGUE

     EXCEPTIONS

       INVALID_PARAMETER_COMBINATION = 1

       PROGRAM_ERROR                 = 2

       TOO_MANY_LINES                = 3

       OTHERS                        = 4.

   IF SY-SUBRC <> 0.

   ENDIF  .

ENDMODULE.                 " PBO  OUTPUT

Max

0 Kudos
338

can i have the sample program which u developed and the parameters passed

0 Kudos
338

My internal table has always 1 row of data only. It just displays the dump count

0 Kudos
338

Tried with the program..still same issue..

0 Kudos
338

Hi

The problem is you've have one row only: you're program works fine, only the field EMPHASIZE has to be blank

Max

0 Kudos
338

Hi Max,

I have not used emphasize parameter in the filed catalog.It is blank

Regards,

Durga

0 Kudos
338

TYPES: BEGIN OF ty_outtab,
        name TYPE string,
        age  TYPE c,
        colour(4) TYPE c,
       END OF ty_outtab.

DATA: dt_outtab TYPE STANDARD TABLE OF ty_outtab,
      ds_outtab TYPE ty_outtab.

DATA: obj_grid    TYPE REF TO cl_gui_alv_grid.
DATA: obj_custom_container  TYPE REF TO cl_gui_custom_container.
DATA: gs_layout  TYPE lvc_s_layo.

DATA: dt_fcat    TYPE lvc_t_fcat,
      ds_fldcat  TYPE lvc_s_fcat.
*&---------------------------------------------------------------------*
*&              S T A R T - O F - S E L E C T I O N                    *
*&---------------------------------------------------------------------*
START-OF-SELECTION.

  ds_fldcat-row_pos   = '1'.
  ds_fldcat-col_pos   = '1'.
  ds_fldcat-fieldname = 'NAME'.
  ds_fldcat-tabname   = 'DT_OUTTAB'.
  ds_fldcat-just      = 'L'.
  ds_fldcat-outputlen = '10'.
  ds_fldcat-icon = 'X'.
  APPEND ds_fldcat TO dt_fcat.
  CLEAR ds_fldcat.

  ds_fldcat-row_pos   = '1'.
  ds_fldcat-col_pos   = '2'.
  ds_fldcat-fieldname = 'AGE'.
  ds_fldcat-tabname   = 'DT_OUTTAB'.
  ds_fldcat-just      = 'L'.
  ds_fldcat-outputlen = '0'.
  APPEND ds_fldcat TO dt_fcat.
  CLEAR ds_fldcat.

  ds_outtab-name = 'TEST'.
  ds_outtab-age  = '12'.
  ds_outtab-colour = 'C600'.
  APPEND ds_outtab TO dt_outtab.

  CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  ALV  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE alv OUTPUT.


  CREATE OBJECT obj_custom_container
      EXPORTING
*    PARENT                      =
        container_name              = 'CONTROL_AREA'
*    STYLE                       =
*    LIFETIME                    = LIFETIME_DEFAULT
*    REPID                       =
*    DYNNR                       =
*    NO_AUTODEF_PROGID_DYNNR     =
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        OTHERS                      = 6
        .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*----Creating ALV Grid instance
  CREATE OBJECT obj_grid
    EXPORTING
      i_parent          = obj_custom_container
    EXCEPTIONS
      error_cntl_create = 1
      error_cntl_init   = 2
      error_cntl_link   = 3
      error_dp_create   = 4
      OTHERS            = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  gs_layout-info_fname = 'COLOUR'.
  gs_layout-grid_title = text-001.
  gs_layout-no_rowmark = 'X'.
  gs_layout-zebra      = 'X'.
*  GS_VARIANT-REPORT     = sy-repid.

  CALL METHOD obj_grid->set_table_for_first_display
    EXPORTING
      is_layout                     = gs_layout
    CHANGING
      it_outtab                     = dt_outtab[]
      it_fieldcatalog               = dt_fcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  CALL METHOD obj_grid->refresh_table_display
*  EXPORTING
*    is_stable      =
*    i_soft_refresh =
*  EXCEPTIONS
*    finished       = 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.


ENDMODULE.                 " ALV  OUTPUT

0 Kudos
338

Hi

but if you've only one row, the cell will be always YELLOW because it's always markes as current line

Max

0 Kudos
338

any alternative solution please...

0 Kudos
338

Hi

I don't think if you use the GRID, you should use ALV LIST

Max

0 Kudos
338

Thanks Shambu for the help. tried passing one more row. it worked.

Regards,

Durga

kumud
Active Contributor
0 Kudos
338

Hello,

Why is NO_OUT field set to 'X' for the second column?

Regards,

Kumud

Former Member
0 Kudos
338

Hi

The field COLOR is just a tecnical field for row color management, theoretically that field doesn't need to be loaded in catalog table.

Max