‎2006 Oct 19 3:22 PM
hello,
Is this code right for coloring a row...
READ TABLE GT_BPSTAB ASSIGNING <GT_BPSTAB> INDEX LV_COUNTER.
IF LV_COUNTER = 12.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-EMPHASIZE = 'C610'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
IF LV_COUNTER = 13.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-EMPHASIZE = 'C910'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
LS_LAYOUT-INFO_FNAME = 'COLOR_LINE'.
*append GT_FIELDCATALOG to LT_FIELDCATALOG.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'GT_STRUCT'
I_SAVE = X_SAVE
I_DEFAULT = LV_DEF
IS_LAYOUT = LS_LAYOUT
CHANGING
IT_OUTTAB = GT_BPSTAB[]
IT_FIELDCATALOG = GT_FIELDCATALOG[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
‎2006 Oct 19 3:25 PM
use modify
IF LV_COUNTER = 12.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-EMPHASIZE = 'C610'.
<b>modify GT_BPSTAB from _BPSTAB .</b>
ENDIF.
IF LV_COUNTER = 13.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
<b>WA_BPSTAB-EMPHASIZE = 'C910'.
modify GT_BPSTAB from _BPSTAB .</b>
ENDIF.
‎2006 Oct 19 3:44 PM
Its going for a dump with short text as
' Short text in processing a internal table '
‎2006 Oct 19 3:53 PM
No, that logic is not correct for coloring a row. You need to add a field to your internal table G_BPSTAB.
Call it color_line.
....
color_line(4) type c, " Line color
....Just before calling the SET_TABLE_FOR_FIRST_DISPLAY method, add coding like this to tell the ALV that COLOR_LINE is the field that will be used to determine the color.
<b> data is_layout type lvc_s_layo,
* Field that identify color line in internal table
move 'COLOR_LINE' to is_layout-info_fname.</b>
call method w_alv_grid->set_table_for_first_display
exporting
<b> is_layout = is_layout</b>
I_STRUCTURE_NAME = 'GT_STRUCT'
I_SAVE = X_SAVE
I_DEFAULT = LV_DEF
IS_LAYOUT = LS_LAYOUT
CHANGING
IT_OUTTAB = GT_BPSTAB[]
IT_FIELDCATALOG = GT_FIELDCATALOG[]
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
Now when filling your internal table, you can simply assign the color code to this field.
wa_BPSTAB-COLOR_LINE = 'C610'.
append wa_bdstab to gt_bpstab.Regards,
Rich Heilman
‎2006 Oct 19 4:52 PM
Hello Rich & Friends,
I am trying this way, but the display is not getting colored.
what can i do now....
MOVE COLOR_LINE TO LS_LAYOUT-INFO_FNAME.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'gt_STRUCT'
I_SAVE = X_SAVE
I_DEFAULT = LV_DEF
IS_LAYOUT = LS_LAYOUT
CHANGING
IT_OUTTAB = GT_BPSTAB[]
IT_FIELDCATALOG = GT_FIELDCATALOG[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF LV_COUNTER = 12.
WA_BPSTAB-COLOR_LINE = 'C610'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
IF LV_COUNTER = 13.
WA_BPSTAB-COLOR_LINE = 'C910'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
ENDIF.
‎2006 Oct 19 4:54 PM
Hello Rich & Friends,
I am trying this way, but the display is not getting colored.
what can i do now....
MOVE COLOR_LINE TO LS_LAYOUT-INFO_FNAME.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'gt_STRUCT'
I_SAVE = X_SAVE
I_DEFAULT = LV_DEF
IS_LAYOUT = LS_LAYOUT
CHANGING
IT_OUTTAB = GT_BPSTAB[]
IT_FIELDCATALOG = GT_FIELDCATALOG[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF LV_COUNTER = 12.
WA_BPSTAB-COLOR_LINE = 'C610'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
IF LV_COUNTER = 13.
WA_BPSTAB-COLOR_LINE = 'C910'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
ENDIF.
‎2006 Oct 19 4:59 PM
‎2006 Oct 19 5:30 PM
MOVE 'COLOR_LINE' TO LS_LAYOUT-INFO_FNAME.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'GT_STRUCT'
I_SAVE = X_SAVE
I_DEFAULT = LV_DEF
IS_LAYOUT = LS_LAYOUT
CHANGING
IT_OUTTAB = GT_BPSTAB[]
IT_FIELDCATALOG = GT_FIELDCATALOG[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**
IF LV_COUNTER = 12.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-COLOR_LINE = 'C610'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
IF LV_COUNTER = 13.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-COLOR_LINE = 'C910'.
APPEND WA_BPSTAB TO GT_BPSTAB.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
CALL METHOD CL_GUI_CFW=>DISPATCH.
CASE OK_CODE.
WHEN 'BACK'.
PERFORM BACK .
WHEN 'EXIT'.
PERFORM EXIT_PROGRAM.
WHEN 'RETURN'.
PERFORM BACK .
ENDCASE .
ENDMODULE. " USER_COMMAND_0100 INPUT
Message was edited by: Jonathan Gabriel
‎2006 Oct 20 9:31 AM
Hello Rich & SDN friends,
Code is syntactically correct & getting activated.
But the display is getting colored from first line to line 13.
I want two differenet colors on line 12 & line 13..
How to solve this..........