Displaying tables with dynamic number of columns

Hello,
I'm pretty new to JSF. Currently I'm working on a project where I have to select a table from a list, and then make it browsable/editable. The problem I have is that the different tables also have a different number of columns.
I have no problem displaying different tables if the number of coulumns stays the same (using h:datatable) but when it's dynamic, I don't know how I can have my JSP to adjust to support the varying number of columns.
Has anyone got an example of dynamic datatable or maybe someone can point me in the right direction.
Brimborian

Hi daniel,
1. There is an INDEPENDENT FORM
  whose inputs are FIELD LIST
  and from those, it consructs dynamic table.
2. Here is the program.
the dynamic table name will be
<DYNTABLE>.
3. U can use this program (FORM in this program)
to generate any kind of internal table
by specifying some inputs (ie. field list)
4.
REPORT abc.
COMPULSORY
FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
FIELD-SYMBOLS: <dynline> TYPE ANY.
DATA: lt TYPE lvc_t_fcat.
DATA: ls TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA : fldname(50) TYPE c.
PARAMETERS : infty(4) TYPE c OBLIGATORY.
DATA : iname LIKE dd02l-tabname.
START-OF-SELECTION.
GET INFO
CONCATENATE 'P' infty INTO iname.
DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
EXPORTING
tabname = iname
TABLES
ddfields = ddfields.
CONSTRUCT FIELD LIST
LOOP AT ddfields.
ls-fieldname = ddfields-fieldname.
APPEND ls TO lt.
ENDLOOP.
PERFORM
PERFORM mydyntable USING lt.
BREAK-POINT.
INDEPENDENT FORM
FORM mydyntable USING lt TYPE lvc_t_fcat .
Create Dyn Table From FC
FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
FIELD-SYMBOLS: <fs_1>.
FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
DATA: lt_data TYPE REF TO data.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Assign Dyn Table To Field Sumbol
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <dyntable>.
ENDFORM. "MYDYNTABLE
regards,
amit m.

Similar Messages

  • BI  Layout/Template | Table with dynamic number of columns

    hi!
    i have a problem concerning the creation of a dynamic report with the BI publisher.
    in my BI template i need a table with a dynamic number of columns. i have searched the
    forums but havent really found a solution for this type of problem.
    first of all this is A dummy-structure of my dataset:
    <ROWSET>
         <ROW>
              <FIELD1>1</FIELD2>
              <FIELD2>2</FIELD2>
              <FIELD3>3</FIELD3>
              <FIELD4>4</FIELD4>
         </ROW>
         <ROW>
              <FIELD1>a</FIELD2>
              <FIELD2>b</FIELD2>
              <FIELD3>c</FIELD3>
              <FIELD4>d</FIELD4>
         </ROW>
    </ROWSET>
    in the report the fields represent the columns i need in the table.
    the problem is, that the number of the fields vary. in this example i have 4 fields/columns
    but another time i may have 6 or 10 etc..
    my dataset is always different because i am loading my dataset via a http request which is
    returning the needed data in XML.
    is there a nativ possibility within the publisher to generate the columns dynamically?
    i read about <?split-column-header:group element name?> etc. but this is only for cross-tables.
    can anybody give me a hint how to approach this problem?
    would be very glad for some advice.
    thanks a lot in advance!

    Specific answer is here
    http://winrichman.blogspot.com/2008/09/dynamic-column.html
    but these link let you know, how to do
    http://winrichman.blogspot.com/search/label/Dynamic%20column
    http://winrichman.blogspot.com/search/label/Cross-tab
    http://winrichman.blogspot.com/search/label/cross%20tab

  • Display table with variable number of columns

    Hello Forum,
    I'm trying to build an export view of User Management Engine data. I would like to output a table with one row for every user with yes / no fields indicating membership in each of the available groups. Because the number of available groups might change in the future, I can't hardcode the column names for the groups.
    That is, I call a webservice to compute a table, and I get back a table with a variable number of columns.
    When I try to insert the webservice into my VC model, it complains:
    "Port 'Response' was omitted because it includes nested tables, which are not presently supported by Visual Composer"
    You might be interested to know that the business method of my webservice (for testing purposes) looks as follows:
    public String[][] getVariableSizeArray() {
            String[][] ret = new String[10][];
            for (int i = 1; i <= 10; i++) {
                    ret<i> = new String[10];
                    for (int j = 1; j <= 10; j++) {
                            ret<i>[j] = Integer.toString(i * j);
            return ret;
    Any help is appreciated, and points will be awarded for helpful answers,
    Sincerely,
    Florian
    Message was edited by:
            Florian Something

    Hi Florian,
    dynamic data structures are not supported. You can do this with a workaround. If you know the maximum count of your columns then you can add them to the table and hide/unhide them dynamicly via a formula in the hidden condition. Of course in your WS you als need a fix structure of your columns.
    This is not the best solution, I know so far, but it works. This is just one limit of VC.
    Best Regards,
    Marcel

  • How to create a table with varied number of columns?

    I am trying to create a balance table. The colunms should include years between the start year and end year the user will input at run time. The rows will be the customers with outstanding balance in those years.
    If the user input years 2000 and 2002, the table should have columns 2000, 2001, 2002. But if the user input 2000 and 2001, the table will only have columns 2000 and 2001.
    Can I do it? How? Thanka a lot.

    Why did you create a new thread for this?
    How to create a table with varied number of columns?

  • How can i export the data to excel which has 2 tables with same number of columns & column names?

    Hi everyone, again landed up with a problem.
    After trying a lot to do it myself, finally decided to post here..
    I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
    It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
    Because both the tables have same number of columns & column names.
    Below are 2 tables with column names:
    Table-1 (MONTHLY_PART_1)
    Table-2 (MONTHLY_PART_2)
    SL_NO
    SL_NO
    COMP
    COMP
    DUE_DATE
    DUE_DATE
    U-1
    U-1
    U-2
    U-2
    U-4
    U-4
    U-20
    U-20
    U-25
    U-25
    Since both the tables have same column names, I'm getting the following error :
    Error 402 at line 103, column 4
      alias required in SELECT list of cursor to avoid duplicate column names.
    So How can i export the data to excel which has 2 tables with same number of columns & column names?
    Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
    Help me with this please.
    Thank You.

    You'll have to *alias* your columns, not prefix it with the table names:
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id, b.id, a.val1, b.val1, a.val2, b.val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
      for rData in cData loop
    ERROR at line 18:
    ORA-06550: line 18, column 3:
    PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
    ORA-06550: line 18, column 3:
    PL/SQL: Statement ignored
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
    PL/SQL procedure successfully completed.
    cheers

  • Table with varying number of columns

    Hello experts,
    my issue:
    I need to print a table with varying number of columns. Depending on if all cells of a certain column are initial the
    whole column should disappear. Hiding is not enough.
    If this columns is in the middle of the table the following columns should move left to fill the gap.
    my approach: (maybe there is an easier one)
    There are 4 different possible situations. My approach was to create 4 different tables with different amount of
    columns. In the interface I fill the table that is really needed from the source table data and fill a flag that characteristics
    the situation, possible values (1,2,3,4).
    In the form I'd like to print the appropriate table depending on the situations.
    my problem:
    How to place all 4 possible tables lying upon each other in the form and print only the needed one depending on the flag value?
    my question:
    Is my approach ok? Or is there an easier one?
    If it is ok. How can I solve the problem regarding printing the right table.
    Thanks in advance!
    Heinz

    Hi Heinz,
    You can handle it with FormCalc Script at initialization.
    Suppose you have a table with name TABLE having a header HEADER and data row DATA:
    TABLE-->HEADER(Cell1...Cell2...Cell3...Cell4)
              --->DATA(Cell1...Cell2...Cell3...Cell4)
    Suppose you want to hide Cell3 for null values, then write below code at initialization of DATA:
    if(DATA[*].Cell3.rawValue eq null)
    then
    DATA[*].Cell3.presence = "hidden"
    HEADER.Cell3.presence = "hidden"
    else
    DATA[*].Cell3.presence = "visible"
    HEADER.Cell3.presence = "visible"
    endif
    Hope it would help.
    Regards,
    Vaibhav

  • How create table with variable number of columns?

    I am creating table data in Java. Number of columns is variable. How I can write <table> in UIX.
    Here is code of one of my unsuccessful attempt:
    <provider>
    <!- get table data like DataObjectList-->
    <data name="ReportTableData">
    <method class="app.ReportTableData" method="getTableData"/>
    </data>
    <!- get names of columns like DataObjectList-->
    <data name="ColumnNames">
    <method class="app.ReportTableData" method="getColumnNames"/>
    </data>
    </provider>
    <table data:tableData="@ReportTableData">
    <contents data:childData="@ColumnNames">
    <text data:text="nameColumn"/>
    </contents>
    </table>
    I hoped that I can get cell data by key, where key is name of column. But cells of table contain only names of columns.
    Please help me, where I mistaken?
    Thank you.

    Hi Sergey,
    The UIX table implementation relies on a childData like mechanism internally to iterate over the rows. For instance, when you databind the text attribute of the UINode used to stamp out each column, you are relying on the uix:table iterating over the table data using the data object for the current row when evaluating your column stamp.
    Setting the data:childData attribute on the table's contents element conflicts with UIX's internal iteration over the tableData. For this reason, we don't support specifying a dynamic number of table columns in UIX XML.
    This doesn't mean that you can't do it, there are different strategies. If you've got a finite and known set of columns, you can specify each possible column and then databind the rendered attribute of each one to hide and show it as appropriate. Another, often cleaner approach, is to build this subtree of UINodes in Java code.

  • Generating table with large number of columns (256)

    Hi,
    I don't know if this is right place for posting this:
    for data mining purposes I need a table which column names needs to be size N, where N is 2, 3 or 4. Column name is build upon alphabet of nucleotids A,C,T,G and all variations with repetition. For N=2, columns are: AA, AC, AT, AG, CA, CC, CT, CG, TA, TC, TT, TG, GA, GC, GT, GG (4^2 = 16). For N=3, 4^3 = 64, and for N=4 4^4 = 256.
    Primary key in table is array of nucleotids, and values in previously mentioned columns for each nucleotid array are 1 or 0, based on that if such nucleotid of size N exists in that chain or not.
    My questions are:
    1) is there any tool (in Oracle Data Miner or whatever) which can generate such table from array of nucleotids (one array of nucleotids is ordinary string)?
    2) It's not a problem to generate this table myself but is it "normal" to have database table with 257 columns (when N = 4)?
    I hope that my problem is clear (because of my English).
    Thanks in advance.
    Regards.

    Without knowing the reason for doing so, I would guess, this kind of design is quite poor.
    How are you planning to specify your queries? (I do know dynamic SQL would be a possibility ...).
    Another point of view:
    What if someone decides to have column names built using 5 nucleotids? This would exceed the maximum number of columns of a table which currently (10g, 11g) is 1000?

  • Generate itab with dynamic number of columns

    I have a method that exports a internal table to excel, XML or HTML, which works fine in many cases.
    Now I want to export some special data that I want to put into an itab first.
    The problem is that both the number of columns and the number of rows are dynamic.
    LOOP AT (header_table)
      (for each entry, I need one column)
    ENDLOOP.
    LOOP AT (row_table).
      (do some calculations and add a row to the itab)
    ENDLOOP.
    Is there a way to generate an internal table like this?

    Hi daniel,
    1. There is an INDEPENDENT FORM
      whose inputs are FIELD LIST
      and from those, it consructs dynamic table.
    2. Here is the program.
    the dynamic table name will be
    <DYNTABLE>.
    3. U can use this program (FORM in this program)
    to generate any kind of internal table
    by specifying some inputs (ie. field list)
    4.
    REPORT abc.
    COMPULSORY
    FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
    FIELD-SYMBOLS: <dynline> TYPE ANY.
    DATA: lt TYPE lvc_t_fcat.
    DATA: ls TYPE lvc_s_fcat.
    FIELD-SYMBOLS: <fld> TYPE ANY.
    DATA : fldname(50) TYPE c.
    PARAMETERS : infty(4) TYPE c OBLIGATORY.
    DATA : iname LIKE dd02l-tabname.
    START-OF-SELECTION.
    GET INFO
    CONCATENATE 'P' infty INTO iname.
    DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
    EXPORTING
    tabname = iname
    TABLES
    ddfields = ddfields.
    CONSTRUCT FIELD LIST
    LOOP AT ddfields.
    ls-fieldname = ddfields-fieldname.
    APPEND ls TO lt.
    ENDLOOP.
    PERFORM
    PERFORM mydyntable USING lt.
    BREAK-POINT.
    INDEPENDENT FORM
    FORM mydyntable USING lt TYPE lvc_t_fcat .
    Create Dyn Table From FC
    FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
    FIELD-SYMBOLS: <fs_1>.
    FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
    DATA: lt_data TYPE REF TO data.
    ASSIGN lt_data TO <fs_data>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = lt
    IMPORTING
    ep_table = <fs_data>
    EXCEPTIONS
    generate_subpool_dir_full = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    Assign Dyn Table To Field Sumbol
    ASSIGN <fs_data>->* TO <fs_1>.
    ASSIGN <fs_1> TO <fs_2>.
    ASSIGN <fs_1> TO <dyntable>.
    ENDFORM. "MYDYNTABLE
    regards,
    amit m.

  • How to create table with dynamic amount of columns which are nested columns

    M trying to fetch data and show in a javaFX table.
    My table displays the details of different items from ItemVO , where :
    public class ItemVO()
    String itemName;
    List<ItemTypeVO> type;
    and My ItemTypeVO has the following attributes :
    public class ItemTypeVO()
    String typeName;
    Integer quantity;
    Integer price;
    Now, i want to display the details of an item in a table in which the itemname and quantity will be displayed, the quantity column will have nested columns showing different types(typeName) as found from List<ItemTypeVO> inside ItemVO.
    This question is similar to this link but my not able to find how to link a list with itemVO for nested columns. :(
    Please help !!
    M still unable to find a solution..
    Edited by: abhinay_a on Jan 14, 2013 10:50 AM

    Hi Abhilash,
    Thanks for the quick reply.
    Actually the problem is with the image, as I am not able to rotate 270 degree. Crystal report cannot support the rotation of image.
    i have another problem, I have to create a report in which
    Lables are fixed on the left side of report and 3 columns per portrait page. Those columns are
    dynamically created and shown in the report.
    The format is like the above. Can you please help me in doing this report, as I tried it doing
    with CrossTab. I am really stuck to this report.

  • ADOBE Form Using Table with dynamic number of rows

    Hi All
    First some information about our infrastructure:
    - AdobeDesigner 7.1 in the Developerstudio
    - SAP-Portal 7.0 SP15
    I have a View with tabstrips and behind the tabs i have defined an event. On one Tab I included a ADOBE-Form with Table. The Data for the PDF sould only filled in the context for the Form when i jump to this Tab. I created the Form by using this documentation [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0859ad1-53aa-2a10-78ae-99e41c407669].
    To fill the tablecontext I use the following Code:
    IPrivateAnlegenBANFView.IPositionenElement position = null;
    IPrivateAnlegenBANFView.IPositionenNode posNode = wdContext.nodePositionen();
    int NUM_5_TIMES = 5;
    for (int i = 0; i < NUM_5_TIMES; i) {
    IPrivateAnlegenBANFView.IPositionenElement posElement = wdContext.createPositionenElement();
    +posElement.setMaterial("" + i);+
    +posElement.setKurztext("Test" + i);+
    +posElement.setWarengruppe("Warengr" + i);+
    posNode.addElement(posElement);
    If i put this code in the wdDoInit method it  works fine and shows me 5 Rows. But if I put the code in the Action of the tabstrip it shows me only one row. I checked the entries of the context and there are 5 entries (showed them in a WD-Table).
    Can someone tell me what im doing wrong?
    Thanks for a answer and kind regards
    Pascal

    Hi All
    finally i found the solution for the problem.
    When you define the interactive Form in the view do not define the property "dataSource" of UI-Element Interactive Form it seems, that the binding is static and not dynamic.
    Add the following source to the viewCotroller
    Global Part of the Source:
    private static IWDInteractiveForm form = null;
    Method wdDoModify:
    if (firstTime) {
      form = (IWDInteractiveForm) view.getElement("InteractiveForm");
    When you have an Event where you fill your Contextnode which you want to display in the table of an Adobe Form Use this code:
    Action:
    public void onActionFillTab(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ){
      //@@begin onActionFillTab(ServerEvent)
         * Code to fill the Node for AdobeForm Table
        form.bindDataSource(wdContext.nodeTabelle().getNodeInfo());
      //@@end
    If you want to clear your table and show it directly use in the action the following code:
    wdContext.nodeTabelle().invalidate();
    form.bindDataSource(wdContext.nodeTabelle().getNodeInfo());
    Kind regards
    pascal

  • How to display data in table with dynamic rows, section wise in a page.

    Hello all,
    I work on report creation in BI Publisher where I need to display data from xml in a table in pdf format.The output page is divided into two vertical sections , containing tables, with exactly same columns on left and right sections. The number of rows in table depends on the output of the fetching query. The page is to be populated in such a way that, at first, the left table is populated, then the next rows fill up the table on the right section of the page, if more rows are left, they fill up the tables on next page[first the left table, and then the right one, in a similar fashion as in page 1]
    On a bird's eye view, the data needs to be simply mapped to a table, with dynamic number of rows, and so can span number of pages depending on size of data. On a implementation level, I am stuck in getting the left section of the page populated first, then the right section[in place of the right page], and then the next page.
    Please guide me if someone has any idea in getting this achieved.
    Thanks in advance.

    Thanks for the response...
    I am able to get the desired functionality. I just need the tables to be inside a bigger table, that also has a dividing line between the two columns. This is was is intended in the req. provided to me. The column formatting option provides me a line ,but that is not further modifiable .Please help me in getting a perpendicular line between the two columns, which I need to be of a specified width and color.

  • How to clone data with in Table with dynamic 'n' number of columns

    Hi All,
    I've a table with syntax,
    create table Temp (id number primary key, name varchar2(10), partner varchar2(10), info varchar2(20));
    And with data like
    insert itno temp values (sequence.nextval, 'test', 'p1', 'info for p1');
    insert into temp values (sequence.nextval, 'test', 'p2', 'info for p2');
    And now, i need to clone the data in TEMP table of name 'test' for new name 'test1' and here is my script,
    insert into Temp  select sequence.nextval id, 'test1' name, partner, info from TEMP where name='test1';
    this query executed successfully and able to insert records.
    The PROBLEM is,
    if some new columns added in TEMP table, need to update this query.
    How to clone the data with in the table for *'n' number of columns and*
    some columns with dynamic data and remaining columns as source data.
    Thanks & Regards
    PavanPinnu.
    Edited by: pavankumargupta on Apr 30, 2009 10:37 AM

    Hi,
    Thanks for the quick reply.
    My Scenario, is we have a Game Details table. When ever some Game get cloned, we need to add new records in to that Table for the new Game.
    As, the id will be primary key, this should populate from a Sequence (in our system, we used this) and Game Name will be new Game Name. And data for other columns should be same as Parent Game.
    when ever business needs changes, there will be some addition of new columns in Table.
    And with the existing query,
    insert into Temp (id, name, partner, info) select sequence.nextval id, 'test1' name, partner, info from TEMP where name='test'_
    will successfully add new rows but new added columns will have empty data.
    so, is there any way to do this, i mean, some columns with sequence values and other columns with existing values.
    One way, we can do is, get ResultSet MetaData (i'm using Java), and parse the columns. prepare a query in required format.
    I'm looking for alternative ways in query format in SQL.
    Thanks & Regards
    PavanPinnu.
    Edited by: pavankumargupta on Apr 30, 2009 11:05 AM
    Edited by: pavankumargupta on Apr 30, 2009 11:05 AM

  • Dynamic Number of Column in a table

    Hi guys,
    I have a requirement that needs dynamic number of column in a tale.
    It is possible to do this in Adobe forms.
    Thanks,
    Chirantan

    Hello. It of course is possible in Adobe.
    You need to write a simple script using JavaScript or FormCalc to hide or show columns according to some special value. You will work with the presence attribute of the object. E.g. MYFIELD.presence = "visible" or "hidden" or "invisible". You will need to change your subforms content to flowed.
    Use these guides:
    http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf
    help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Hope this helps, good luck, Otto

  • Internal table with variable no of columns

    Hi All,
    I have to create an internal table with some fixed columns and rest of the table should be dynamic. The total no of columns depends on a field of some other table. hence, the number of columns of the table are unknown. How to create such a table.
    Thanks,
    Neha

    Execute this program .. we will get a fair idea about how the dyanmic column are populated in the table. Based on that u can write ur sceond table with 92 columns
    *& Report  ZTEST009
    REPORT  ztest009 NO STANDARD PAGE HEADING LINE-SIZE 60 LINE-COUNT 2(1).
    TYPE-POOLS : slis.
    TYPES : BEGIN OF internal,
            matnr(18),
            werks(4),
            qtyn(20),
            desc(20) TYPE c,
            qty TYPE i,
            END OF internal.
    DATA : it TYPE TABLE OF internal,
           wa TYPE internal.
    DATA : fieldcat  TYPE lvc_t_fcat,
           lcat      TYPE lvc_s_fcat,
           final_cat TYPE slis_t_fieldcat_alv,
           fcat      TYPE slis_fieldcat_alv,
           top       TYPE slis_t_listheader,
           events    TYPE slis_t_event,
           layout    TYPE slis_layout_alv.
    DATA : newfield  TYPE REF TO data,
           newdata   TYPE REF TO data.
    FIELD-SYMBOLS : <fs1>,
                    <dynamic_value>,
                    <dynamic_cat> TYPE STANDARD TABLE.
    START-OF-SELECTION.
      PERFORM popudate.
      PERFORM buildcat.
      PERFORM loadata.
      PERFORM events USING events.
      PERFORM header USING top.
      PERFORM layout.
    END-OF-SELECTION.
      PERFORM display.
    *&      Form  popudate
          text
    -->  p1        text
    <--  p2        text
    FORM popudate .
      DEFINE popu.
        wa-matnr = &1.
        wa-werks = &2.
        wa-qtyn = &3.
        wa-desc = &4.
        wa-qty = &5.
        append wa to it.
        clear wa.
      END-OF-DEFINITION.
      popu 'material1' 'pla1' 'QTY1' 'quantity1' 100.
      popu 'material1' 'pla1' 'QTY2' 'quantity2' 200.
      popu 'material1' 'pla1' 'QTY3' 'quantity3' 300.
      popu 'material2' 'pla2' 'QTY1' 'quantity1' 400.
      popu 'material2' 'pla2' 'QTY2' 'quantity2' 500.
      popu 'material2' 'pla2' 'QTY3' 'quantity3' 600.
      popu 'material3' 'pla3' 'QTY1' 'quantity1' 700.
      popu 'material3' 'pla3' 'QTY2' 'quantity2' 400.
      SORT it BY matnr.
    ENDFORM.                    " popudate
    *&      Form  buildcat
          text
    -->  p1        text
    <--  p2        text
    FORM buildcat .
      lcat-fieldname = 'MATNR'.
      lcat-datatype = 'CHAR'.
      lcat-seltext = 'Material'.
      lcat-intlen = 18.
      APPEND lcat TO fieldcat.
      CLEAR lcat.
      lcat-fieldname = 'WERKS'.
      lcat-datatype = 'CHAR'.
      lcat-seltext = 'Plant'.
      lcat-intlen = 4.
      APPEND lcat TO fieldcat.
      CLEAR lcat.
      LOOP AT it INTO wa.
        READ TABLE fieldcat INTO lcat WITH KEY fieldname = wa-qtyn.
        IF sy-subrc <> 0.
          lcat-fieldname = wa-qtyn.
          lcat-datatype = 'CHAR'.
          lcat-seltext = wa-desc.
          lcat-intlen = 10.
          APPEND lcat TO fieldcat.
          CLEAR lcat.
        ENDIF.
      ENDLOOP.
      CLEAR lcat.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
       i_style_table             =
          it_fieldcatalog           = fieldcat
       i_length_in_byte          =
        IMPORTING
          ep_table                  = newfield
       e_style_fname             =
    EXCEPTIONS
       generate_subpool_dir_full = 1
       others                    = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ASSIGN newfield->* TO <dynamic_cat>.
      CREATE DATA newdata LIKE LINE OF <dynamic_cat>.
      ASSIGN newdata->* TO <dynamic_value>.
    ENDFORM.                    " buildcat
    *&      Form   loadata
          text
    -->  p1        text
    <--  p2        text
    FORM  loadata .
      DATA flag TYPE i.
      LOOP AT it INTO wa.
        flag = 0.
        ASSIGN COMPONENT 'MATNR' OF STRUCTURE <dynamic_value> TO <fs1>.
        <fs1> = wa-matnr.
        ASSIGN COMPONENT 'WERKS' OF STRUCTURE <dynamic_value> TO <fs1>.
        <fs1> = wa-werks.
        CALL FUNCTION 'AIPC_CONVERT_TO_UPPERCASE'
          EXPORTING
            i_input  = wa-qtyn
            i_langu  = sy-langu
          IMPORTING
            e_output = wa-qtyn.
        ASSIGN COMPONENT wa-qtyn OF STRUCTURE <dynamic_value> TO <fs1>.
        <fs1> = wa-qty.
        AT END OF matnr.
          APPEND <dynamic_value> TO <dynamic_cat>.
          CLEAR : <dynamic_value>.
        ENDAT.
        CLEAR : wa.
      ENDLOOP.
    ENDFORM.                    "  loadata
    **&      Form  display
          text
    -->  p1        text
    <--  p2        text
    FORM display .
      LOOP AT fieldcat INTO lcat.
        fcat-fieldname = lcat-fieldname.
        fcat-outputlen = lcat-intlen.
        fcat-seltext_l = lcat-seltext.
        APPEND fcat TO final_cat.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = sy-repid
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
         is_layout                      = layout
         it_fieldcat                    = final_cat
      IT_SORT                        =
      I_SAVE                         = ' '
      IS_VARIANT                     =
         it_events                      = events
        TABLES
          t_outtab                       = <dynamic_cat>
    ENDFORM.                    " display
    Regards,
    Aswin.

Maybe you are looking for

  • SharePoint Foundation 2013 Installation Error

    Hi, While doing the SharePoint Foundation Installation 2013 I'm getting below error screen when I click on Install Software Prerequisites. Can you please advice how to resolve this issue :-

  • Thumbnail view for ical?

    i love the mimum window for itunes (it shows only what's playing and a couple buttons for control by clicking the green window control button in titlebar)... is there a way to shrink ical down to do the same kind of thing? it would be ideal to show e

  • PLS give me a small drawing

    Hello PLS give me a small pice of code with a JFrame(in an application) which will have a button and a simple shape(an circle for ex.), (no complicate Layouts, whith setLayout(new FlowLayout()); for ex.). I'd like that when the button is presed a win

  • Need help with Tsql Query

    Hi all One of our SQL jobs collects the SQLstatement which is running loner than 10 minutes by querying dm_exec_sql_text and dm_exec_sql_sessions. Now the table has the similar records like below SQL statementColumn SELECT * FROM    [DB].[dbo].[TABLE

  • PSE 3.0 vs. Paint Shop Pro 9

    Ich hätte mal gern ein paar rein subjektive Meinungen bzw. Ansichten zu dem Thema. Ich möchte keine Verweise auf irgendwelche Testpublikationen sondern Meinungen oder Auffassunegn von Leuten die beide Programme mehr oder weniger kennen, und deren Mei