‎2005 May 28 2:05 PM
Hi,
How can we change the number of columns based on a value in the selection screen.
A period will be entered in the selection screen, the internal table should have as many columns as the number of months in that period entered.
How will we be able to do that ?
Thanks in advance,
Archana.
‎2005 May 28 2:19 PM
Hi archana
Check out the class "<b>CL_ALV_TABLE_CREATE</b>". Try its method called "<b>CREATE_DYNAMIC_TABLE</b>". It is some easy just prepare a field catalog and call the method to give reference of dynamically created table.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
‎2005 May 30 4:39 AM
Hi,
Can have a look at this
Retrieving field names dynamically
Sometimes you may have only a table name and want to retrieve the name of each field of the corresponding table. For example, when you want to use ASSIGN COMPONENT fieldname OF TABLE table.
An ABAPer's first reaction is to read the standard ABAP basis tables DD02L, DD03L, etc
This way of reading fields is very slow. Use methods from the class CL_ABAP_TYPEDESCR instead.
Example:
data: descr_struc_ref TYPE REF TO cl_abap_structdescr.
descr_struc_ref ?= cl_abap_typedescr=>describe_by_name('SFLIGHT' ).
Here is the result of descr_struct_ref after the execution of this piece of code
ABSOLUTE_NAME C 200 TYPE=SFLIGHT
TYPE_KIND C 1 u
LENGTH I 4 80
DECIMALS I 4 0
KIND C 1 S
STRUCT_KIND C 1 F
COMPONENTS h 8 Table[14x40]
HAS_INCLUDE C 1
The table COMPONENTS is filled with :
LENGTH DECIMALS TYPE_KIND NAME
3 | 0 |C |MANDT
3 | 0 |C |CARRID
4 | 0 |N |CONNID
8 | 0 |D |FLDATE
etc.
You have the fields name and a lot more information about the table. This class can also handle structure, table type, etc.
Note that this method is very fast because it uses the database layer directly thanks to SYSTEM CALLs.
To have a look at the class, use transaction SE24.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap faqs.faq#q-25
Thanks & Regards,
Judith.