cancel
Showing results for 
Search instead for 
Did you mean: 

how to hide columns in the output table in webdynpro based on input

Former Member
0 Kudos

Hi Experts,

I have 2 inputs and 1 input is optional.If both inputs are given proper table output is displayed,but if only 1 input is given a column is empty in the output table so i want to hide this column dynamically at runtime based on my inputs.And i want to hide some empty rows also at runtime based on inputs.

Can anyone help me out to solve this.

Thanks in advance.

Regards,

Anita.

Accepted Solutions (0)

Answers (2)

Answers (2)

uday_gubbala2
Active Contributor
0 Kudos

Hi Anita,

You can proceed as follows if you want to hide a column C1 when only 1 of the input field has been filled by the user. Create an component controller level boolean context attribute (say FLAG) with a default value of 'X'. Now bind the "Visible" property of column C1 to this attribute.

After the user enters his input and triggers an action by pressing on some button just check the values in both the input fields. If the value has been omitted in 1 of the fields then change the value of your boolean attribute (FLAG) to ' '. So now the column does automatically become hidden.

And regarding the other requirement of hiding rows which have a blank value in a particular column... Once you extract the data using your SELECT query into your internal table perform these additional steps in between.

loop at it_data into wa_data.
  if wa_data-field1 is initial.
    delete it_data
 endif.
endloop.

Now bind this new internal table to your context node. Your table would now automatically not display the rows which have initial values in 1 particular column.

Regards,

Uday

Former Member
0 Kudos

Hi Anitha,

What i understood from your question is,you want to control the table from your inputs.I have a one question for you what do you want to show defaultly i.e when you run the application what you want to show,either no table or table with some values.

Any how i am giving solution in this way.

If both inputs are given proper table output is displayed

Write your below logic in the WDDOMODIFYVIEW )

Here i am assuming that you already have a table element in the view.

Get the values entered in the input fields and compare those 2 values ,if the condition is satisfied then bind the values which you want to show in the table to the context node.

but if only 1 input is given a column is empty in the output table so i want to hide this column dynamically at runtime based on my inputs

You are telling that you know the empty column.If so get the view element reference and use the REMOVE_COLUMN to remove the column.

data:lr_table type ref to cl_wd_table,

lr_column type ref to L_WD_TABLE_COLUMN.

lr_table ?= view->get_element( 'TABLE1' ).

CALL METHOD LR_TABLE->REMOVE_COLUMN

EXPORTING

ID = 'TABLE1_color'

  • INDEX =

RECEIVING

THE_COLUMN = lr_column.

i want to hide some empty rows also at runtime based on inputs.

Removing the rows is very simple.if you know the key fields data of internal table from your input fields then do in this way.

delete itab from wa where key1= "12" and key2="abd".

Now bind the internal table to context node.

LO_ND_hcm->BIND_TABLE(

NEW_ITEMS = it_final

SET_INITIAL_ELEMENTS = ABAP_TRUE ).

Former Member
0 Kudos

Hi,

Thanks for the reply.

I will brief my webdynpro views.

There are 2 views one is input and another is output.

Output view is a table and i have already binded the fields to the context which i need in the output.

My query is if i give both the inputs i dont want to make any changes in the output table,

but if i give 1 input a column is always empty so i want to hide it.

And i want to do this with the present views without defining new views.

And now about the rows , if a column value corresponding to some rows is empty then i want to hide only these row.I want to display only those rows for which a particular column has entry.

Is this possible,please help me out.

Regards,

Anita.

arjun_thakur
Active Contributor
0 Kudos

hi anita,

to hide a col of a table , you can bind the visibilty property of that col to a context which should be of WDUI_VISIBILITY type. You can change the value of this context at run time according to your condition.

and for not displaying empty row in a table: you must be binding for table node with an internal table.

make sure that you don't append any empty line in the internal table with the help of a flag variable.

i hope it helps

regards

arjun