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: 

ALV alternate batches rows color messed up after sorting

siongchao_ng
Contributor
0 Kudos

Hi all,

Recently I have a requirement that requires me to change color alv rows alternately according to batches of a process order. I set the color according to batches of odd and even. Meaning like assign green to odd batches and yellow to even batches.

So example, after I have an internal table, the color will be displayed like:

Batch

1              Green

1              Green

1              Green

2               Yellow

2               Yellow

3               Green

4               Yellow

4                Yellow

4                Yellow

4                 Yellow

5                Green

5                Green

Problem: After display when user did some sorting to other columns, the displayed will be messed since batches will be resorted and I can have situation like:

Batch

1               Green

1                Green

1                Green

5                Green

5                Green

2                Yellow

2                Yellow

3                 Green

4                Yellow

4                Yellow

4                 Yellow

4                 Yellow

Notice the Batch 1 and Batch 5 are placed next to each other and same color.

Anyone have any idea whether color can be changed after user re-sort the alv table?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Siong,

The process is a bit tedious.....

DATA : wa_eve TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

      i_list_type     = 0

    IMPORTING

      et_events       = t_eve

    EXCEPTIONS

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

  READ TABLE t_eve WITH KEY name =   'GROUPLEVEL_CHANGE'.

                                            INTO wa_eve.

  IF sy-subrc = 0.

    MOVE 'GROUPLEVEL_CHANGE' TO wa_eve-form.

    APPEND t_eve FROM wa_eve INDEX sy-tabix.

  ENDIF.

Now....

Create a PERFORM.

FORM GROUPLEVEL_CHANGE USING LINFO TYPE KKBLO_LINEINFO

                             GROUP TYPE KKBLO_GROUPLEVELS.

In This Perform

You can use FM reuse_alv_grid_layout_info_get to get the sort order re-process the data accordingly.

And then referesh the display

DATA : e_grid TYPE REF TO cl_gui_alv_grid.

  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    IMPORTING

      e_grid = e_grid.

  CALL METHOD e_grid->check_changed_data.

  "update_alv_tab

  CALL METHOD e_grid->refresh_table_display.

Regards

.

9 REPLIES 9

Former Member
0 Kudos

Create another field (Number) which don't display in the table AFTER sorting. Use this number to to determine the color.

Number    Batch

1                  1               Green

1                  1                Green

1                  1                Green

2                  5                Yellow

2                  5                Yellow

3                  2                Green

3                   2               Green

4                  3                Yellow

5                   4               Green

5                   4                Green

5                   4               Green

5                   4                Green

to renumber the Batch and change the color after user action, please refer to this, page 36 onwards,

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415...

arindam_m
Active Contributor
0 Kudos

Hi,

May be you have to do a custom class based on CL_SALV_SORTS and then may be do a custom method in that to build the color coding again, something like a refresh. Link to get started with to know more on the class.

http://help.sap.com/saphelp_erp2004/helpdata/en/e9/e5eb40c4f8712ae10000000a155106/content.htm

Other way may be to reproduce the ALV again with the sort info.. but this might be a bad way as you will need to re do the whole grid every time SORT happens.

Cheers,

Arindam

0 Kudos

Hi Arindam,

I am using the   REUSE_ALV_GRID_DISPLAY FM so class method not applicable here.

How can I re-produce the ALV again once the FM has been run?

Former Member
0 Kudos

to renumber the Batch and change the color after user action, please refer to this, page 36 onwards,

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415...

0 Kudos

Hi Siong Chao Ng,

I set the color according to batches of odd and even. Meaning like assign green to odd batches and yellow to even batches.

You assigned colors according to batches ODD and EVEN  1 and 5 are odd so it is giving green.

0 Kudos

Hi ramesh,

Do you have even better idea of assigning colors?

Former Member
0 Kudos

Hi Siong,

The process is a bit tedious.....

DATA : wa_eve TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

      i_list_type     = 0

    IMPORTING

      et_events       = t_eve

    EXCEPTIONS

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

  READ TABLE t_eve WITH KEY name =   'GROUPLEVEL_CHANGE'.

                                            INTO wa_eve.

  IF sy-subrc = 0.

    MOVE 'GROUPLEVEL_CHANGE' TO wa_eve-form.

    APPEND t_eve FROM wa_eve INDEX sy-tabix.

  ENDIF.

Now....

Create a PERFORM.

FORM GROUPLEVEL_CHANGE USING LINFO TYPE KKBLO_LINEINFO

                             GROUP TYPE KKBLO_GROUPLEVELS.

In This Perform

You can use FM reuse_alv_grid_layout_info_get to get the sort order re-process the data accordingly.

And then referesh the display

DATA : e_grid TYPE REF TO cl_gui_alv_grid.

  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    IMPORTING

      e_grid = e_grid.

  CALL METHOD e_grid->check_changed_data.

  "update_alv_tab

  CALL METHOD e_grid->refresh_table_display.

Regards

.

0 Kudos

Hi Yakub,

I assume that the GROUPLEVEL_CHANGE refer to getting user's sort action? and do I call the 'REUSE_ALV_EVENTS_GET' fm before my   REUSE_ALV_GRID_DISPLAY fm or after

  REUSE_ALV_GRID_DISPLAY FM?

0 Kudos