cancel
Showing results for 
Search instead for 
Did you mean: 

which type must a table from a context node have in assistance class?

Former Member
0 Kudos

Hey experts,

i'm actually beginning to use the assistance class in my webdynpro.

at the moment i'm trying to get a table of the node, of which i get the reference:

- i created a globale variable from type if_wd_context_node

- i created a method with an import-Parameter of the same type like before

- in the method i'm getting the reference to my context-node

no i want to get a table of the globale variable. in webdynpro i just use the wizard and get:

  DATA lo_nd_mepo1211_alv TYPE REF TO if_wd_context_node.



  DATA lt_mepo1211_alv TYPE wd_this->elements_mepo1211_alv.



* navigate from <CONTEXT> to <MEPO1211_ALV> via lead selection

  lo_nd_mepo1211_alv = wd_context->get_child_node( name = wd_this->wdctx_mepo1211_alv ).



* @TODO handle non existant child

* IF lo_nd_mepo1211_alv IS INITIAL.

* ENDIF.



  lo_nd_mepo1211_alv->get_static_attributes_table( IMPORTING table = lt_mepo1211_alv ).

but this, of course, won't work in my assistance class.

my Problem is the type of lt_mepo1211_alv .. which type should i use? i can't use the structure vor the node, because after that i added some attributes directly to the node and not to the structure.

I think with a structure like ls_mepo1211_alv i will have the same Problem of  getting the right type.

Has anyone an idea, of how to solve that Problems?

regards,

Mathias

Accepted Solutions (1)

Accepted Solutions (1)

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

I think you can't refer to a type created in your component.

You can try with the following work arround:

Create a new attribute in the method of your assitance class:

I_TABLE TYPE REF TO DATA.

Then before call to the method do the following:

DATA: lv_table TYPE REF TO data.

CREATE DATA lv_table TYPE TABLE OF wd_this->element_mepo1211_alv.

wd_assistt->your_method(  i_node = lo_nd_your_node

                                               i_table = lv_table)

And inside your method use the following:

  FIELD-SYMBOLS: <table> TYPE ANY TABLE,

                                <ls_table> TYPE ANY,

                                <field> TYPE any.

  ASSIGN i_table->* TO <table>.

lo_nd_mepo1211_alv->get_static_attributes_table( IMPORTING table = <table>.

   LOOP AT <table> ASSIGNING <ls_table>.

      ASSIGN COMPONENT 'YOUT_FIELD' OF STRUCTURE <ls_table> TO <field>.

   ENDLOOP.

Hope this help you.

Regards,

Ricardo.

Answers (1)

Answers (1)

amy_king
Active Contributor
0 Kudos

Hi Mathias,

You're on the right track. Let's say you have defined in the data dictionary a structure structuretype and also a table type tabletype which has line type structuretype

If you have defined your context node as having dictionary structure structuretype, then you could fetch the context node's static attributes table and pass that to your assistance class method. The node's static attributes table will be a table of type structuretype so you can use tabletype to type the assistance class method's parameter.

data lo_nd_mynode       type ref to if_wd_context_node.
data lt_atrributes_table  type wd_this->elements_mynode.

lo_nd_
mynode = wd_context->get_child_node( name = wd_this->wdctx_mynode ).
lo_nd_
mynode->get_static_attributes_table( importing table = lt_atrributes_table ).


So the piece you're missing is to define your context node with a dictionary structure.

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

so this means, it's better to update my structure of the ALV in data dictionary with all attributes, so that i can use that structure within my assistance class?

@Ricardo

I'm going to learn some more about field symbols and then try your way, too!

regards,

Mathias

amy_king
Active Contributor
0 Kudos

Hi Mathias,

There's always more than one way to solve a problem. Try different approaches to see what works best for your requirements and coding style. The two approaches discussed here will achieve the same end result but delegate the work differently.

One Approach:

  1. In Web Dynpro
    1. Get the node's static attributes table
    2. Pass the static attributes table to assistance class method
  2. In Assistance Class
    1. Work with a statically typed internal table

Another Approach:

  1. In Web Dynpro
    1. Pass the node to assistance class method
  2. In Assistance Class
    1. Get the node's static attributes table
    2. Work with a generically typed internal table

Cheers,
Amy