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

how to control internal table columns dynamically based on input

Former Member
0 Likes
501

i have 2 fields in the selection screen - user and tcode

we can give any number of tcodes as in put

based on requirement i need to display all the tcodes belongs to one user in one row

in other words

the out put table columns should increase dynamically based on number of tcodes entered

in the input

how to do this?

Edited by: tummala swapna on Apr 7, 2009 11:55 AM

3 REPLIES 3
Read only

Former Member
0 Likes
471

use the class CL_ALV_TABLE_CREATE - >CREATE_DYNAMIC_TABLE for dynamic table creation.

Read only

former_member873340
Active Participant
0 Likes
471

Hi Swapna,

You can certainly achieve this.

Just a sample code

DATA : lt_dy_tab_fields TYPE lvc_t_fcat WITH HEADER LINE.

cl_alv_table_create=>create_dynamic_table(

EXPORTING

it_fieldcatalog = lt_dy_tab_fields[]

IMPORTING

ep_table = tab_ref1 ).

ASSIGN tab_ref1->* TO <table_sum>.

*Line item is created using the TAB_REF

CREATE DATA line_ref LIKE LINE OF <table>.

ASSIGN line_ref->* TO <line>.

You have to fill up the lt_dy_tab_fields with the list of the columns, the method wil convert it to a internal table.

Tell me in case u need any help.

Gowri

Read only

Former Member
0 Likes
471

This may be useful to you..

FIELD-SYMBOLS : <FS_TABLE> TYPE ANY TABLE.

DATA: DREF TYPE REF TO DATA,

WA_DREF TYPE REF TO DATA,

DY_LINE TYPE REF TO DATA,

ITAB_TYPE TYPE REF TO CL_ABAP_TABLEDESCR,

WA_TYPE TYPE REF TO CL_ABAP_STRUCTDESCR,

STRUCT_TYPE TYPE REF TO CL_ABAP_STRUCTDESCR,

ELEM_TYPE TYPE REF TO CL_ABAP_ELEMDESCR,

COMP_TAB TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE,

COMP_FLD TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,

OTAB TYPE ABAP_SORTORDER_TAB,

OLINE TYPE ABAP_SORTORDER.

  • BEGIN DYNAMIC STRUCTURE FOR FINAL INTERNAL TABLE @@@@@@@@@@@@@@@@@@

STRUCT_TYPE ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME('table or structure name').

COMP_TAB = STRUCT_TYPE->GET_COMPONENTS( ).

STRUCT_TYPE = CL_ABAP_STRUCTDESCR=>CREATE( COMP_TAB ).

ITAB_TYPE = CL_ABAP_TABLEDESCR=>CREATE( STRUCT_TYPE ).

CREATE DATA DREF TYPE HANDLE ITAB_TYPE.

ASSIGN DREF->* TO <FS_TABLE>.

  • END DYNAMIC STRUCTURE FOR FINAL INTERNAL TABLE @@@@@@@@@@@@@@@@@@