cancel
Showing results for 
Search instead for 
Did you mean: 

manipulating an unknown internal table

Former Member
0 Kudos

Hi,

I need to do a loop in an internal table but I dont know how many fields there are in it.

I want to do a loop in whatever table that I receive as a parameter, recovering all its columns and lines.

I am trying to do this with the class CL_ABAP_TABLEDESCR, but I didn't manage to do it.

Could anyone help me pls?

Thanks a lot.

Regards,

Jorge Luiz

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Jorge,

Please see this [article|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae], in this [wiki|https://wiki.sdn.sap.com/wiki/x/QwCMAw] and in this [wiki|https://wiki.sdn.sap.com/wiki/x/9IRWAw].

Regards.

Answers (1)

Answers (1)

former_member402443
Contributor
0 Kudos

Hi Jorge,

Please go thru the code given below, that might help you in solving the problem.

Call this code when u trigger an action.

  • Node Info

rootnode_info TYPE REF TO if_wd_context_node_info,

  • Context Nodes

dyn_node TYPE REF TO if_wd_context_node,

tabname_node TYPE REF TO if_wd_context_node,

  • String (for table name)

tablename TYPE string.

  • get node info of context root node

rootnode_info = wd_context->get_node_info( ).

  • Get the name of the table to be created

tabname_node = wd_context->get_child_node( name = 'INPUT' ).

tabname_node->get_attribute( EXPORTING name = 'TABLENAME'

IMPORTING value = tablename ).

TRANSLATE tablename TO UPPER CASE.

  • create sub node named TEST1 of structure (tablename)

cl_wd_dynamic_tool=>create_nodeinfo_from_struct(

parent_info = rootnode_info

node_name = tablename

structure_name = tablename

is_multiple = abap_true ).

DATA: stru_tab TYPE REF TO data.

FIELD-SYMBOLS:

<tab> TYPE table.

  • create internal table

CREATE DATA stru_tab TYPE TABLE OF (tablename).

ASSIGN stru_tab->* TO <tab>.

  • Get table content

SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.

  • get instance of new node

dyn_node = wd_context->get_child_node( name = tablename ).

  • Bind internal table to context node.

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_alv( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

  • Pass context node to ALV

DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .

l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

l_ref_interfacecontroller->set_data( dyn_node ).

Regards

Manoj Kumar