cancel
Showing results for 
Search instead for 
Did you mean: 

Binding of dynamic table ?

martin_svik2
Participant
0 Kudos

hi,

i have pasted the code below (from an demo) into my method WDDOMODIFYVIEW of an view. so there should be a table with demo data to be displayed. So far so good, BUT: this coding is only doing the binding of the table in context dynamicly. So HOW can i display this table now in my view ? See screenshot: i want to display the table inside the tabstrip "TAB_2".

So how to achive that ?

br Martin

  DATA: node_info   TYPE REF TO if_wd_context_node_info,

        struct_type TYPE REF TO cl_abap_structdescr,

        table_type  TYPE REF TO cl_abap_tabledescr,

        comp_tab    TYPE cl_abap_structdescr=>component_table,

        comp        LIKE LINE OF comp_tab,

        my_table    TYPE REF TO data,

        my_row      TYPE REF TO data.

  FIELD-SYMBOLS: <table>  TYPE table,

                 <row>    TYPE data,

                 <flight> TYPE sflight.

* build a structure description from the list of single fields

  comp-name = 'CARRID'.

  comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CARR_ID' ).

  APPEND comp TO comp_tab.

comp-name = 'CONNID'.

comp-type ?= cl_abap_datadescr=>describe_by_name( 'S_CONN_ID' ).

APPEND comp TO comp_tab.

* note this structure contains the fields "CONNID" and "CARRID"

  struct_type = cl_abap_structdescr=>create( comp_tab ).

* now the nodeinfo is created

  node_info = wd_context->get_node_info( ).

  node_info = node_info->add_new_child_node(

    name                         = 'MY_NODE'

    is_mandatory                 = abap_true

    is_multiple                  = abap_true

    static_element_rtti          = struct_type

    is_static                    = abap_false

       ).

* fill new node;

  DATA: l_node   TYPE REF TO if_wd_context_node,

        l_flight TYPE STANDARD TABLE OF sflight.

*l_flight = CL_WD_DEMO_DYN_MODEL->get_flights( ).

  l_node = wd_context->get_child_node( 'MY_NODE' ).

* l_flight = wd_assist->get_flights( ).

*

*  if you could create a local data type, would be fine, but if you have to do it dynamically ...

  struct_type = node_info->get_static_attributes_type( ).

* create tabledescriptor from structdescription (standard table, no keys)

  table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ).

  CREATE DATA my_table TYPE HANDLE table_type.

  ASSIGN my_table->* TO <table>.

  LOOP AT l_flight ASSIGNING <flight>.

    CREATE DATA my_row TYPE HANDLE struct_type.

    ASSIGN my_row->* TO <row>.

    MOVE-CORRESPONDING <flight> TO <row>.

    APPEND <row> TO <table>.

  ENDLOOP.


  l_node->bind_table( <table> ).

Accepted Solutions (1)

Accepted Solutions (1)

j_schnatz
Explorer
0 Kudos

Hi Martin,

check method CREATE_TABLE_FROM_NODE in class CL_WD_DYNAMIC_TOOL - it will automatically create the table (CL_WD_TABLE) based on a given node and add it to the container provided in parameter UI_PARENT (your tab).

Hope this helps.

Cheers

Johannes

martin_svik2
Participant
0 Kudos

Hello Johannes,

after playing around with the parameters it works !!!!!!!! THANK YOU VERY MUCH

br Martin

j_schnatz
Explorer
0 Kudos

Your are welcome Martin.

Have a good one.

Cheers,

Johannes

martin_svik2
Participant
0 Kudos

Well, one thing is left:

the table is now displayed under my tab-strip testtab2. thats because i do it that way with:

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

But how can i place it under TAB_2 and not under ROOTUIEELEMENTCONTAINER ?

this is not working:

lr_container ?= view->get_element( 'TAB_2' ) 

It brings me to runtime error saying:

Dynamic type conflict during the assignment of references.

br, Martin

j_schnatz
Explorer
0 Kudos

Make sure the variable you assign the tab to has the correct type:

  DATA lo_tab TYPE REF TO cl_wd_tab.

  lo_tab ?= view->get_element( 'TAB_2' ).

Cheers,

Johannes


martin_svik2
Participant
0 Kudos

Hi Johannes,

thats fine with me, but this is not working. the call before was:

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

    CALL METHOD cl_wd_dynamic_tool=>create_table_from_node

      EXPORTING

        ui_parent = lr_container

        table_id  = 'MY_TABLE'

        node      = l_node.


this works, but table is displayed outside the tab-strib.

But when i do:


    lo_tab ?= view->get_element( 'TAB_2' ).

    CALL METHOD cl_wd_dynamic_tool=>create_table_from_node

      EXPORTING

        ui_parent = lo_tab

        table_id  = 'MY_TABLE'

        node      = l_node.


i get an error saying:

"LO_TAB" is not type-compatible with formal parameter "UI_PARENT".


br, Martin

j_schnatz
Explorer
0 Kudos

Hi Martin,

create a transparent container in your tab (TAB_2) at design-time and add the table to this container at runtime using your CL_WD_DYNAMIC_TOOL=>CREATE_TABLE_FROM_NODE call.

Also make sure you check for the the FIRST_TIME-flag so you don't execute the dynamic creation coding every roundtrip.


Cheers,

Johannes

martin_svik2
Participant
0 Kudos

Hi Johannes,

now it works, thank you Sorry for the many "basic question" -> i am working with ABAP for 25 years now, but i am quite new to web dynpro ABAP

br Martin

Answers (0)