on 11-13-2008 10:08 AM
Hi Experts.
I Have a situation where in I create tables at runtime, depending on the number of entries in my database table. For Ex.. if there are two entries in my DB table.. two tables will be created at runtime in my WDA application.The created table should have one column as dropdown and another as input field. i managed to create such tables. Now my question is how can I read values from my table that is created at runtime (nodes and attributes are created at runtime as well). I have done my coding in the WDDOMODIFY of my View. Any help would be rewarded..
Regards,
S.P.K
Sorry for my delayed reply.
Please find my code as below
DATA:
lr_container TYPE REF TO cl_wd_uielement_container,
lr_table TYPE REF TO cl_wd_table,
lr_layout TYPE REF TO cl_wd_flow_data,
node_feedback TYPE REF TO if_wd_context_node,
lr_node TYPE REF TO if_wd_context_node_info,
lv_fb_lines TYPE i,
lv_index TYPE numc2,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_attribute_info TYPE wdr_context_attribute_info,
lv_node_name TYPE string,
lv_table_id TYPE string,
lv_table_id_cp TYPE string,
lv_result TYPE string,
lv_cap_text TYPE string,
lr_column1 TYPE REF TO cl_wd_table_column,
lr_column2 TYPE REF TO cl_wd_table_column,
lr_column3 TYPE REF TO cl_wd_table_column,
lr_caption1 TYPE REF TO cl_wd_caption,
lr_caption2 TYPE REF TO cl_wd_caption,
lr_caption3 TYPE REF TO cl_wd_caption,
lr_ddi TYPE REF TO cl_wd_dropdown_by_idx,
lr_ddi_1 TYPE REF TO cl_wd_dropdown_by_idx,
lr_ip_field TYPE REF TO cl_wd_input_field,
cx_add_attr_error TYPE REF TO cx_wd_context,
lv_bind_texts TYPE string,
lv_comm_texts TYPE string,
lv_group_texts TYPE string,
lr_group TYPE REF TO cl_wd_group,
lt_table_id TYPE string_table,
ls_priority TYPE zst_numc1,
lv_fact_no TYPE numc2,
lv_prio_no TYPE numc2,
ls_field_reason TYPE string,
ls_field_prio TYPE string,
ls_field_comments TYPE string,
lv_field_index TYPE i,
ls_fb_text TYPE zst_fb_text,
obj TYPE REF TO cl_abap_structdescr,
comp_wa TYPE abap_compdescr,
lv_table_id_lines TYPE i,
lv_priority TYPE string,
lv_comments TYPE string.
FIELD-SYMBOLS: <ls_p9005> TYPE ANY,
<fs_field> TYPE ANY.
DO 5 TIMES.
ls_priority = ls_priority + 1.
APPEND ls_priority TO lt_priority.
ENDDO.
lv_fact_no = '00'.
lv_prio_no = '00'.
CONSTANTS: lc_node_name TYPE string VALUE 'FEED_BACK_'.
IF first_time = 'X'.
LOOP AT lt_dd07v INTO ls_dd07v. "Table containing my entries
lv_fact_group = ls_dd07v-domvalue_l.
READ TABLE
lt_feedreas
INTO ls_feedreas
WITH KEY factor_group = lv_fact_group.
IF sy-subrc = 0.
CONCATENATE lc_node_name lv_fact_group INTO lv_node_name.
lr_node_info = wd_context->get_node_info( ).
CALL METHOD lr_node_info->add_new_child_node
EXPORTING
name = lv_node_name
is_mandatory = abap_false
is_multiple = abap_true
is_multiple_selection = abap_true
is_singleton = abap_false
is_initialize_lead_selection = abap_true
is_static = abap_true
RECEIVING
child_node_info = lr_node_info.
Prepare properties of attribute & add to context node CHILD
lr_attribute_info-name = 'TEXT'.
lr_attribute_info-type_name = `STRING`. "ZDE_FEEDREAS
lr_attribute_info-value_help_mode = '0'.
lr_node_info->add_attribute(
EXPORTING
attribute_info = lr_attribute_info ).
CLEAR lr_attribute_info.
Prepare properties of attribute & add to context node CHILD
lr_attribute_info-name = 'PRIORITY'.
lr_attribute_info-type_name = `NUMC1`.
lr_attribute_info-value_help_mode = '1'.
lr_node_info->add_attribute(
EXPORTING
attribute_info = lr_attribute_info ).
CLEAR lr_attribute_info.
Prepare properties of attribute & add to context node CHILD
lr_attribute_info-name = 'EMP_COMMENTS'.
lr_attribute_info-type_name = `STRING`.
lr_attribute_info-value_help_mode = '1'.
lr_node_info->add_attribute(
EXPORTING
attribute_info = lr_attribute_info ).
CLEAR lr_attribute_info.
LOOP AT lt_feedreas
INTO ls_feedreas WHERE factor_group = lv_fact_group. "creating tables based on group
node_feedback = wd_context->get_child_node( lv_node_name ).
ls_feedback-text = ls_feedreas-text.
DO 30 TIMES.
lv_fact_no = lv_fact_no + 1.
lv_prio_no = lv_prio_no + 1.
CONCATENATE 'FACTOR_' lv_fact_no
INTO ls_field_reason.
CONCATENATE 'PRIO_' lv_prio_no
INTO ls_field_prio.
CONCATENATE 'COMMENTS_' lv_prio_no
INTO ls_field_comments.
READ TABLE lt_pa9005
INTO ls_p9005
WITH KEY (ls_field_reason) = ls_feedreas-reason.
IF sy-subrc = 0.
obj ?= cl_abap_typedescr=>describe_by_data( ls_p9005 ).
READ TABLE obj->components
INTO comp_wa
WITH KEY name = ls_field_prio.
IF sy-subrc = 0.
lv_field_index = sy-tabix.
ENDIF.
ASSIGN ls_p9005 TO <ls_p9005>.
ASSIGN COMPONENT lv_field_index
OF STRUCTURE <ls_p9005>
TO <fs_field>.
ls_feedback-priority = <fs_field>.
READ TABLE obj->components
INTO comp_wa
WITH KEY name = ls_field_comments.
IF sy-subrc = 0.
lv_field_index = sy-tabix.
ENDIF.
ASSIGN ls_p9005 TO <ls_p9005>.
ASSIGN COMPONENT lv_field_index
OF STRUCTURE <ls_p9005>
TO <fs_field>.
READ TABLE lt_fb_text
INTO ls_fb_text
WITH KEY guid = <fs_field>.
IF sy-subrc = 0.
ls_feedback-emp_comments = ls_fb_text-text.
CLEAR ls_fb_text.
ENDIF.
CLEAR ls_p9005.
EXIT.
ENDIF.
ENDDO.
CLEAR: lv_fact_no, lv_prio_no.
ENDIF.
APPEND ls_feedback TO lt_feedback.
CLEAR ls_feedback.
ENDLOOP.
IF lt_feedback IS NOT INITIAL.
node_feedback->bind_table(
new_items = lt_feedback
set_initial_elements = abap_false ).
IF wd_comp_controller->lr_app_it->giv_login <> 'MSS'.
node_feedback->bind_table(
new_items = lt_priority
set_initial_elements = abap_false ).
ENDIF.
DESCRIBE TABLE lt_feedback LINES lv_fb_lines.
REFRESH lt_feedback.
CONCATENATE 'TABLE_' lv_fact_group INTO lv_table_id.
APPEND lv_table_id TO lt_table_id.
lr_container ?= view->get_element('ROOTUIELEMENTCONTAINER').
lr_table = cl_wd_dynamic_tool=>create_table_from_node(
ui_parent = lr_container
table_id = lv_table_id
node = node_feedback ).
CALL METHOD lr_table->set_footer_visible
EXPORTING
value = abap_false.
CALL METHOD lr_table->set_visible_row_count
EXPORTING
value = lv_fb_lines.
CALL METHOD lr_table->set_selection_mode
EXPORTING
value = '06'.
ENDIF.
ENDIF.
ENDLOOP.
DESCRIBE TABLE lt_table_id LINES lv_table_id_lines.
LOOP AT lt_table_id INTO lv_table_id.
lv_table_id_cp = lv_table_id.
SHIFT lv_table_id_cp BY 6 PLACES .
lv_index = lv_table_id_cp.
IF lv_table_id_lines IS NOT INITIAL.
IF sy-tabix = lv_table_id_lines.
EXIT.
ENDIF.
ENDIF.
lr_table ?= view->get_element( id = lv_table_id ).
CALL METHOD cl_wd_input_field=>new_input_field
EXPORTING
bind_value = lv_comm_texts
RECEIVING
control = lr_ip_field.
CALL METHOD cl_wd_dropdown_by_idx=>new_dropdown_by_idx
EXPORTING
bind_texts = lv_bind_texts
RECEIVING
control = lr_ddi.
IF wd_comp_controller->lr_app_it->giv_login = 'ESS'.
CALL METHOD lr_column2->set_table_cell_editor
EXPORTING
the_table_cell_editor = lr_ddi.
ENDIF.
ENDIF.
ENDLOOP.
ELSE.
ENDIF.
Any guidace would be rewarded
Regards,
S.P.K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi karthikeyan,
Your table is showing values means you already binded values to the context node.So read the context node where ever you want you will get the values.
Table is used to show the values in the context node.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can u pls paste ur code...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
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.