cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic table columns in web dynpro abap

Former Member
0 Kudos

Hi,

In my current project I have got a requirement whose solution I am not able to figure out.

My requirement is this:

I will have a table containig budget owners name(since its compensation management in HR).There will be a table popin inside this table on the click of the personal number of the budget owner. Now the table popin will have another table with all employees name under that particular budget owner.

The problem is that the table inside the popin will not be having fixed columns.Actually the columns will be coming from a standard java web dynpro application (say in the form of an internal table).

My requirement is this how can this be handled?Can we include all the possible columns in the node(which i bind to the child table) and make them visible/invisible during runtime? or create a dynamic node and assign it to the table(but in this case a node needs to be bound to the table during design time,what to bind?) ?

Can u please help along with code snippets.

Thanks and Regards,

Saikat.

Accepted Solutions (1)

Accepted Solutions (1)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos
data : lo_element type ref to cl_wd_uielement,

    lv_value = abap_false.
or
    lv_read_only = abap_true.

  lo_element ?= view->get_element( ID = 'TC_MAIN' ).
  lo_element->set_enabled( lv_value ).


""Change to reduce darkness of fields

  DATA lo_nd_n_read_only TYPE REF TO if_wd_context_node.
  DATA lo_el_n_read_only TYPE REF TO if_wd_context_element.

  lo_nd_n_read_only = wd_context->get_child_node( name = wd_this->wdctx_n_read_only ).
  lo_el_n_read_only = lo_nd_n_read_only->get_element( ).
  lo_el_n_read_only->set_attribute(
    name =  `READ_ONLY`
    value = lv_read_only ).
Former Member
0 Kudos

Thnx for the input.

I am abke to make the table columns inside the popin visible/invisible.

I have a tabstrip.Indise one of the tabs is my main table and inside one of the columns is the popin.Inside that a transparent container and finally the table inside that.

This is the code that worked for me.

METHOD wddomodifyview .

DATA lr_root_container TYPE REF TO cl_wd_uielement_container.

DATA lr_table_popin TYPE REF TO cl_wd_table_popin.

DATA lr_transparent_container TYPE REF TO cl_wd_transparent_container.

DATA lr_table TYPE REF TO cl_wd_table.

DATA lr_table_column TYPE REF TO cl_wd_table_column.

DATA lr_table_in_table_popin TYPE REF TO cl_wd_table.

DATA lr_node_header_node TYPE REF TO if_wd_context_node.

DATA lr_node_item_node TYPE REF TO if_wd_context_node.

DATA lr_tabstrip TYPE REF TO cl_wd_tabstrip.

DATA lr_tab TYPE REF TO cl_wd_tab.

data lr_tc type ref to CL_WD_TRANSPARENT_CONTAINER.

data lr_table2 type ref to cl_wd_table.

DATA lr_table2_column TYPE REF TO cl_wd_table_column.

IF first_time = abap_false.

lr_root_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

lr_tabstrip ?= lr_root_container->get_child( id = 'TABSTRIP1' ). "GETTING THE TABSTRIP

lr_tab ?= lr_tabstrip->get_tab( id = 'TAB1' ). "GETTING THE TAB INSIDE TABSTRIP

lr_table ?= lr_tab->GET_CONTENT( ). "GETTING THE CONTENT(TABLE IN THIS CASE) INSIDE TABSTRIP

lr_table_column ?= lr_table->get_grouped_column( id = 'TABLE_MAIN_PERNR' ). "GETTING THE COLUMN INSIDE THE TABLE

"Table popin

lr_table_popin ?= lr_table_column->GET_POPIN( ). "GETTING THE POPIN INSIDE THE TABLE

lr_tc ?= lr_table_popin->GET_CONTENT( ). "GETTING THE CONTENT(TRANSPARENT CONTAINER IN THIS CASE)INSIDE THE TABLE

lr_table2 ?= lr_tc->get_child( id = 'TABLE_EMPLOYEE' ). "GETTING THE EMPLOYEE TABLE INSIDE THE TRANSPARENT CONTAINER

lr_table2_column ?= lr_table2->get_grouped_column( id = 'TABLE_EMPLOYEE_PERNR' ). "GETTING THE COLUMN INSIDE THE TABLE

lr_table2_column->SET_VISIBLE( '02' ). "SETTING VISIBILITY FOR THE COLUMN

ENDIF.

ENDMETHOD.

But I'm still considering the dynamic node concept.Lets see if this works out or not.If not then I'll have to go for the dynamic node thing.

Thanks,

Saikat

Answers (4)

Answers (4)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

[Link 1|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3041fcd6-3833-2c10-efad-b545c6001553?quicklink=index&overridelayout=true]

[Link 2|http://www.saptechnical.com/Tutorials/WebDynproABAP/Hide/Page3.htm]

search for sample code,

you usually write the code in MODIFYVIEW method to display/hide the fileds.

lets see some one might post some sample code to hide the fields dynamically

Edited by: ssm on Aug 17, 2011 3:05 PM

Former Member
0 Kudos

@ssm,thank you for the links.

But i am looking forward if someone can give the code samples of how exactly i can get the table and then a particular column to make it visible/invisible.

Thanks,

Saikat.

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

the simple way is , assume that you have 3 fields in the tablepopin, so will create 3 attributes for that node.

create 3 more attributes in that node like FIELD1_VISIBLE, FIELD2_VISIBLE, FIELD3_VISIBLE.

so when the tablepopin data needs to be binded. you will push abap_true or abap_false to the above attributes to decide which field needs to be visible.

or as an alternative ...

get the table ID, And then the column ID...and then you can set the visible properties based on the requirement for the columns.

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

keep all the possible columns in the node at design time and make them visible/invisble in the table during runtime ... SOUNDS EASY TO IMPLEMENT

the other one needs to create a child node dynamically and bind the child node to parent node.

however i m not sure how to create a child node dynamically.

Former Member
0 Kudos

Hi,

Can you please provide some code samples to make table columns visible/invisible at rumtime.That will be very helpful

Thanks,

Saikat

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

for me it is always easy to look TABLE POPIN as part of the table,

in table, if we have N records, and every record has only one row.... in this case you can define all the attributes in one node (that includes table and tablepopin). you can play around with the field properties to display/edit/hide/

in table, if we have N records, and every record has N rows(TABLEPOPIN has multiple records).... in this case

we have 0 to N cardinality to the table and TABLEPOPIN has 0 to N cardinality.....

we need to define as node and then a sub node to the parent node.

Former Member
0 Kudos

Thanks for your answer ssm.

In my case the table popin will have multiple rows.I undertand the subnode concept that you are saying and I totally agree with you.

But my problem is that,the table popin wont have fixed columns i.e i cannot finalize the subnode at the design time.I need to either keep all the possible columns in the node at design time and make them visible/invisble in the table during runtime or else create attributes or the whole node dynamically.

This is where my problem is.

Can anyone please shed some light on this.Which approach is better and how to achieve it?