Application Development and Automation 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: 
Read only

ALV

Former Member
0 Likes
759

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

8 REPLIES 8
Read only

Former Member
0 Likes
724
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.
Read only

0 Likes
724

Its going for a dump with short text as

' Short text in processing a internal table '

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
724

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

Read only

0 Likes
724

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.

Read only

0 Likes
724

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.

Read only

0 Likes
724

Jonathan, you code seems a bit unorganized, to help you better, please post the entire code of your program, or email it directly to my email address on my business card.

Also, you should have quotes around COLOR_LINE in this statement.

MOVE 'COLOR_LINE' TO LS_LAYOUT-INFO_FNAME.

Regards,

Rich Heilman

Read only

0 Likes
724

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

Read only

0 Likes
724

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..........