on 12-24-2013 4:46 AM
1. i am displaying the ALv report in wd abap, and i have Created two button like : Next and Previous.
2. Req is : Initially i need to display in the alv only 10 records, and if i click Next button next 10 i need to disply.
and if i click Previous i need to display previous 10 records.
Please it is emergency requirement, please can any one help me on this.
Thanks in advance.
Regards,
Venugopal.
hi, venu keep this code inside view.
on next button action:
_________________________
method ONACTIONNEXT .
wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC1 + 1.
wd_this->V_COUNT_REC2 = wd_this->V_COUNT_REC1 + 10.
DATA lo_nd_cust_detail TYPE REF TO if_wd_context_node.
DATA lt_cust_detail TYPE wd_this->Elements_cust_detail.
* navigate from <CONTEXT> to <CUST_DETAIL> via lead selection
lo_nd_cust_detail = wd_context->get_child_node( name = wd_this->wdctx_cust_detail ).
* @TODO handle non existant child
* IF lo_nd_cust_detail IS INITIAL.
* ENDIF.
* * @TODO compute values
* * e.g. call a model function
*
data:wa_cust1 like line of lt_cust_detail,
it_cust1 like lt_cust_detail.
select * from kna1 into corresponding fields of table lt_cust_detail.
LOOP AT lt_cust_detail into wa_cust1.
IF sy-tabix = wd_this->V_COUNT_REC1.
append wa_cust1 to it_cust1.
wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC1 + 1.
ENDIF.
IF wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC2.
lo_nd_cust_detail->bind_table( new_items = it_cust1 set_initial_elements = abap_true ).
wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC1 - 1.
exit.
ENDIF.
ENDLOOP.
endmethod.
on previous button action:
______________________________
method ONACTIONPREVIOUS .
IF wd_this->V_COUNT_REC1 >= 20.
wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC1 - 19.
wd_this->V_COUNT_REC2 = wd_this->V_COUNT_REC1 + 10.
DATA lo_nd_cust_detail TYPE REF TO if_wd_context_node.
DATA lt_cust_detail TYPE wd_this->Elements_cust_detail.
* navigate from <CONTEXT> to <CUST_DETAIL> via lead selection
lo_nd_cust_detail = wd_context->get_child_node( name = wd_this->wdctx_cust_detail ).
* @TODO handle non existant child
* IF lo_nd_cust_detail IS INITIAL.
* ENDIF.
* * @TODO compute values
* * e.g. call a model function
*
data:wa_cust1 like line of lt_cust_detail,
it_cust1 like lt_cust_detail.
select * from kna1 into corresponding fields of table lt_cust_detail.
LOOP AT lt_cust_detail into wa_cust1.
IF sy-tabix = wd_this->V_COUNT_REC1.
append wa_cust1 to it_cust1.
wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC1 + 1.
ENDIF.
IF wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC2.
lo_nd_cust_detail->bind_table( new_items = it_cust1 set_initial_elements = abap_true ).
wd_this->V_COUNT_REC1 = wd_this->V_COUNT_REC1 - 1.
exit.
ENDIF.
ENDLOOP.
ENDIF.
endmethod.
**************************************************************
declare V_COUNT_REC1 and V_COUNT_REC2 as integer type in attribute of view
change the variable name accordingly but implement the logic as i implemented here.
****************************************************************
implement this code and provide me point if this code is necessary.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Great thanks to biswajit sahoo , you're coding is help full for my requirement.
i appreciate for your answer.
Regards,
Venugopal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for all for sharing your valuable information.
i am trying now..i will get back if any issues.
Thanks a lot for all.
Regards,
Venugopal.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
apply this logic
If you have a table with a simple primary key (i.e. only one key field), which is the case for E070 you can simply use something like this:
select * from E070 into table [internal table] up to ROW_LIMIT rows
where TRKORR > TRKORR_PREV
order by primary key.
pass the number of entries you want to get via parameter ROW_LIMIT and fill the value TRKORR_PREV with the highest value you previously read.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have tried this out and it works.
In your MAIN View, in Context Tab, create 2 attributes of type i, like count, count1.
This should be your select statement like:
select * from ekpo up to 10 rows into corresponding fields of table lt_potab where ebeln = lv_ponum
and ( ebelp >= lv_count and ebelp <= lv_count1 ).
Before the select statement initialize your count variables:
****(First get the count variables current value)
if lv_count is initial and lv_count1 is initial.
lv_count = '0000'.
lv_count1 = '0100'.
endif.
and after the select statement update your variables:
* set single attribute
lo_el_context->set_attribute(
name = `COUNT`
value = lv_count ).
lo_el_context->set_attribute(
name = `COUNT1`
value = lv_count1 ).
In your Next button Code
1) Get the current value of the variable count
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->Element_context.
DATA lv_count TYPE wd_this->Element_context-count.
DATA lv_count1 TYPE wd_this->Element_context-count1.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `COUNT`
IMPORTING
value = lv_count ).
lo_el_context->get_attribute(
EXPORTING
name = `COUNT1`
IMPORTING
value = lv_count1 ).
2) Add the next 10.
lv_count = lv_count + 100.
lv_count1 = lv_count1 + 100.
3) Set the values.
* set single attribute
lo_el_context->set_attribute(
name = `COUNT`
value = lv_count ).
lo_el_context->set_attribute(
name = `COUNT1`
value = lv_count1 ).
4) Call the method where you call the ALV
wd_this->po_data( ). this will reset the value
Now again get the values of count & count1 before your select * from ekpo statement as shown above ***.
Best Regards,
Fawaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venu,
If your Next & Previous records from database table, then you have to fetch the data again on action 'NEXT' & PREVIOUS buttons of alv, for this you have to keep unique field for ex. Item No or any of the number field as per your conditions...
But, In case if fetched 30 records in ALV Internal table,Now You are in 10 - 20 records, if you want to perform previous or next, the interface IF_SALV_WD_TABLE_SETTINGS will take care of, pls check with the method set_visible_rows..etc..
Message was edited by: Neil Gardiner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Define actions for those buttons and in handlers use method SET_FIRST_VISIBLE_ROW of IF_SALV_WD_TABLE_SETTINGS to set row.
Regards,
Sreenivas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sreenivasa Rao,
Thanks for you reply....
Please can you elaborate with example of this method.
My Req is : If i click On Next button in the same table i need to display next 10 records.....
and same way if i click Previous button, I needo to display Backward 10 records.
i have created actions for both but i am confusing for disply next 10 records coding...on action.
Regards,
Venugopal.
Hello for this you need to bind the Property Visible row count with some attribute and on next and previous increase and decrease the value of that.
But in that case on pressing of next 10+ value will be visible, means overall rows will be 10+ and again if you pressed next then 20+....
But i think you want to show 10 rows at a time, correct ? then in this case bind only 10 value in your node at a time, like calculate all data and sort it by some parameter and then store all data in some copy node. and on next calculate next 10 using copy node and fill in the main node.
Hi,
Write this code in your next action handler
* get ALV component
DATA:r_salv_wd_table TYPE REF TO iwci_salv_wd_table.
data lr_table_settings TYPE REF TO if_salv_wd_table_settings.
data alv_config_table type ref to CL_SALV_WD_CONFIG_TABLE
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
lr_table_settings ?= alv_config_table = lr_salv_wd_table->get_model( ).
Define N as view attribute and increase it by 10 each time
wd_this->N = wd_this->N +10
lr_table_settings->set_first_visible_row( N ).
Similarly in Previous action handler decrease by 10.
Regards,
Sreenivas.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.