cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a table dynamically (through code) in a smartform?

Former Member
0 Kudos

Hi,

I want to create a smartform where just by passing the internal table name and the TABLE TYPE of the internal table from the driver program to the smartform, the smartform will display the internal table contents to the user in the table format. This means, as the internal table can be of any table type, the no. and data type of the columns will be different and the smartform will be smart enough to draw the table layout automatically and display the contents. How will I achieve this? Any hint will be welcome. Thanks in advance.`

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Anirban,

First go to Se11 and create a new table type in the data type( for eg zit_mara) containing all the fields that you want to display dynamically in the smartform.Then create a smartform and in the form interface declare a variable( for eg lt_mara which is the internal table that recieves the data from the driver program and assign it's type as zit_mara). Also declare a work area wa_mara type zit_mara. Now the window in which you want to display the table dynamically, right click, select flow logic and create a loop.Here mention the internal table name(for eg lt_mara) INTO work area wa_mara. Create a text in the same window and mention all the work area fields that are to be displayed. Now you have to declare the same internal table in the driver program( lt_mara type zit_mara) which contains the table data to be displayed on the smartform and pass it to the smartform through the interface of the function module call in the driver program.

Regards,

Ram.

Former Member
0 Kudos

Hello Anirban,

As we can't change the layout of Smartfrm dynamically we have to fix it.

1. Just Create a table structure of 5 equal sized column.

2. Now create a structure in TYPES

TYPES : BEGIN OF i_table,

FIELD1(15) type c,

FIELD2(15) type c,

FIELD3(15) type c,

FIELD4(15) type c,

FIELD5(15) type c,

END OF i_table.

3. Now create a table in "FORM INTERFACE"

4. Display the same in your smartforms.

Now in your Print program create the same table as above.

1. Now you can move the first 5 fields data from your dynamic internal table to the interface table.

2. You can add up a popup saying only first 5 fields can be displayed.

Note : if the field length is bigger then you have to use a variable to cut out only first 15 character to put it into the interface table.

Hope this hint helps you a bit to gather some knowledge for your requirement.

Cheers,

Suvendu

former_member198441
Participant
0 Kudos

use


data :i_table  type ref to data .
field-symbols :<table>  type table,         " Main Internal Table

**create dynamic table 
    call method cl_alv_table_create=>create_dynamic_table
      exporting
        it_fieldcatalog =   pass ur table type
      importing
        ep_table        = i_table.
    assign i_table->* to <table>.

regards,

PP

Edited by: P.P on Jun 3, 2009 2:15 PM

Edited by: P.P on Jun 3, 2009 2:16 PM

Edited by: P.P on Jun 3, 2009 2:16 PM

Former Member
0 Kudos

Hi,

As far as I know, CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE creates a dynamic internal table from the field catalog, but I want to draw the table layout in smartform dynamically (no. of columns will be according to the TABLE TYPE of the internal table). Can this be achieved through some HTML coding or something? Or else how can this be achieved?