on 2009 Feb 19 6:28 PM
Hi all, it´s me again, suffering like a mother with my first WDA serious application
I have this ALV with a prices column, with an editable checkbox field, and what my client wants is a field on the screen (I think it must be a Textview) that displays the total sum of all selected rows in the ALV. Of course, this sum must be dynamic, according with the actual selection.
Could anyone tell what should I do?
Thanks a lot, best regards.
Federico Alvarez
Hi Fedrico,
Seeing your problem, You hv to write the logic on the ON_DATA_CHECK event of the alv grid.
I am giving you a sample code that might helps you.
METHOD on_data_check .
Data declaration for assigning the contract,total and balance(remaining) amount
DATA : lo_nd_contract_payment TYPE REF TO if_wd_context_node,
lo_el_contract_payment TYPE REF TO if_wd_context_element,
ls_contract_payment TYPE wd_this->element_contract_payment,
lv_contract_amount LIKE ls_contract_payment-contract_amount,
lv_value_date LIKE ls_contract_payment-value_date.
Data Declaration
DATA : lo_nd_payment_table TYPE REF TO if_wd_context_node,
lo_el_payment_table TYPE REF TO if_wd_context_element,
ls_payment_table TYPE wd_this->element_payment_table,
lt_payment_table LIKE TABLE OF ls_payment_table,
lv_total_amount LIKE ls_payment_table-amount,
lv_balance_amount LIKE ls_payment_table-amount,
lv_paymeth LIKE ls_payment_table-payment_method,
lt_paycreate TYPE TABLE OF /dmpui/db_str_paycreate,
ls_paycreate TYPE /dmpui/db_str_paycreate.
Data declartion for message manager
DATA : lo_api_controller TYPE REF TO if_wd_controller,
lo_message_manager TYPE REF TO if_wd_message_manager.
get message manager
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
navigate from <CONTEXT> to <PAYMENT_TABLE> via lead selection
lo_nd_payment_table = wd_context->get_child_node( name = wd_this->wdctx_payment_table ).
check for data error in the grid
CHECK r_param->t_error_cells IS INITIAL.
IF lo_nd_payment_table IS NOT INITIAL.
get all declared attrigbutes
lo_nd_payment_table->get_static_attributes_table(
IMPORTING
table = lt_payment_table ).
ENDIF.
lo_el_payment_table = lo_nd_payment_table->get_element( ).
lo_el_payment_table->get_attribute(
EXPORTING
name = `PAYMENT_METHOD`
IMPORTING
value = lv_paymeth ).
lv_total_amount = 0.
wd_assist->gc_total_amount = 0.
IF lt_payment_table[] IS NOT INITIAL.
Looping at the payment internal table*
LOOP AT lt_payment_table INTO ls_payment_table.
lv_total_amount = lv_total_amount + ls_payment_table-amount.
ENDIF.
CLEAR ls_payment_table.
ENDLOOP.
ENDIF.
Passing the Total Amount Value to the Assistance class variable
wd_assist->gc_total_amount = lv_total_amount.
navigate from <CONTEXT> to <CONTRACT_PAYMENT> via lead selection
lo_nd_contract_payment = wd_context->get_child_node( name = wd_this->wdctx_contract_payment ).
get element via lead selection
lo_el_contract_payment = lo_nd_contract_payment->get_element( ).
lo_el_contract_payment->get_attribute(
EXPORTING
name = `CONTRACT_AMOUNT`
IMPORTING
value = lv_contract_amount ).
Calculating the balance amount
lv_balance_amount = lv_contract_amount - wd_assist->gc_total_amount.
get single attribute
lo_el_contract_payment->set_attribute(
EXPORTING
name = `TOTAL_AMOUNT`
value = wd_assist->gc_total_amount ).
lo_el_contract_payment->set_attribute(
EXPORTING
name = `BALANCE_AMOUNT`
value = lv_balance_amount ).
Binding the data to the context node
lo_nd_payment_table->bind_table(
EXPORTING
new_items = lt_payment_table " List of Elements or Model Data
set_initial_elements = abap_true " If TRUE, Set Initial Elements Otherwise Add
).
ENDMETHOD.
Regards
Manoj Kumar
Edited by: Manoj Kumar on Feb 27, 2009 10:25 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.