cancel
Showing results for 
Search instead for 
Did you mean: 

Read dynamically created node

Former Member
0 Kudos

Hi,

I have created a node dynamically based on some fieldcatalog in one of the method in my webdynpro for Abap.

Now in another method i want to read the contents of that dynamically created node.

Can somebody help me in this regards pl.

View Entire Topic
Former Member
0 Kudos

HI,

When you have created the node there itself, you have to move it to some global variable. declare a vairable in component controller attributes. And use it where ever required.

Former Member
0 Kudos

Hi Lekha,

I m facing problem in creating the table for that particular node reference. How do u thing i can solve this ?

This table i want to use in method GET_STATIC_ATTRIBUTES_TABLE( IMPORTING table = lt_table ) or something similar to get the all the binded values of that node.

uday_gubbala2
Active Contributor
0 Kudos

Hi Soumya,

Thats exactly what I was referring to. When you try to use any of the GET_STATIC* methods you would end up in an error saying that the respective attribute does not exist. You would have to repeatedly make use of the normal GET_ATTRIBUTE method for this.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Soumya,

Thats exactly what I was referring to. When you try to use any of the GET_STATIC* methods you would end up in an error saying that the respective attribute does not exist. You would have to repeatedly call the normal GET_ATTRIBUTE method for different attributes. Try put the calls to this method inside a loop & specify the index while trying to read the attribute.

Regards,

Uday

Former Member
0 Kudos

Hi Uday,

Thanks for the reply.

But i m facing difficulty in declaring the variable of that type. If I give lt_values type data ill get syntax errors as data is a generic type. Can u help me.

Former Member
0 Kudos

Hi,



  FIELD-SYMBOLS :
    <lt_table>        TYPE STANDARD TABLE.      " Field symbol for detail node

*wd_comp_controller->gt_data_table type ref to data.
* Get the node ref
  lr_node = wd_comp_controller->lr_node.
* Assign the ref of table
  IF wd_comp_controller->gt_data_table IS NOT INITIAL.
    ASSIGN wd_comp_controller->gt_data_table->* TO <lt_table>.
  ENDIF.                                      "if wd_comp_controller->gt_data_table is not initial.

  IF lr_node IS NOT INITIAL.
    CALL METHOD lr_node->get_static_attributes_table
      IMPORTING
        table = <lt_table>.

Regards,

Lekha.

Edited by: Lekha on Sep 17, 2009 4:03 PM

Former Member
0 Kudos

Hi Lekha,

I have tried the similar solution where in i passed fieldsymbol of type Standard table to GET_STATIC_ATTRIBUTES_TABLE but while executing i got a Dump saying "Line types of an internal table and a work area not compatible."

Former Member
0 Kudos

Hi,

I guess you might have created a dynamic internal table right where yuo have even created a dynamic node.

Move the relevant linetypes/tabletypes into global variables and use them.

Can you paste your code....

Edited by: Lekha on Sep 17, 2009 4:16 PM

Former Member
0 Kudos

Hi Lekha,

Here is my code.

METHOD1:

              • Next, validate which fields you will use as ALV columns *******

DATA: ls_component TYPE cl_abap_structdescr=>component,

lr_type TYPE REF TO cl_abap_datadescr,

lt_components TYPE cl_abap_structdescr=>component_table.

*in place of CHAR20, we need to place the data-element of the field to get

*the heading to the ALV grid columns i.e. lt_fieldcatlog-dd_roll

*(field for dataelement in fieldcatalog)

LOOP AT lt_fieldcatlog INTO ls_fieldcatlog.

lr_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'CHAR20' ).

ls_component-name = ls_fieldcatlog-fieldname.

ls_component-type = lr_type .

APPEND ls_component TO lt_components.

ENDLOOP.

              • Next, create a new structure and assign it to a new dynamic context node *******

DATA: lr_root_info TYPE REF TO if_wd_context_node_info ,

lr_node_info TYPE REF TO if_wd_context_node_info,

lr_structdescr TYPE REF TO cl_abap_structdescr.

CALL METHOD cl_abap_structdescr=>create

EXPORTING

p_components = lt_components

RECEIVING

p_result = lr_structdescr.

  • Get context node info

lr_root_info = wd_context->get_node_info( ).

  • Generate new node with the dynamic structure

CALL METHOD lr_root_info->add_new_child_node

EXPORTING

name = 'LEGACY'

is_initialize_lead_selection = abap_false

static_element_rtti = lr_structdescr

is_static = abap_false

RECEIVING

child_node_info = lr_node_info.

  • get instance of new node

dyn_node = wd_context->get_child_node( name = 'LEGACY' ).

ASSIGN lt_legacy->* TO <tab>.

dyn_node->bind_table( <tab> ).

*instantiate alv component

DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

l_ref_cmp_usage = wd_this->wd_cpuse_legacytable( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

              • last, GET reference to model *******

DATA: lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.

lo_interfacecontroller = wd_this->wd_cpifc_legacytable( ).

lo_interfacecontroller->set_data( dyn_node ).

ENDIF.

METHOD2:

"Now create the internal table dynamically.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt_fcatlog

IMPORTING

ep_table = lt_legacy.

ASSIGN lt_legacy->* to <fs_legacy>.

dyn_node = wd_context->get_child_node( name = 'LEGACY ' ).

dyn_node->get_static_attributes_table( IMPORTING table = <fs_legacy> ).

Former Member
0 Kudos
"Line types of an internal table and a work area not compatible."

Where are you getting this error.

Former Member
0 Kudos

Hi Lekha,

I am getting the error while i m executing my Webdynpro application and in method GET_STATIC_ATTRIBUTES_TABLE .

Can you please help me solve this error.

Former Member
0 Kudos

Hi,

When you check in ST22 for SOURCECODE there you an find the error. Paste that piece of code.