Skip to Content

How can i read context's ITAB data?

Hello

Below is standard SAP code from WDDOINIT of a standard webdynrpo, now i want to write a post-exit and want to modify the ITAB and finally rebind it to context,

METHOD WDDOINIT.

DATA: ls_result_line LIKE LINE OF wd_this->mr_component_ctrl->mt_search_result,
ls_result_info LIKE wd_this->mr_component_ctrl->ms_search_result_inf,
lt_key_field TYPE dpr_tt_api_name_value_pair. "#EC NEEDED
* ls_key_field TYPE dpr_ts_api_name_value_pair.

DATA: lt_construct TYPE dpr_tt_api_name_value_pair,
ls_construct LIKE LINE OF lt_construct,
lv_begin TYPE i,
lv_end TYPE i,
i TYPE i VALUE 1,

lt_url TYPE dpr_tt_api_name_value_pair,
ls_url TYPE dpr_ts_api_name_value_pair,
lv_columns TYPE i.

DATA: lr_type_desc TYPE REF TO cl_abap_typedescr,
lr_struc_desc TYPE REF TO cl_abap_structdescr,
lt_field_desc TYPE abap_component_tab.

DATA: ls_dyn_wa TYPE REF TO cl_abap_structdescr,
lt_dyn_comp_tab TYPE cl_abap_structdescr=>component_table,
ls_dyn_comp LIKE LINE OF lt_dyn_comp_tab.

DATA: lt_cxt_like TYPE REF TO data,
ls_cxt_like TYPE REF TO data.

FIELD-SYMBOLS: <comp> TYPE any,
<comp_url> TYPE string,
<itab> TYPE STANDARD TABLE,
<wa> TYPE any,
<ls_dyn_comp_tab> LIKE LINE OF lt_dyn_comp_tab.

DATA : lv_result TYPE string.

* Get key information for links in the result list
CALL METHOD wd_this->mr_component_ctrl->mr_ui_log_search->get_key_fields
RECEIVING
et_key_fields = lt_key_field.

* Construct component table
lt_construct = it_construct.
ls_result_info = wd_this->mr_component_ctrl->ms_search_result_inf.

LOOP AT lt_construct INTO ls_construct .
ls_dyn_comp-name = ls_construct-name.
ls_dyn_comp-type ?= cl_abap_typedescr=>describe_by_name( ls_construct-value ).
APPEND ls_dyn_comp TO lt_dyn_comp_tab.
ENDLOOP.

* Construct working area
ls_dyn_wa = cl_abap_structdescr=>create( lt_dyn_comp_tab ).

* DATA creation and handling
CREATE DATA ls_cxt_like TYPE HANDLE ls_dyn_wa .
ASSIGN ls_cxt_like->* TO <wa>.
wd_comp_controller->mr_select_cxt_structure = ls_cxt_like.

CREATE DATA lt_cxt_like LIKE TABLE OF <wa>.
ASSIGN lt_cxt_like->* TO <itab>.

lv_begin = 1.
lv_end = ls_result_info-num_columns .

CHECK lv_end IS NOT INITIAL.
WHILE lv_end <= ls_result_info-num_return.

LOOP AT wd_this->mr_component_ctrl->mt_search_result
INTO ls_result_line FROM lv_begin TO lv_end.

* check if this column is relevant
READ TABLE lt_dyn_comp_tab
WITH KEY name = ls_result_line-fieldname
TRANSPORTING NO FIELDS.

IF sy-subrc = 0.
* Yes, use outputvalue for the result table

ASSIGN COMPONENT sy-tabix OF STRUCTURE <wa> TO <comp>.

IF <comp> IS ASSIGNED AND sy-subrc EQ 0.

<comp> = ls_result_line-fieldval .
ENDIF.

ENDIF.

i = i + 1.

UNASSIGN <comp>.

ENDLOOP.
IF <wa> IS NOT INITIAL.
APPEND <wa> TO <itab>.
ENDIF.
lv_begin = lv_begin + ls_result_info-num_columns.
lv_end = lv_end + ls_result_info-num_columns.
i = 1.

ENDWHILE.


CALL METHOD wd_comp_controller->mr_ui_log_search->fill_breadcrumb
EXPORTING
iv_breadcrumb_sel = wd_comp_controller->mv_breadcrumb_sel
CHANGING
ct_result_tab = <itab>.


* Sort result tab according to first& second visible column
SORT <itab> BY (wd_this->mv_sortfield1) (wd_this->mv_sortfield2).

* Bind table
CALL METHOD ir_child_node->bind_elements " ==> Pls. let me know the counter part method for this method so that i "will read the <itab> data into my local <my_local_itab>
EXPORTING
new_items = <itab>
set_initial_elements = abap_true.


ENDMETHOD.

In my post-exit of the above method, i want to modify the <itab> data and want to rebind it again, hence, pls. let me know

1) How can get / read the <itab> data into my local <my_itab> or my_itab? i tried with STATIC_ATTRIBUTE / STATIC_ATTRIBUTES / GET_ELEMENTS method of IF*NODE* but no use!, pls. let me know how can read <itab>?

2) To bind the modified <my_itab> i guess,, just i will copy the abpve code and use for my post-exit

Thank you

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2013 at 02:04 AM

    Hi there,

    First to get data do this:

    Data: lv_node type ref to if_wd_context_node,

    lt_tab type standard table of if_view=>element_tableofdata,

    lv_wa like line of lt_tab.

    lv_node = wd_context->get_child_node( name = 'TABLEOFDATA' ).

    lv_node->get_static_attributes_table( importing table = lt_tab ).


    Now do your processing

    To bind back to the context do the following:

    lv_node->bind_table( lt_tab).

    hope it helps..

    Add a comment
    10|10000 characters needed characters exceeded

    • Okay, you can achieve your requirement by using POSTEXIT and placing all the required code in it.

      All the best 😊

      FYI:

      As you have elements collection, you can also get data by using context element reference

      • Loop over the elements and use context element reference
        • Get the attribute value by using GET_ATTRIBUTE
        • Set the attribute value by using SET_ATTRIBUTE to modify data

      Regards,

      Rama

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.