cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Node Creation in ALV.

former_member226225
Contributor
0 Kudos

Hi Friends,

             

              I am trying to display the data in ALV , I am dynamically creating the node and attributes and finally i am getting the data into final internal table but the data is not displaying .

Just check the code and give the solution for that.



   DATA:
*Node Info
  obj_node_info type ref to if_wd_context_node_info,
*Context Nodes
  dyn_node      type ref to if_wd_context_node.

   data : t_attr type WDR_CONTEXT_ATTR_INFO_MAP,
          wa_attr type WDR_CONTEXT_ATTRIBUTE_INFO.

   data : obj_type TYPE REF TO cl_abap_datadescr.

  data : wa_node type WDR_CONTEXT_ATTRIBUTE_INFO.

CALL METHOD WD_CONTEXT->GET_NODE_INFO
   RECEIVING
     NODE_INFO = obj_node_info.


CALL METHOD OBJ_NODE_INFO->ADD_NEW_CHILD_NODE
   EXPORTING
     NAME                         = 'ZVBAK'
   RECEIVING
     CHILD_NODE_INFO              = obj_node_info.


obj_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'VBELN_VA' ).

clear wa_node.
wa_node-name = 'VBELN'.
wa_node-RTTi = obj_type .

CALL METHOD OBJ_NODE_INFO->ADD_ATTRIBUTE
   EXPORTING
     ATTRIBUTE_INFO = wa_node.


clear : wa_node,
         obj_type.
obj_type ?= cl_abap_typedescr=>describe_by_name( p_name = 'ERDAT' ).

wa_node-name = 'ERDAT'.
wa_node-rtti = obj_type.

CALL METHOD OBJ_NODE_INFO->ADD_ATTRIBUTE
   EXPORTING
     ATTRIBUTE_INFO = wa_node.

FIELD-SYMBOLS : <tab> type ANY TABLE.

DATA: struct_tab type ref to data.
*      T_data type table of struct_data.


CALL METHOD OBJ_NODE_INFO->GET_ATTRIBUTES
   RECEIVING
     ATTRIBUTES = t_attr.



*Create Internal Table
create data struct_tab type table of ('ZVBAK').
assign struct_tab->* to <tab>.

*Get table content
select * from VBAK into corresponding  fields of table <tab>
   up to 20 ROWS.

*get  instance of new node
dyn_node = wd_context->get_child_node( name = 'ZVBAK' ).

*Bind Internal table to context node.
dyn_node->bind_table( <tab> ).

*instantiate alv component

DATA LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.

LO_CMP_USAGE =   WD_THIS->WD_CPUSE_ALVCOMP( ).
IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
   LO_CMP_USAGE->CREATE_COMPONENT( ).
ENDIF.



DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
LO_INTERFACECONTROLLER =   WD_THIS->WD_CPIFC_ALVCOMP( ).

   LO_INTERFACECONTROLLER->SET_DATA(
*   only_if_new_descr =                 " wdy_boolean
     R_NODE_DATA dyn_node ).              " ref to if_wd_context_node

Thanks,

Raghunadh.K

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos
Former Member
0 Kudos

Hi Kodali,

In windows Controller check View Container .. Adding ALV Table Or not......

If not embed Alv Table into VC..

Regards,

Venkat

Abhijeet-K
Active Participant
0 Kudos

Hi Raghunadh,

On second thoughts, your code seems fine. I just need to know where you have called it. If it is called after the page has been rendered once already, the set_data won't have any effect (at least didn't do for me). So, the suggestion is to call set_data some time during initialisation/view modification with some dummy node with cardinality 0-n, and then call again, once your real node with dynamic attributes is ready.

Abhijeet-K
Active Participant
0 Kudos

Hi Raghunadh,

Have you done the mapping of ALV component usage context node DATA with the context node that stores the ALV table data?

See the attached image.