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 GRID: How to change Subtotal and Main total values in standard row

Former Member
0 Kudos

Hi Experts,

By using SORT-SUBTOT = 'X' and FIELDCATALOG-DO_SUM = 'X', I will get subtotal and Main total.

My requiremnt is I need be calculate values manually and pass the calculated values to subtotal and maintotal.

is it possible in ALV GRID?

By adding extra row we will do this but I am looking standard subtotal and maintotal row change.

Thanks in advance,

Mahe

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

With function REUSE_ALV_GRID_DISPLAY you cannot do this.

It´s possible if you create a class inherited from cl_gui_alv_grid and rewrite the method set_data_table, you can do this. Like:


CLASS xgrid DEFINITION INHERITING FROM cl_gui_alv_grid.

  PROTECTED SECTION.

    METHODS: set_data_table REDEFINITION.

ENDCLASS.                    "xgrid DEFINITION


CLASS xgrid IMPLEMENTATION.

  METHOD set_data_table.

* ....MODIFY data_table ...

    CALL METHOD super->set_data_table
      CHANGING
        data_table = data_table.

  ENDMETHOD.                    "set_data_table

ENDCLASS.                    "xgrid IMPLEMENTATION

 DATA:    grid  TYPE REF TO xgrid.

  CREATE OBJECT custom_container EXPORTING container_name = mycontainer.

  CREATE OBJECT grid  EXPORTING i_parent = custom_container.

  CALL METHOD grid1->set_table_for_first_display ...

Best regards,

Leandro Mengue

3 REPLIES 3

naveen_inuganti2
Active Contributor
0 Kudos

Hi,

I don't think you can do that with normal effort. Because you might need to manipulate some standard methods.

Why don't you try in this way.. add one extra row at each subtotal level and to get required values in standard subtotal line. And hide added row by using layout option.

When I am answering this question, I felt... 'You must be working for interesting client!'.

Thanks,

Naveen.I

Former Member
0 Kudos

Hi,

With function REUSE_ALV_GRID_DISPLAY you cannot do this.

It´s possible if you create a class inherited from cl_gui_alv_grid and rewrite the method set_data_table, you can do this. Like:


CLASS xgrid DEFINITION INHERITING FROM cl_gui_alv_grid.

  PROTECTED SECTION.

    METHODS: set_data_table REDEFINITION.

ENDCLASS.                    "xgrid DEFINITION


CLASS xgrid IMPLEMENTATION.

  METHOD set_data_table.

* ....MODIFY data_table ...

    CALL METHOD super->set_data_table
      CHANGING
        data_table = data_table.

  ENDMETHOD.                    "set_data_table

ENDCLASS.                    "xgrid IMPLEMENTATION

 DATA:    grid  TYPE REF TO xgrid.

  CREATE OBJECT custom_container EXPORTING container_name = mycontainer.

  CREATE OBJECT grid  EXPORTING i_parent = custom_container.

  CALL METHOD grid1->set_table_for_first_display ...

Best regards,

Leandro Mengue

Former Member
0 Kudos

Hi,

I am having a similar requirement. I am trying to edit the ALV total & subtotal lines. I am half successful but stuck with the packet size problem.

Please find the details of my problem in the thread

Can you please share how you solved this?

Regards,

Immanuel