on 02-13-2018 3:53 PM
Hello experts, I have a tableview and I need to insert records through a button.
I currently have several problems:
1. When I report the records with different data and press the ENTER key, all records are updated with the data from the last record.
2. When I select a record of the new ones that I just inserted and press the Delete button, all the new inserted records are deleted.
Please, I need help with the method code "EH_ONINSERT". I currently have this code:
DATA: lr_entity TYPE REF TO if_bol_bo_property_access,
lr_cn TYPE REF TO cl_bsp_wd_context_node,
ls_attr TYPE zhe_tarifas.
CLEAR: ls_attr.
DATA: lv_seltab TYPE int4.
CLEAR: ls_attr.
FIELD-SYMBOLS: <lr_cn> TYPE any.
ASSIGN me->context->('ZTARIFAS') TO <lr_cn>.
IF <lr_cn> IS ASSIGNED.
lr_cn ?= <lr_cn>.
lr_entity ?= lr_cn->collection_wrapper->get_first( ). "get_current( ).
ENDIF.
CHECK lr_entity IS BOUND.
lr_entity->set_properties( EXPORTING is_attributes = ls_attr ).
typed_context->ztarifas->get_collection_wrapper( )->add( iv_entity = lr_entity ).
typed_context->ztarifas->visible_first_row_index = typed_context->ztarifas->collection_wrapper->size( ).
Thank you,
Regards.
Hi Frankie...
Put the below code in EH_ONINSERT method. Each time you click the Insert button, it will add a new row to the table.
DATA: lr_current TYPE REF TO if_bol_bo_property_access,
lr_value_node TYPE REF TO cl_bsp_wd_value_node,
ls_attr TYPE zhe_tarifas,
lr_attr TYPE REF TO zhe_tarifas.
TRY.
CREATE DATA lr_attr.
CREATE OBJECT lr_value_node
EXPORTING
iv_data_ref = lr_attr.
lr_value_node->set_properties( ls_attr ).
me->typed_context->ztarifas->collection_wrapper->add( lr_value_node ).
me->typed_context->ztarifas->visible_first_row_index = me->typed_context->ztarifas->collection_wrapper->size( ).
CATCH cx_root.
ENDTRY.
-Ricky.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
you use the 1st BO entity of the context collection, clear it and add it a second time:
lr_entity ?= lr_cn->collection_wrapper->get_first( ).
...
lr_entity->set_properties( EXPORTING is_attributes = ls_attr ).
typed_context->ztarifas->get_collection_wrapper( )->add( iv_entity = lr_entity ).
You need to create a new BO instance with via eg CREATE_RELATED_ENTITY or use a new value node CL_BSP_WD_VALUE_NODE.
you may have a lot at eg CL_BP_DATA_ACCOUNTIDNUMB1->EH_ONINSERT - similar behaviour
regards
Domi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.