cancel
Showing results for 
Search instead for 
Did you mean: 

How to create dynamic context based on a structure defined in the program?

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

I need to create a dynamic context based on a structure wa_struc which i have define programatically.

When I pass wa_struc to structure_name parameter of create_nodeinfo_from_struc, i get a runtime error:

"Parameter STRUCTURE_NAME contains an invalid value wa_struc."

How to create dynamic context based on a structure defined in the program?

I have written the code like this:

TYPES: BEGIN OF t_type,

v_carrid TYPE sflight-carrid,

v_connid TYPE sflight-connid,

END OF t_type.

Data: i_struc type table of t_type,

wa_struc type t_type.

data: dyn_node type ref to if_wd_context_node.

data: rootnode_info type ref to if_wd_context_node_info.

rootnode_info = wd_context->get_node_info( ).

clear i_struc. refresh i_struc.

select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.

cl_wd_dynamic_tool=>create_nodeinfo_from_struct(

parent_info = rootnode_info

node_name = 'dynflight'

structure_name = 'wa_struc'

is_multiple = abap_true ).

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

dyn_node->bind_table( i_struc ).

Thanks

Gopal

Message was edited by: gopalkrishna baliga

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi Gopal,

if this question is still open i can help. Let me know if you need information.

- Michelle

gopalkrishna_baliga
Participant
0 Kudos

Hi Michelle,

First of all Special thanks for your informative answers to my other forum questions. I really appreciate your help.

Coming back to this question I am still waiting for an answer. Please help. Note that my structure is not in a dictionary.

I am trying to create a new node. That is

CONTEXT

- DYNFLIGHT

-


CARRID

-


CONNID

As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.

Also I cannot define the structure in the ABAP dictionary because it changes based on condition

I have updated my code like the following and I am getting error:

TYPES: BEGIN OF t_type,

CARRID TYPE sflight-carrid,

CONNID TYPE sflight-connid,

END OF t_type.

Data: i_struc type table of t_type,

dyn_node type ref to if_wd_context_node,

rootnode_info type ref to if_wd_context_node_info,

i_node_att type wdr_context_attr_info_map,

wa_node_att type line of wdr_context_attr_info_map.

wa_node_att-name = 'CARRID'.

wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.

insert wa_node_att into table i_node_att.

wa_node_att-name = 'CONNID'.

wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.

insert wa_node_att into table i_node_att.

clear i_struc. refresh i_struc.

select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.

rootnode_info = wd_context->get_node_info( ).

rootnode_info->add_new_child_node( name = 'DYNFLIGHT'

attributes = i_node_att

is_multiple = abap_true ).

dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).

dyn_node->bind_table( i_struc ).

l_ref_interfacecontroller->set_data( dyn_node ).

But now I am getting the following error :

The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.

The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP

Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP

Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP

Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP

Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP

Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP

Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP

Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP

Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP

Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP

-Gopal

Message was edited by: gopalkrishna baliga

0 Kudos

Hi Gopal,

if your structure is not in a dictionary i would recommend dynamic creation of the structure:

type-pools:

abap.

<b>*... (1) identify components required in your dynamic table</b>

data:

ls_component type abap_componentdescr,

lt_component type abap_component_tab.

clear ls_component.

ls_component-name = 'CARRID'.

ls_component-type ?= cl_abap_typedescr=>describe_by_name( 'SFLIGHT-CARRID' ).

insert ls_component into table lt_component.

clear ls_component.

ls_component-name = 'CONNID'.

ls_component-type ?= cl_abap_typedescr=>describe_by_name( 'SFLIGHT-CONNID' ).

insert ls_component into table lt_component.

<b>*... (2) create structure description in accordance to component</b>data:

lr_strucdescr type ref to cl_abap_structdescr.

if lt_component is not initial.

lr_strucdescr = cl_abap_structdescr=>create( lt_component ).

endif.

<b>*... (3) create table description for structure description</b>data:

lr_tabledescr type ref to cl_abap_tabledescr.

lr_tabledescr = cl_abap_tabledescr=>create( p_line_type = lr_strucdescr ).

<b>*... (4) create table</b>

data:

lr_data_table type ref to data.

create data lr_data_table type handle lr_tabledescr.

field-symbols:

<lt_table> type standard table.

assign lr_data_table->* to <lt_table>.

<b>*... (5) fill table (from database)</b>select * from sflight into corresponding fields of table <lt_table>.

<b>*... (6) create node dynamically</b>

data:

lr_node_info type ref to if_wd_context_node_info.

lr_node_info = wd_context->root_node_info->add_new_child_node(

name = 'DYNFLIGHT'

static_element_rtti = lr_strucdescr

is_static = abap_false

is_mandatory = abap_false

is_mandatory_selection = abap_false

is_multiple = abap_true

is_multiple_selection = abap_true

is_singleton = abap_false ).

      • optionally the table holding attribute information can also be added when calling this method ***

<b>*... (7) get node</b>

data:

lr_node type ref to if_wd_context_node.

lr_node = lr_context->root_node->get_child_node( 'DYNFLIGHT' ).

<b>*... (8) bind table to node</b>

lr_node->bind_table( <lt_table> ).

      • Make sure your node has been mapped to the data node in the interface of the web dynpro component SALV_WD_TABLE which you are using *** If this is not the case then you can optionally call the interface method SET_DATA( <lt_table> ). *** For performance reasons do not hold the table in your memory. Keep everything local as in my coding above ***

- Michelle

Former Member
0 Kudos

Hi baliga,

Why dont u respond to several threads posted by you?.

If the replies are not helpful do let us know....or close the thread. Please, dont just leave the threads open....this is just for courtesy to responders and future readers.

Thanks,

Raj.

gopalkrishna_baliga
Participant
0 Kudos

Hi Raj,

I do reply if I have any answer. But if you are telling in terms of closing the thread then yes I am sorry I might have not closed previous threads because I did not get satisfactory answers. Some answers I get for Webdynpro Java when I require for Webdynro ABAP. But I will make sure to close future threads. My apoligies.

Gopal

Former Member
0 Kudos

Hi baliga,

No need of apologies man. take it easy. I just told it for the sake of future readers.

You know, if we read the whole thread, if we cant conclude, it wastes time.

Thanks anyways,

Raj.