cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Row Counter

Former Member
0 Kudos
284

Hi All - I have an ALV table that display 15 row; if the ALV has more than 15 records let's say 1000 row on the vertical scroll bar will display row 20 of 1000 or 31 of 1000 (feature that ALV default for the user)

I want to display that same logic but in a text out of the ALV, how I can read all the rows of the ALV and display...i.e. "856 records displaying" and also if the user select row 754 it should say "you have selected row 754 out of 1000 records"

Is this possible?

Thanks!

Jason P-V

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

how I can read all the rows of the ALV

For this, just read the node using get_static_Attributes_table method. It will return all rows in ALV.

DATA lo_nd_cn_table TYPE REF TO if_wd_context_node.

DATA it_table TYPE wd_this->elements_cn_table.

  • navigate from <CONTEXT> to <CN_TABLE> via lead selection

lo_nd_cn_table = wd_context->get_child_node( name = wd_this->wdctx_cn_table ).

lo_nd_cn_table->get_static_attributes_table( IMPORTING table = lt_table).

Former Member
0 Kudos

What I mean with reading the ALV row is reading the number of rows, the data has been already displayed in the ALV I just need to display the i.e. "2153 recods available or displaying"

Former Member
0 Kudos

Use this statement to get the number of rows in internal table :

describe table lt_table lines last_row.

Here lt_table is internal table having a number of records.

last row is a variable type I which will have number of records whether 1 , 2 or 1000.

Answers (2)

Answers (2)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Create an attribute index in the context.

dont display it in front end but update the value of it in the back end.

When you want to display 800 records displaying.

you first read the table using get_static_attributes_table and once you get the table itab.

you can read the no.of lines in the table using

DESCRIBE TABLE itab LINES ln.

so ln will hold the no.of records.

display this value in the front end.

to display the lead seleced row no.

on lead select event ,use get_static_attributes it will hold the lead selected value.

since index is also part of the context attribute which is bound to table you can get the index value also from this.

lo_el_sap_prj_experience->get_static_attributes(

IMPORTING

static_attributes = ls_sap_prj_experience ).

pass ls_sap_prj_experience-index to some variable and display it in front end.

Priya

Former Member
0 Kudos

if the user select row 754 it should say "you have selected row 754 out of 1000 records

For this, implement the ON_LEAD_SELECT Event in your Methods tab, Inside this event you will get the index of row selected using :

data : lv_index type I.

lv_index = r_param->index.

With index of row selected, now you can display message.

Former Member
0 Kudos

Saurav Mago - thanks for the input, that's right the ON_LEAD_SELECT will display have the index of the row, but how I will display i.e 567 (index) out of 1000 row, I need the 1000 now that I have the index.

it can be 1000 or 4 records, I need the total line available in the ALV.

Thanks!

Jason P-V

Former Member
0 Kudos

Use this :

In Internal table you will have all records. Using code given before , you will get data in internal table. Now get the index of last row which will indicate the number of records in table(ALV).

data last_row type I.

describe table itab lines last_row.

DATA lo_nd_cn_table TYPE REF TO if_wd_context_node.

DATA it_table TYPE wd_this->elements_cn_table.

  • navigate from <CONTEXT> to <CN_TABLE> via lead selection

lo_nd_cn_table = wd_context->get_child_node( name = wd_this->wdctx_cn_table ).

lo_nd_cn_table->get_static_attributes_table( IMPORTING table = lt_table).

data last_row type I.

describe table lt_table lines last_row.

Edited by: Saurav Mago on Nov 17, 2009 9:26 AM

Former Member
0 Kudos

Can you add DATA statement with that answer?

The itab will be an itab of the ALV node?

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

itab hold the value of the ALV table whe you call that get_static_attributes_table throug wizard u will get the data declarations automatically

Priya

Former Member
0 Kudos

The itab will be an itab of the ALV node?

Here itab will hold all the records whichever is displayed in ALV table.

But you want only number of rows in ALV so use describe statement as explained.

Data Itab TYPE wd_this->elements_cn_table.

Here cn_table is my node.

Edited by: Saurav Mago on Nov 17, 2009 9:35 AM

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

yes it should be of the type of ALV node.

Priya

Former Member
0 Kudos

Priya & Saurav Mago - thank you for your quick response I will implement your inputs.

Thanks!

Jason P-V