Application Development and Automation 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: 
Read only

dynamic column assignment to the table control

ramgopalyadav
Explorer
0 Likes
861

Hi ..

I have a requirement in which i have to assign the columns dynamically at the run time to the table control... for example ..like in the transaction MC81.

Anyway .. small help will be a great...

Thanx & Regards,

Ramgopal

3 REPLIES 3
Read only

Former Member
0 Likes
811

i think recently i saw some posting on this topic..

one week or 10days back..

try to find using search...

reagrds

vijay

Read only

Former Member
0 Likes
811

Hi

You can define the TC with all possible fields and at run time manipulate the column display.

Here is how it can be done :

In PBO -

DATA: cols LIKE LINE OF tcname-cols.

LOOP AT tcname-cols

INTO cols where index = n (whatever the column no).

cols-invisible = '1'.

"1 for invisible true and 0 for false

MODIFY TCNAME-cols FROM cols INDEX sy-tabix.

ENDLOOP.

Regards

Kalpana

Message was edited by: Kalpana Tyagi

Read only

former_member186741
Active Contributor
0 Likes
811

Hi Ramgopal,

I'm not sure if it's what you want but you can set up a table control relating to a generic table where every column is, say, 20 chars and then populate that from whichever source you like. For example I created a simplistic version of SE16 where I can put the name of the dictionary table I want to display on the selection screen and the next screen shows a table control holding the first 5 columns of the first few rows of the selected table.

The start of the program was:

PARAMETERS: p_table TYPE tablename OBLIGATORY.

TABLES znrw_tc. " has 5 cols...col01,col02 etc each c20

DATA w_row TYPE znrw_tc.

DATA t_tab TYPE TABLE OF znrw_tc WITH HEADER LINE.

FIELD-SYMBOLS: <table> TYPE ANY,

<in_column> TYPE ANY,

<out_column> TYPE any.

START-OF-SELECTION.

DATA dref TYPE REF TO data.

CREATE DATA dref TYPE (p_table).

ASSIGN dref->* TO <table>.

SELECT * UP TO 10 ROWS

FROM (p_table)

INTO <table>.

DO 5 TIMES.

ASSIGN COMPONENT sy-index OF STRUCTURE <table> TO <in_column>.

IF sy-subrc <> 0.

EXIT.

ENDIF.

ASSIGN COMPONENT sy-index OF STRUCTURE w_row TO <out_column>.

<out_column> = <in_column>.

ENDDO.

append w_row to t_tab.

...

ENDSELECT.

CALL SCREEN 0100.

......................

The hardest part was creating the table control with the wizard but I found that if I created a structure (ZNRW_TC) in SE11 it worked.