cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a number of Link to Actions based on the Output of an ALV

Former Member
0 Kudos

Hello Experts,

I have an ALV table as an output in WDA in which the number of records are unknown.

I want to limit the number of records to 500 at a point of time.

Below the table i need to have link to actions placed like 1-500 501-1000 10001-1500 and so on.

As the number of records are unknown i need to have these link to actions divided among total records.

And if the table shows 1-500 records the Link to Action 1-500 should become text so that the user will not be able to click on it.

So my requirement is

1.How to limit the number of records to 500.

2.How to place the link to actions dynamically based on the number of output records.

3.How to change the Link to Action to Text.

Please help me in this.

Thanks in Advance,

Shravan

Accepted Solutions (1)

Accepted Solutions (1)

former_member199125
Active Contributor
0 Kudos

Hi Sharma,

1.How to limit the number of records to 500.

2.How to place the link to actions dynamically based on the number of output records.

3.How to change the Link to Action to Text.

1) lo_value->if_salv_wd_table_settings~set_Visible_row_count( 500 ).

2)

after bind the table to data node of alv interface controller...you can get number of elements in node by using below statement

data count type i.

count = lo_nd_itab->get_element_count( ).

so now based on count value write your dynamic code.

for dynamic link to url

data root type ref to cl_Wd_uielement_container.

data lurl type ref to cl_wd_link_to_url.

root ?= view->get_element( 'ROOTUIELEMENTCONTAINER' )

LURL = CL_WD_LINK_TO_URL->NEW_LINK_TO_URL( TEXT = 'XXXX' ).

CL_WD_FLOWDATA=>NEW_FLOW_dATA( ELEMENT = LURL ).

ROOT->ADD_CHILD( LURL ).

ALTERNATIVE SOLU FOR 2

CREATE 4 LINK TO URL ELEMENTS 1-500 501-1000 10001-1500

BASED UP ON COUNT VALUE , HANDLE THEIR VISIBILITY.. USING WDYI_VISIBILITY ATTRIBUTE.

3)u WANT TO ENABLE OR DISABLE ? THEN USE WDY_BOOLEAN ATTRIBUTE.

If you got any queries in above , let me know

Regards

Srinivas

Answers (2)

Answers (2)

saravanan_narayanan
Active Contributor
0 Kudos

Hello Shravan,

Just a clarification about your requirement

you mentioned that

>>And if the table shows 1-500 records the Link to Action 1-500 should become text so that the user will not be able to click on it

Thus it mean that if you display links 1-500, 501-1000 and if user is viewing the 2nd set i.e. 501-1000 of records then you want the link 501-1000 to appear as Text. If so then how are you planning to tackle the table scrolling. In the sense user can scroll through the records via scroll bar. Are you planning to disable the scrolling?

BR, Saravanan

Former Member
0 Kudos

Hi Saravanan,

Thanks for your reply.

At a time only 500 records will get fetched into the ALV table.

And on click of the Link to Action 501-1000 i will be calling another method which fetches the next 500 records into the table.

Hope it is clear....

Thanks,

Shravan

saravanan_narayanan
Active Contributor
0 Kudos

Hello Shravan,

If you know the total number of records at runtime then its simple. Otherwise you need to write some complex logic. I assume that at runtime while launching the application you will know the total number records .

1.How to limit the number of records to 500.

As Srinivas mentioned call the set_visible_row_count method by passing 500

2.How to place the link to actions dynamically based on the number of output records.

Logic for the same.



data i_total type i value 1250. "say total number of records
data i_max type i value 500. "your max records to be displayed in aLV at anypoint of time
data i_num type i.
data i_rem type i.
i_num = i_total div i_max.
i_rem = i_total mod i_max.

data lv_end_text type string.
data lv_start_text type string.
data lv_final_text type string.
data i_start type i.
data i_end type i.

do i_num times.

  i_start = ( i_max * ( sy-index - 1 ) + 1 ).
  lv_start_text = i_start.
  i_end = i_max * sy-index.
  lv_end_text = i_end.
  concatenate lv_start_text ' - ' lv_end_text into lv_final_text RESPECTING BLANKS.

   "Write the logic to create the Link to Action - as suggested by Srinivas

enddo.

if i_rem > 0.
  i_start  = i_max * i_num + 1.
  lv_start_text = i_start.
  i_end = i_max * i_num + i_rem.
  lv_end_text = i_end.
  concatenate lv_start_text ' - ' lv_end_text into lv_final_text RESPECTING BLANKS.

 " Write the logic to add the last linkToAction
endif.

3.How to change the Link to Action to Text.

If you set the enable property of the LinkToAction to abap_false then it will be disabled and displayed as text.

Hope this helps.

BR, Saravanan

Former Member
0 Kudos

Hi Sharan,

You can check like this..

* navigate from <CONTEXT> to <N_ERROR_LOG> via lead selection
  lo_nd_n_error_log = wd_context->get_child_node( name = wd_this->wdctx_n_error_log ).

  lo_nd_n_error_log->get_static_attributes_table( importing table = lt_n_error_log ).

  count = LINES( lt_n_error_log ).

  lt_table_settings  = wd_this->alv_model.
  lt_column_settings = wd_this->alv_model.

  IF count > 500

  you can create link to actions dynamically here..

  ELSE if   IF count > 1000
you can create link to actions dynamically here..

  ELSE if   IF count > 1500
you can create link to actions dynamically here..

  ENDIF.

But my doubt is how you can limit no of records on database. i think you can't stop at some point.

Think with above logic, may you get something.

Cheers,

Kris.