Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding dynamic columns in Table Control

Former Member
0 Kudos

Hi All,

Can we add dynamic columns in a table control? The requirement is something like this. When the user clicks a button it should add a column to the table. Also is it possible for the same column to refer to different fields of the Internal Table of the Database table. Example. The first row in the table control must refer to MARA-MATNR and the second row must refer to MAKT-MAKTX.

Regards,

Sudhindra

1 ACCEPTED SOLUTION

Former Member
0 Kudos

This is much easier to do, using ALV approach. Let us know, if you have any particular reasons to choose Table Control over ALV.

<b>Your Requirements</b>:

a) <b>Add a column on pressing a button</b>

In the user command, make change the parameter NO_OUT to space, for that particular field in the field catalog.

b) <b>Same column to refer to different fields of Internal table of database table</b>

Change Row sequence in fieldcatalog

(In this case, what information you have given and the example you have quoted is no way related/I have not understood).

If you need to use table control, you might have to generate programs with dynpros. There are some Function Modules available, however, I feel that it things get just more complicated.

Regards,

Subramanian V.

7 REPLIES 7

Former Member
0 Kudos

This is much easier to do, using ALV approach. Let us know, if you have any particular reasons to choose Table Control over ALV.

<b>Your Requirements</b>:

a) <b>Add a column on pressing a button</b>

In the user command, make change the parameter NO_OUT to space, for that particular field in the field catalog.

b) <b>Same column to refer to different fields of Internal table of database table</b>

Change Row sequence in fieldcatalog

(In this case, what information you have given and the example you have quoted is no way related/I have not understood).

If you need to use table control, you might have to generate programs with dynpros. There are some Function Modules available, however, I feel that it things get just more complicated.

Regards,

Subramanian V.

0 Kudos

Hi Subramanian,

Thanks for the quick reply. Appreciate that. We can go for the ALV control but this has to be both display as well as a input container. Also this has to support F4 functionality(Search Help). Also what I meant by different fields in a column is something like this.

1st row in the column should refer to -> MARA-MATNR

2nd row in the same column should refer to -> MAKT-MAKTX

0 Kudos

You can use ALV for input purpose as well. Check out OO ALV programs. SE38 -> BCAlVEDIT* , tons of programs available.

a) Input from user - In ALV, this is possible

b) F4 help - Possible with ALV

Not sure why would you need material number and description in the same column and that too one below another. It is possible with lot of tweaking but still requirement is strange and you need to have at least two rows for the same MATNR, one with the number and other with description.

Regards,

Subramanian V.

Former Member
0 Kudos

Hello Sudhindra,

If you know all the columns that the table control will ever contain, then I suppose it is possible to add and delete the columns dynamically.

What cannot be dynamic, is the determination of which coulmn would be displayed in the table control.

To elaborate, In SE51, you have to define the table control with all the possible columns. In the program, during the PBO, you can choose to hide some of these columns. When the user performs certain action (PAI), you can determine which opf the hidden columns would be displayed in the table control after the next PBO.

Coming to your second requirement, I don't think it is directly possible in case of table conrols. You will have to do some manipulation to achieve it. But even if you can I think you should not. Because, It is not elegant from a good-UI design perspective. ANd during the course of the necessary manipulations, we might have to forgo some of the features like Automatic Field Validation, Automatic Input Help etc. You can use ALV for the same.

Please be judicious in deciding which approach to consider and if you run into some more problems, please do get back with some more details like how many columns you have, how many different row-types do you want, what are the features for the fields that you wish to provide (eg. F4 help) an so on...

Regards,

Anand Mandalika.

0 Kudos

Hi Poornanand,

Thanks a lot for your valuable suggestion. I know that this is not a good design and we are mixing up the fields in a single column. But the client is very specific about this for usability issues. There are going to be 5 dynamic columns. The design should be something like this

Components LOB1 LOB2 LOB3 LOB4 LOB5 LOB6

-


Gross Premium 1000 200 300 400 100 500

Outstanding Loss 300 100 400 500 600 50

The components can grow vertically in length. Now below the LOB(Line of Business) they are the amount fields. The LOB field in the Table control must have an search help.

Now I know that once a column in the table control has got a search help it will reflect in all the rows of that column.

Can we do this approach? We have two table controls one for LOB and the other just for the components and the amounts. And while scrolling one of them the other should also scroll along with it?

0 Kudos

Hi,

I had a similar situation in my previous project where the client was very specific about usability as well; which usually turn out to be a perception problem and how the client is currently visualizing/looking at the system.

From your requirement, I think you should try a quick prototype screen development where your LOB is 1st column, Gross Prem as 2nd and Outstanding Loss as 3rd column. I am sure once the client looks at the screen, he will give it a second thought. By adopting this approach, your need for dynamic columns might be converted into dynamic rows, which is no problem in table/any other control.

Scrolling of two table can be worked out as well but as I said, try the above mentioned approach.

Hope it helps.

Regards

0 Kudos

Hi Shehryar,

That could be one of the solutions but the pain is that the component(Gross Premium, Outstanding Loss) are also dynamic. He can add componennts for the respective LOBs as well. So in that case again it becomes dynamic.

Regards,

Sudhi