cancel
Showing results for 
Search instead for 
Did you mean: 

How to display a dynamic Row Count in ALV?

Former Member
0 Kudos

Hi All,

I need to display a row count in my ALV table.

It is suppose to be located within the ALV (header or preferably footer).

The row count must be calculated dynamically based on the current lines of the ALV (including any filter that the user may apply).

Best Regards,

Aviad

Accepted Solutions (1)

Accepted Solutions (1)

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Aviad,

The following lines of code will show the row count in the last line.

DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

   lo_interfacecontroller =   wd_this->wd_cpifc_<Your ALV component usage name>( ).

   DATA lv_value TYPE REF TO cl_salv_wd_config_table.

   lv_value = lo_interfacecontroller->get_model(

   ).

   CALL METHOD lv_value->if_salv_wd_std_functions~set_count_records_allowed

    EXPORTING

      value = abap_true.

  CALL METHOD lv_value->if_salv_wd_field_settings~set_count_records_enabled

    EXPORTING

      value = abap_true.


The result is as below:

Initially without any filter


After applying filter:

Let me know if does not help you. there is some other way.

Regards,

Ajit

Former Member
0 Kudos

Hi,

This is the functionality that I needed but I want it to be displayed at the toolbar or the footer.

Best Regards,

Aviad

former_member216769
Participant
0 Kudos

Hi Aviad,

You can achive this functionality to display no of entries after filter criteria on your ALV toolbar.

=> Create and input field with label which will display no of entries.

          Set READY_ONLY property of input field.

=> Create an node to store entry value

          Node name: FUNCTION_ELEMENT

          Attribute: ENTRIES type string.

=> Bind the above node to  node 'FUNCTION_ELEMENT' of ALV interfacecontroller_usage.

=> Create an method in your view to calculate entries

     Method type: EVENT HANDLER

     Event: ON_STD_FUNCTION_AFTE of your ALV component

=> Write below code.

     Data: lt_entries type if_SALV_bs=>t_type_row,

               lt_entries_out type if_SALV_bs=>t_type_row.

     Fetch the node entries into an internal table which you have used to display data  on ALV.

     CL_SALV_WD_FILTER_EXECUTE(

          EXPORTING

               T_INPUT               =     INTERNAL-TABLE

               T_FIELDS              =     ALV_MODEL->IF_SALV_WD_FIELD_SETTINGS~T_FIELDS

          CHANGING

               T-ROWS                    =     LT_ENTRIES

               T_ROWS_OUTSIDE     = LT_ENTRIES_OUT

          EXPECTIONS

               NO_FILTER-RULES     =  1 ).

     DESCRIBE TABLE LT_ENTRIES LINES L_ENTRIES.

     Bind L_entries to node FUNCTION_ELEMENT->ENTRIES.

In this way you can have no of entries on your ALV toolbar.

Output attached...

Hope with will help you...

Former Member
0 Kudos

Hi Manikandan D Nair,

After copying the code I get the following error:

Method "CL_SALV_WD_FILTER_EXECUTE" is unknown or PROTECTED or PRIVATE.

Edited:

It suppose to be CL_SALV_WD_FILTER=>EXECUTE

Aviad

Message was edited by: Aviad Levy

Former Member
0 Kudos

Hi,

Just a few minor adjustments

CALL METHOD cl_salv_wd_filter=>execute(

     EXPORTING

       t_input         = <INTERNAL-TABLE>

       t_fields        = lo_value->if_salv_wd_field_settings~t_fields

     CHANGING

       t_rows             = lt_entries

       t_row_outside   = lt_entries_out

     EXCEPTIONS

       no_filter_rules = 1 ).

   IF sy-subrc EQ 0.

     DESCRIBE TABLE lt_entries LINES l_entries.

   ELSE.

     DESCRIBE TABLE <INTERNAL-TABLE> LINES l_entries.

   ENDIF.


Aviad

former_member216769
Participant
0 Kudos

Hi Aviad,

Yes it was a typo mistake...

I hope it helped to achieve your functionality

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

When you scroll the records in ALV table,It automatically shows the row count.

PFB the snapshot for reference.

Thanks

KH

Former Member
0 Kudos

Hi,

I want it to be shown always.

Aviad

Former Member
0 Kudos

Hi,

You can create a attribute to store no. of records of itab ( By using DESCRIBE  TABLE <ITAB> ) which you've binded to your ALV table and display that attribute.

Thanks

KH

Former Member
0 Kudos

Hi,

This will not show changes made by filtering.

Aviad