‎2009 May 14 7:17 AM
Hi ,
I need to have dynamic column based on the given input . for eg if i give 3 as input then it should give me 3 column as the out put . Can any one solve it .
Regards
Abeehs
‎2009 May 14 7:21 AM
A lot of people can probably be of some help, but you do need to be a bit more specific.
1. Does your output (internal table for example), have a variable number of columns?
2. which columns need to be output, the first three, or just 3 random columns?
3. Is your output an ALV?
4. etc. etc.
In case of ALV for example it will be quite easy to set the number of columns to be output to 3.
‎2009 May 14 7:24 AM
You can pass the selection screen parameter as (no. of coulumns) in brackets '()' to the variable which holds no. of columns.
It would automatically take the dynamic no. of columns entered.
‎2009 May 14 7:25 AM
Hi,
Basically i suppose you mean that your internal table will be dynamic.
There are a lot of posts in SDN on how to create in internal table dynamically.
Basically you will have to make use of method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE .
You will have to create a fieldcatalog which will contain details about the columns which you will need and that will help you in creating the dynamic internal table.
Regards,
Ankur Parab
‎2009 May 14 7:39 AM
Hi all,
Thanks for ur reply ..
My task to display the column dynamically based on the user input given in the parameter for eg . Consider a parameter . the user enter the value 5 . Then it has to show 5 columns as out put how to solve it
‎2009 May 14 7:44 AM
But do you also have a dynamic table? In other words, is the number of columns of your internal table FIXED or not?
1. If FIXED, use the ALV grid as output, in which you can enter a column of the field catalog and set the NO_OUT to 'X' (column is not output).
2. If dynamic number of columns, just provide only those columns to your method corresponding to the number of columns to be output.
Again, you need to be a bit more specific about your requirement.
‎2009 May 14 7:52 AM
Hi ,
You need to use FIELD-SYMBOLS to dynamically assign the columns.
Check the sample code -
PARAMETERS : P_ABC TYPE I.
FIELD-SYMBOLS : <FIELD> TYPE ANY.
TABLES : SCARR.
DATA : T_SCARR TYPE TABLE OF SCARR.
SELECT * FROM SCARR INTO TABLE T_SCARR.
LOOP AT T_SCARR INTO SCARR.
DO P_ABC TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE SCARR TO <FIELD>.
WRITE : <FIELD>.
ENDDO.
NEW-LINE.
ENDLOOP.Note : Here I have displayed the columns of SCARR as an example.
Regards
Pinaki