JSP: Create Dynamic 2 Column Table looping through iter.hasNext()

Hi,
I have created an ArrayList which I populate with 2 strings per element - if such a thing exists. for example my array would have
{ccc, email}
{bbb,ip}
{aaa,dsl}
{ddd,tv}
I then sort this list using Collections.sort in which case I end up with the following:
aaa, dsl
bbb, ip
ccc, email
ddd, tv
However, I want display the contents in 1 table with 2 columns with a check box in front of each
i.e.
checkbox - aaa, dsl checkbox ccc, email
checkbox- bbb, ip checkbox ddd, tv
I would be happy if the table was like the above, however, even if if bbb,ip printed in the right column I would be ok.
This list example only contains 4 rows now but it could be 5 rows, 6 rows, 7 etc. It can grow/strink so that would be dynamic as well.
I think I need to build a for loop or while loop and to somehow spit out the contents of the first element then increment and check against total lsit and do the second td statement etc. But I am not totally sure. Anyhow, I hope I haven't confused anyone who reads this. Appreciate any help or direction. Thanks

the reason each list element contains 2 pieces of data is so that I can keep the login and type together for sorting purposes and can probably display the login -aaa along with the correct type Email etc.
here is a snip of the code if it will help.
List listTmp = new ArrayList();
ArrayList allLogins = new ArrayList();
for(int i=0;i<service_output.length;i++)
String[] tmpStr = new String[2];
n = service_output.indexOf('(');
if (n > 0)
serviceType = service_output[i].substring(0, n);
restOfString = service_output[i].substring(n+1);
int atsign_index = 0;
atsign_index = restOfString.indexOf('@');
if ((atsign_index) > 0)
loginPrefix = restOfString.substring(0, atsign_index);
tmpStr[0] = loginPrefix;
tmpStr[1] = serviceType;
LoginServType login1 = new LoginServType (tmpStr[0], tmpStr[1]);
allLogins.add(login1);
serviceCount++;
else
continue;
else
continue;
roundServices= new BigDecimal(serviceCount/maxcols).setScale(2, BigDecimal.ROUND_UP);
Collections.sort(allLogins);
//Iterator iter = allLogins.iterator();
for (Iterator iter = allLogins.iterator(); iter.hasNext();)
LoginServType loginiter = (LoginServType)iter.next();
String tempService = myformat.translateService(loginiter.getServType());
%>
<table summary="" class="dataDisplay borderCollapse autoLayout width100pc">
<colgroup>
<col class="alignLeft width30pc" />
<col class="alignRight width30pc" />
</colgroup>
<thead>
<tr>
<th class="alignLeft sublabel_display"></th>
</tr>
</thead>
<tbody>
<tr class="">
<input type="checkbox" name="username" value="<%=loginiter.getLogin()%>"><%=loginiter.getLogin()%> -
<%=tempService%>
<%iter.next(); %>
<input type="checkbox" name="username" value="<%=loginiter.getLogin()%>"><%=loginiter.getLogin()%> -
<%=tempService%>
</tr>
</tbody>
</div>
<%
}//end of for loop
%>
</table>
</div>
</div>

Similar Messages

  • How to create dynamic nested internal table

    Hi Experts,
    Pleae tell me or give sample code, how to create dynamic nested internal table ?
    I have seen threads saying creation of dynamic internal tables using some table structure only. But now the requirement is to create dynamic nested internal table.
    For example the internal table contains two fields viz., one is field1 of dynamic internal table and other is normal field2 and values as shown below:
    Nested internal table:
    field1                     |     field2 ...
    <table content1>     |     value2..
    <table content1>     |     value2..
    Here the [table content] should also a dynamic internal table.
    Let me know if you need any other info.
    regards
    Saravanan R

    see the complete code..i am currently working in ECC6.0 EHP4. just check which version you are using..
    REPORT  yst_test_000.
    DATA:
          lt_comptab         TYPE cl_abap_structdescr=>component_table,
          ls_comp            LIKE LINE OF lt_comptab,
          lref_newstr        TYPE REF TO cl_abap_structdescr,
          lref_tab_type      TYPE REF TO cl_abap_tabledescr,
          lt_fcat            TYPE lvc_t_fcat,
          ls_fcat            TYPE lvc_s_fcat,
          ls_dd03p           TYPE dd03p,
          lt_data            type ref to data.
    field-symbols: <fs_table> type standard table.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name       = 'SCARR'
      CHANGING
        ct_fieldcat            = lt_fcat
      EXCEPTIONS
        inconsistent_interface = 1
        program_error          = 2
        OTHERS                 = 3.
    IF sy-subrc NE 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    LOOP AT lt_fcat INTO ls_fcat.
      IF ls_fcat-ref_table IS NOT INITIAL.
        CLEAR ls_dd03p.
        CALL FUNCTION 'BUS_DDFIELD_GET'
          EXPORTING
            i_tabnm         = ls_fcat-ref_table
            i_fldnm         = ls_fcat-fieldname
          IMPORTING
            e_dd03p         = ls_dd03p
          EXCEPTIONS
            field_not_found = 1
            OTHERS          = 2.
        IF sy-subrc EQ 0.
          ls_comp-name = ls_fcat-fieldname.
          ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_dd03p-rollname ).
          APPEND ls_comp TO lt_comptab.
          CLEAR ls_comp.
        ENDIF.
      ELSE.
        ls_comp-name = ls_fcat-fieldname.
        ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_fcat-rollname ).
        APPEND ls_comp TO lt_comptab.
        CLEAR ls_comp.
      ENDIF.
    ENDLOOP.
    *Now for the Field which you want deep table then you can do like this
    ls_fcat-fieldname  = 'NESTED_TABLE'.
    ls_fcat-inttype    = 'C'.
    ls_fcat-intlen     = '000006'.
    ls_fcat-rollname   = 'SFLIGHT_TAB1'. "For SFLIGHT
    APPEND ls_fcat TO lt_fcat.
    ls_comp-name = ls_fcat-fieldname.
    ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_fcat-rollname ).
    APPEND ls_comp TO lt_comptab.
    CLEAR ls_comp.
    lref_newstr = cl_abap_structdescr=>create( lt_comptab ).
    lref_tab_type = cl_abap_tabledescr=>create( lref_newstr ).
    create data lt_data type handle lref_tab_type.
    assign lt_data->* to <fs_table>.
    break-point.
    Edited by: Vijay Babu Dudla on Apr 28, 2009 8:05 AM

  • Cannot create a temporary column table in HANA SP8 console

    Hi All,
    We upgraded the HANA to SP8 version this week, and found there are some issues when creating a temporary table.
    Here is the sql:
    CREATE TYPE TT_CONF AS TABLE(ID INTEGER, NAME VARCHAR(32))
    CREATE LOCAL TEMPORARY COLUMN TABLE #CONF LIKE TT_CONF;
    And then got the error message like below:
    Could not execute 'CREATE LOCAL TEMPORARY COLUMN TABLE #CONF LIKE TT_CONF' in 220 ms 419 µs .
    SAP DBTech JDBC: [598]: failed to execute the external statement: InvalidHostNameException at Communication.cpp(01174):
      message: the hostname could not be resolved
      info:    host unknown
      param:  
    Is this a new constraints or just a bug? Does anybody have this issue?

    Hi, queena
    I also encounter the same problem in XS service. Now we import '/sap/hana/xs/libs/dbutils/procedures.xsjslib' into our project. But it will throw errors when one of the procedure's parameters is a temporary table.
    Then we debug it, then we find errors come from following statement : connection.prepareStatement('CREATE LOCAL TEMPORARY COLUMN TABLE "' + localschema + '"."' + localtemp + '" LIKE "' + schema_name + '"."' + table_name + '"').execute();
    So we try to delete COLUMN in the lib, then everything seems okay.

  • Help Creating Dynamic Stacked Column Chart with Multiple Criteria

    Hi all. Im new here and hoping you can help.  I have a dashboard Im trying to rebuild from scratch (our computer had a meltdown and we lost all our files). I did not build the dashboard initially so Im trying to recreate it from the flash file we were able to recover. I have come across a chart that I just cannot figure out how to do.  I can figure out how to write an array in the Excel sheet that pulls the data into a table the way I need it to be but found out after I wrote that that Xcelcius doesn't support arrays so all my data disappears when I go into preview mode (which is especially frustrating since I can see the chart working fine in design mode).  Anyway this is what the data table looks like
    Month         Year            Company      Positive #          Negative #         Neutral #          Positive %       Negative %      Neutral %
    October      2011            CompanyA      1234                1234                 1234                 10                    10                    10
    October      2011            CompanyB      1234                1234                 1234                 10                    10                    10
    October      2011            CompanyC      1234                1234                 1234                 10                    10                    10
    October      2011            CompanyD      1234                1234                 1234                 10                    10                    10
    November  2011            CompanyA      1234                1234                 1234                 10                    10                    10
    November  2011            CompanyB      1234                1234                 1234                 10                    10                    10
    November  2011            CompanyC      1234                1234                 1234                 10                    10                    10
    November  2011            CompanyD      1234                1234                 1234                 10                    10                    10
    December  2011            CompanyA      1234                1234                 1234                 10                    10                    10
    December  2011            CompanyB      1234                1234                 1234                 10                    10                    10
    December  2011            CompanyC      1234                1234                 1234                 10                    10                    10
    December  2011            CompanyD      1234                1234                 1234                 10                    10                    10
    The original chart was built so that you would choose the month from a combo box and then the company names would show up along the X axis with their % amounts shown in the stacked column.  I know how to make a combo box work and I know how to make a stacked column chart work with static data.  I cannot for the life of me figure out how to get it to work so that when you choose the month from the combo box it filters the data.  I've tried filtered rows but I'm just missing some information that makes it work and I can't figure out what that information is.  It has to be able to get the month/year combo from the combo box and then go to the table, filter it by month and year and then create a multi-row table of data with just the company and the percent values.  Any help would be greatly appreciated!

    Which connection you are using?
    IF quite difficult if you are working under static data.

  • Want to create dynamic SQL with table join

    I want to create a dynamic SQL query so that the user can enter any two table names on the selection screen and two field names that he wants to join. After which i should be able to dynamically generate the SQL (native or open) and show the result as report. I have already read the forum threads and know how to create dynamic SQL for single table, what i m struggling with is how to do inner join. I know i can use nested select but that will make the query very slow because i want to extend it to more than 2 tables later.
    Will give points to useful answer for sure, thanks for reading.

    Hi,
    Following is a piece of code which I have used in my program.
    DATA: ws_flds(72)   TYPE c.
    DATA: ftab  LIKE TABLE OF ws_flds.
    ws_flds = 'rbukrs rprctr racct ryear '.
      APPEND ws_flds TO ftab.
       SELECT (ftab)
        INTO CORRESPONDING FIELDS OF TABLE it_grp_glpca
        FROM glpca FOR ALL ENTRIES IN i_cert_item
        WHERE kokrs = c_kokrs
            AND rldnr = '8A'
            AND rrcty IN ('0','2')
            AND rvers  = '000'
            AND rbukrs = i_cert_item-bukrs
            AND ryear  = p_ryear
            AND rprctr = i_cert_item-prctr
            AND racct  = i_cert_item-saknr
            AND ( poper BETWEEN '001' AND ws_poper )
            AND aufnr IN s_aufnr
            AND kostl IN s_kostl
            AND rfarea IN s_fkber
            AND rmvct IN s_rmvct
            AND sprctr IN s_sprctr
            AND ( racct BETWEEN c_low AND c_high ).
    You can now pass your table name as (p_table) or append fieldnames to the internal table (ftab). if it is join then you can append this table like abukrs asaknr..etc.
    Regards
    Subramanian

  • How to Create Dynamic form using table data

    Dear All,
    I have one Table called PRODUCT_MASTER where product details are stored. Say product A,B,C,D are stored in the table. Another table called SUB_PRODUCT_MASTER, which contains sub product details.Say A1,A1,B1,B2, B3,C1, C2, C3, D1,D2,D3.
    Now, I want to create a dynamic form based on product,sub product. for a whole month. For better under standing here is the format.
    PRODUCT A B C D
    SUB_PROD A1 A2 B1 B2 B3 C1 C2 C3 D1 D2 D3
    Days
    1 x x x x x x x x
    2
    3
    4
    5
    6
    7
    Now whenever I add one row in the PRODUCT)MASTER table and SUB_PRODUCT_MASTER table, Form should add one column in the form automatically. e.g. If I add Product E with two Sub product E1 and E2 then form should add ptoduct E column in the form with sub products E1 and E2 as per above format. Here days are fixed to 31. This forms should accept product wise daily despatch entry. For
    storing despatch entry another table is created.
    Please help to create this type od forms.

    You want I believe to create Croos-Table(Matrix) form. Visit Cross-table (matrix) forms layout and add "Please Send me too".

  • Creating Dynamic Applet-Columns

    Hi
    I need to get data from a web-service in the form of stock-quotes and their prices.Once a user(e.g. having 5 stock-quotes)logs-in, the servlets calls the web-service and gets the values. Now these values need to be published to a Java-applet.
    I have already achieved it technically using a GridBagLayout, but the format of the layout, in which the names and values of these scrips are published to the applet, doesn't stay same and once the applet gets refreshed, the layout gets disturbed.
    Like for example, if the layout consisted of 5 rows and 2 columns when the applet was initialized, it comes as 10 columns and only a single row once it gets refreshed.
    I am pasting the contents of the code with this post. Plz have a look:
    * This code belongs to Covansys India Pvt Ltd., Bangalore, INDIA
    * @author : EAI Team, Covansys India Pvt Ltd.
    * Copyright Ravish Narula <[email protected]>
    * Date:06/21/2005
    import java.awt.*;
    import java.applet.*;
    import java.util.Date;
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    public class StockTickerApplet30 extends Applet {
    Thread t = null;
    int delay = 5000;
    int tCount = 0;
    URLConnection servletConnection;
    Hashtable stockHashtable = null;
    Hashtable oldStockValues = new Hashtable();
    protected void makeLabel(String name, GridBagLayout gridbag, GridBagConstraints c) {
    Label label = new Label(name);
    gridbag.setConstraints(label, c);
    add(label);
    protected void makeTextField(String value, GridBagLayout gridbag, GridBagConstraints c, char color) {
    Label textField = new Label(value);
    if (color == 'g')
    textField.setBackground(Color.green);
    else if (color == 'r')
    textField.setBackground(Color.red);
    else
    textField.setBackground(Color.gray);
    gridbag.setConstraints(textField, c);
    add(textField);
    public void init() {
    public void paint(Graphics g) {
    try {
    String location = "http://localhost:7001/etrade/StockQuoteServlet";
    URL testServlet = new URL(location);
    servletConnection = testServlet.openConnection();
    // Don't used a cached version of URL connection.
    servletConnection.setUseCaches(false);
    servletConnection.setDefaultUseCaches(false);
    servletConnection.setDoOutput(true); // to allow us to write to the URL
    //super.init();
    //g.drawString("111111 Applet: before out.close() 111111",10,10 );
    //Write the message to the servlet
    PrintStream out = new PrintStream(servletConnection.getOutputStream());
    out.close();
    // Read the input from the servlet.
    // The servlet will return a serialized vector containing the details.
    //inputStreamFromServlet = servletConnection.getInputStream();
    //setSize(getPreferredSize());
    //System.out.println(" Applet: before GetInputStream()" );
    ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
    //System.out.println(" Applet: before readObject()" );
    stockHashtable = (Hashtable) inputFromServlet.readObject();
    System.out.println("The Hashtable received from Servlet is ::" + stockHashtable);
    } catch (java.net.MalformedURLException me) {
    //System.out.println("The Exeeption message is ::"+me);
    } catch (java.io.IOException ioe) {
    //System.out.println("The Exeeption message is ::"+ioe);
    } catch (Exception e) {
    //System.out.println("The Exeeption message is ::"+e);
    // Generate UI and populate Data
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    Panel p = new Panel();
    setFont(new Font("Helvetica", Font.PLAIN, 14));
    // setLayout(new GridBagLayout());
    setBackground(Color.gray);
    c.fill = GridBagConstraints.BOTH;
    //c.fill = GridBagConstraints.VERTICAL;
    // c.gridwidth=2;
    // c.gridheight=stockHashtable.size();
    int y = 0;
    Enumeration e = stockHashtable.keys();
    while (e.hasMoreElements()) {
    String sName = (String) e.nextElement();
    Double sValue = (Double) stockHashtable.get(sName);
    //For next iteration comparision
    oldStockValues.put(sName, sValue);
    char color = 'w';
    Double sOldValue = (Double) oldStockValues.get(sName);
    int iComparision = sValue.compareTo(sOldValue);
    if (iComparision > 0)
    color = 'g';
    else if (iComparision < 0)
    color = 'r';
    else
    color = 'w';
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = y;
    //c.weightx = 1.0;
    //c.gridwidth = GridBagConstraints.RELATIVE;
    makeLabel(sName, gridbag, c);
    c.weightx = 0.5;
    //c.weighty=100;
    c.gridx = 1;
    c.gridy = y;
    c.gridwidth = GridBagConstraints.REMAINDER;
    makeTextField(sValue.toString(), gridbag, c, color);
    y++;
    //tCount++;
    //g.drawString("@@@@@@@@@@ Count of tCount is: @@@@@@@@@ "+ y ,10,10);
    //setSize(getPreferredSize());
    y = 0;
    setLayout(gridbag);
    y = 0;
    //setLayout(new GridBagLayout());
    validate();
    //show();
    try {
    Thread t = Thread.currentThread();
    t.sleep(5000);
    y = 0;
    repaint();
    y = 0;
    } catch (InterruptedException ie) {
    *************************************************

    sounds like this to me
    DECLARE @ColumnList varchar(5000)
    IF OBJECT_ID('PivotValues') IS NOT NULL
    DROP TABLE PivotValues
    SET @ColumnList = STUFF((SELECT DISTINCT ',[' + MemberValue + ']'
    FROM Reporting.dbo.[MSPLT_ACNT Budget Type UserView]
    FOR XML PATH('')),1,1,'')
    DECLARE @Sql = 'SELECT LookupMemberUID,' + @ColumnList
    + 'INTO PivotValues FROM Reporting.dbo.[MSPLT_ACNT Budget Type UserView] t
    PIVOT (MAX(MemberDescription) FOR MemberValue IN (' + @ColumnList + '))p'
    EXEC(@SQL)
    SELECT *
    FROM (YourExistingQUery)q
    INNER JOIN PivotValues p
    ON p.LookupMemberUID = q.RelatedCol
    You need to replace RelatedCol with actual column that has UID values (its not clear from your explanation above whether its TaskUID or ProjectUID or another column)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • In FR, how to create dynamical reference column

    In FR, can we do something like below:
    I have scenarios in the column header; while in column 1, scenario is selected from the current point of view, for example when I select Budget, I would like in column 2 to be the Actual; If I select Forecast in column 1, and I would like Budget in column 2, etc.
    Any suggestion/advise is welcome.
    Thanks

    Thanks for the reply.
    However, I was not able to find the conditional suppression based on the other column's member name (can only suppress based on its own column member name, data cell, or data cell values, etc).
    Also my requirements is a bit complicated. I also have year as my column header. I have year 2007 to 2009, and scenarios: actual, budget, F1, F2, F3.
    If I choose 2009 for example, Budget, I would like the 2nd column to be 2008 F3; If I choose 2008 F1, I would like the 2nd column to be 2008 Budget; if I choose 2008 F2, I would like the 2nd column to be 2008 F1, and so on.
    Any suggestions/advices ?

  • How to create the Dynamic UI element table in web dynpro in abap

    Hi All,
    Does anybody have reference note or teach me how to create dynamic UI element table in web dynpro in abap ?
    Regards,
    Luke

    HI LukeWong ,
    for creating any UI dynamically you shoul use their runtime class that always start with cl_wd_* ui element name*
    so for the Table UI element the runtime class is CL_WD_TABLE
    now reffer the below code for creating the Table UI dynamically
    METHOD wddomodifyview.
    DATA lr_table TYPE REF TO cl_wd_table.
    DATA lr_flow_data TYPE REF TO cl_wd_flow_data.
    DATA lr_container TYPE REF TO cl_wd_uielement_container.
    DATA lr_column_name TYPE REF TO cl_wd_table_column.
    DATA lr_text_view TYPE REF TO cl_wd_text_view.
    DATA lr_table_header TYPE REF TO cl_wd_caption.
    DATA lr_column_name_header TYPE REF TO cl_wd_caption.
    IF first_time EQ abap_true.
    lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
    lr_table = cl_wd_table=>new_table(
    id = 'TBL_TABLE'
    bind_data_source = 'TABLE'
    design = cl_wd_table=>e_design-alternating
    visible_row_count = 3
    lr_flow_data = cl_wd_flow_data=>new_flow_data( element =
    lr_table ).
    lr_container->add_child( lr_table ).
    lr_column_name = cl_wd_table_column=>new_table_column(
    id = 'TBL_EXAMPLE_NAME'
    lr_table_header ?= cl_wd_caption=>new_caption( text = 'Table UI elem
    ent - example').
    lr_table->add_column( the_column = lr_column_name ).
    lr_table->set_header( lr_table_header ).
    lr_text_view = cl_wd_text_view=>new_text_view(
    id = 'TXV_NAME'
    bind_text = 'TABLE.NAME'
    lr_column_name_header ?= cl_wd_caption=>new_caption( text = 'Name').
    lr_column_name->set_table_cell_editor( the_table_cell_editor = lr_text_view).
    lr_column_name->set_header( lr_column_name_header ).
    ENDIF.
    ENDMETHOD.
    Regards
    Chinnaiya P
    Edited by: chinnaiya pandiyan on Sep 17, 2010 12:01 PM

  • Repeat to create multi-column table

    I'm trying to use a spry:repeat directive to create a
    two-column table. What I would like to have generated as a result
    of the repeat is something like the following:
    <table>
    <tr>
    <td>row[0] data</td>
    <td>row[1] data</td>
    <tr>
    <tr>
    <td>row[2] data</td>
    <td>row[3] data</td>
    <tr>
    </table>
    Using the spry:test directive it's easy to get only the even
    rows in the first TD element, but I can't figure out how to
    reference the data element for the second TD in each table row.
    Here's what my HTML looks like:
    <div id="thumbContainer" spry:region="dsPhotos">
    <table border="0" cellpadding="0" cellspacing="0">
    <tr align="center" valign="middle" spry:repeat="dsPhotos"
    spry:test="loadThumb({ds_RowNumber}, {ds_RowCount})">
    <td width="85" height="85"><img
    src="thumbnails/{filename}" /></td>
    <td width="85" height="85"><img
    src="thumbnails/{filename}" /></td>
    </tr>
    </table>
    </div>
    The loadThumb function returns true for every other row. That
    works correctly and I see the even-numbered items in the two
    columns of each row. I've tried replacing the contents of the
    second img src attribute with every imaginable combination of
    dsPhotos.getData() and I can't find the magic combo that gets me
    the filename of the *next* row. I did try different usages of the
    ds_RowNumberPlus1 data reference but wasn't able to get that to
    work either. I verified that if I create two separate tables and
    use floating div's to get them to appear side-by-side and use
    separate spry:test functions to get the even and odd rows, I can
    iterate the data set twice and get the right contents in each
    table, but I would like to be able to solve this with a single
    table and a single iteration of the data set. Can anyone shed some
    light on how I should reference the n+1th row in my HTML table
    definition above?
    Thanks,
    Steve

    XE provides the browser-based interface for 'convenience'. You could always switch to SQLPlus or use the SQL Window and enter it manually. You could do this after the table has been created by using a documented syntax such as this sample
    ALTER TABLE sales
    ADD CONSTRAINT sales_pk PRIMARY KEY (prod_id, cust_id) DISABLE;
    found at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/clauses002.htm#i1002629
    The referenced doc also shows how to create the constraint at the same time as the table.

  • Creating dynamic internal table(Not field symbol table)

    Hi Experts,
    I am facing problem creating Intarnal table
    I have fieldcatalog, I want create dynamic internal table(Not field symbol table).
    I have written----
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
       i_style_table             =
         it_fieldcatalog           = it_fldcat
          it_fieldcatalog           = me->gt_fieldcat
       i_length_in_byte          =
        IMPORTING
          ep_table                  = lt_new_table
       e_style_fname             =
        EXCEPTIONS
         generate_subpool_dir_full = 1
         OTHERS                    = 2.
        ASSIGN lt_new_table->* TO <gt_dyn_repdata>.
        CREATE DATA ls_new_line LIKE LINE OF <gt_dyn_repdata>.
        ASSIGN ls_new_line->* TO <gs_dyn_repdata>.
    above logic creating dynamic field symbol table.... But I want create normal internal table.
    Thanks,
    Rajasekhar

    Hi
    What do you mean?
    It needs to use the field-symbol, this is the price to pay if it wants a dynamic object
    Max

  • Nested Loops...looping through one month of data at a time year by year

    Hi all,
    I'm trying to create an insert statement that loops through a table that has 10 years of data (2001 to 2010) month by month to minimize impact on server and commits more frequently to avoid filling up the redo logs and rollback tablespaces. The table is large, has about 40 millions records per year. Lets say the structure of the table is the following:
    Customer_ID number(9),
    Order_Item_1 number(6),
    Order_Item_2 number(6),
    Order_Item_3 number(6),
    Order_date date
    The table is in flat format but I want to normalize it so that it looks like the following:
    Customer_ID Order_Seq Order_Item Order_date
    999999999 1 555555 01-jan-2001
    999999999 2 666666 01-jan-2001
    999999999 3 444444 01-jan-2001
    888888888 1 555555 03-jan-2001
    888888888 2 666666 03-jan-2001
    But because I want to loop through month by month....I need to set it up so that it loops through month by month, year by year (Using the Order Date Field) and Order_item by Order_item. Something like:
    so my insert statements would be something like if I hardcoded instead of put the insert statement into a loop:
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,1,Order_item,Order_date where Order_item_1 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='01';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,2,Order_item,Order_date where Order_item_2 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='01';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,3,Order_item,Order_date where Order_item_3 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='01';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,1,Order_item,Order_date where Order_item_1 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='02';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,2,Order_item,Order_date where Order_item_2 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='02';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,3,Order_item,Order_date where Order_item_3 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='03';
    Hope this makes sense.
    Thanks

    Does the sequence of items in an order really matter? In other words, do we really need to preserve that an item was in position 2 versus position 1? I bet that the sequence or position of each item in an order is not meaningful. They were probably numbered 1, 2, and 3 just to make them uniquely named columns so there would be three slots to hold up to 3 items in the denormalized table.
    You only have about 400 million rows to insert, so it could feasibly be done in a single transaction (depending on your database environment).
    You can always do a create table as select (CTAS) to help with undo / redo issues and get better performance. You could run it in parallel, and spit it out to a new table partitioned by month. Single DDL statement running in parallel making your new table--sounds good to me.
    How about something like this:
    CREATE TABLE ORDERS_NORMALIZED
    (CUSTOMER_ID, ORDER_ITEM, ORDER_DATE)
    PARTITION BY RANGE(ORDER_DATE)
    PARTITION p200901 VALUES LESS THAN (TO_DATE('200902','YYYYMM')),
    PARTITION p200902 VALUES LESS THAN (TO_DATE('200903','YYYYMM')),
    PARTITION p201012 VALUES LESS THAN (TO_DATE('201101','YYYYMM'))
    as SELECT CUSTOMER_ID, ORDER_ITEM_1, ORDER_DATE
       FROM OTHER_TABLE
       WHERE ORDER_ITEM_1 IS NOT NULL
       UNION ALL
       SELECT CUSTOMER_ID, ORDER_ITEM_2, ORDER_DATE
       FROM OTHER_TABLE
       WHERE ORDER_ITEM_2 IS NOT NULL
       UNION ALL
       SELECT CUSTOMER_ID, ORDER_ITEM_3, ORDER_DATE
       FROM OTHER_TABLE
       WHERE ORDER_ITEM_3 IS NOT NULL.....................
    Out of curiosity, why not normalize it further? You could have used two tables instead of one.
    One (ORDER) with:
    ORDER_ID
    CUSTOMER_ID
    DATE
    Order_id would be a new surrogate key / primary key.
    Another table (ORDER_ITEM) with:
    ORDER_ID
    ORDER_ITEM
    It would be a table that links ORDERS to ITEMS. You get the idea.

  • Dynamic headers in table control

    Hi,
    How to create dynamic headers in table control headers?
    I have to replace the header labels with internally computed headers.
    I have created input fields for headers..
    Regards,
    Krutika

    Hi Krutika,
    Try this out,
    Populate an internal tabel with all the dates and day in it and also populate the column position  in it.
    say you have populated all this in an internal table it_date----fields in the internal table
    1. date
    2. day
    3. spot1 -
    column name of the table control(spot1 represents the column position)
    then do this ,
    LOOP AT it_date INTO wa_date.
       LOOP AT SCREEN .
    *WHERE screen-name = wa_date-spot.
        CASE wa_date-spot.
          WHEN 'SPOTS1'.
            spots1 = wa_date-dd.
          WHEN 'SPOTS2'.
            spots2 = wa_date-dd.
          WHEN 'SPOTS3'.
            spots3 = wa_date-dd.
          WHEN 'SPOTS4'.
            spots4 = wa_date-dd.
          WHEN 'SPOTS5'.
            spots5 = wa_date-dd.
          WHEN 'SPOTS6'.
            spots6 = wa_date-dd.
          WHEN 'SPOTS7'.
            spots7 = wa_date-dd.
          WHEN 'SPOTS8'.
            spots8 = wa_date-dd.
          WHEN 'SPOTS9'.
            spots9 = wa_date-dd.
          WHEN 'SPOTS10'.
            spots10 = wa_date-dd.
          WHEN 'SPOTS11'.
            spots11 = wa_date-dd.
          WHEN 'SPOTS12'.
            spots12 = wa_date-dd.
          WHEN 'SPOTS13'.
            spots13 = wa_date-dd.
          WHEN 'SPOTS14'.
            spots14 = wa_date-dd.
          WHEN 'SPOTS15'.
            spots15 = wa_date-dd.
          WHEN 'SPOTS16'.
            spots16 = wa_date-dd.
          WHEN 'SPOTS17'.
            spots17 = wa_date-dd.
          WHEN 'SPOTS18'.
            spots18 = wa_date-dd.
          WHEN 'SPOTS19'.
            spots19 = wa_date-dd.
          WHEN 'SPOTS20'.
            spots20 = wa_date-dd.
          WHEN 'SPOTS21'.
            spots21 = wa_date-dd.
          WHEN 'SPOTS22'.
            spots22 = wa_date-dd.
          WHEN 'SPOTS23'.
            spots23 = wa_date-dd.
          WHEN 'SPOTS24'.
            spots24 = wa_date-dd.
          WHEN 'SPOTS25'.
            spots25 = wa_date-dd.
          WHEN 'SPOTS26'.
            spots26 = wa_date-dd.
          WHEN 'SPOTS27'.
            spots27 = wa_date-dd.
          WHEN 'SPOTS28'.
            spots28 = wa_date-dd.
          WHEN 'SPOTS29'.
            spots29 = wa_date-dd.
          WHEN 'SPOTS30'.
            spots30 = wa_date-dd.
          WHEN 'SPOTS31'.
            spots31 = wa_date-dd.
        ENDCASE.
    Hope this helps you,
    Regards,
    Abhijit G. Borkar

  • Looping through arrays

    Hello,
    I am developing a program which contains redundant code as it contains too many methods that loop through the same two dimensional array all the time.
    The reason why the code is redundant is because I need to perform a different action to different values in the array each time (depending on whether statement is true or false).
    What I want to try and do is create one single method which loops through the array and returns a boolean value.
    The method needs to take something like an if statement as a parameter so that I can stop searching through the array when the value of some element in array satisfies the if statement.
    How do I do this? How do I cut down the amount of code that searches through the same array all the time.
    Hope someone can understand
    Thanks

    Are you looking to do something like this?
    interface Predicate {
        boolean apply(int arg);
    class IsEven implements Predicate {
        public boolean apply(int arg) {
            return arg % 2 == 0;
    public class PredicateExample {
        public boolean searchMaxtrix(int[][] m, Predicate p) {
            for (int[] row : m)
                for(int x : row)
                    if (p.apply(x))
                        return true;
            return false;
    }

  • Create dynamic checkBox

    Is it possible to create dynamic checkBox inside the loop? I am planning to generate a set of checkBox and then adding them into panels. Is it possible to do it? I have to generate checkBox dynamically.
    Thx.

    I tried as below. Is it right?
    private void createCheckBoxes(List javaFiles) {
            int count = javaFiles.size();
            System.out.println("The number of .tna files are"+count);
            for(int i=0; i<=count-1; i++){
                 System.out.println("Creating checkBoxes");
                 //Create checkbox
                  JCheckBox  box = new JCheckBox("region"+i);
                  box.setName("region"+i);
                dynamicPanel.add(box);
                dynamicPanel.validate();
        }I have few doubts.
    Initially I tried as below:
    JCheckBox  box = new JCheckBox();
    box.setName("region"+i);It created the check boxes dynamically but the name was not printed. Why is that so?
    Now my first set of code works. But how do I refer to these dynamic components?
    Thx.

Maybe you are looking for

  • Getting FRM-40400 but data is not in table

    I have a form with three data blocks. The first one is Database Data Block = no because it is used for query purposes only. The second one is Database Data Block = yes and is the only data block in which data gets entered into a table. The final data

  • Problem in setHeader method

    i am using the following servlet code to invoke download dialog.how can i get response of the user from the dialog window.(i.e the user pressed the OK or CANCEL button in the dialog by the user) response.setContentType("application/x-filler"); respon

  • I tunes lock up

    when i connect my iphone to my pc it locks up my itunes!!!!! any ideas thanks

  • Problem in testing (deployin)BSP

    Hi all Im  new to BSP when i tried to build sample bsp application  and deploy it has been showing some 500 error . It showing some error like this Please help me . Thanks&regards Prasad Error when processing your request What has happened? The URL h

  • 10.5.2 update seems to have removed all TM backups prior to today?

    After updating to 10.5.2, I see that my Time Machine drive - which prior to the update had backups dating back to whenever I installed Leopard (November I think) - now only contains backups it made today. Anyone else seen this?