How to add a new column to a existing table?

Hi all,
I have requriment acc which i need toadd a new column to a exsiting table.the name of the columns is taken frm database.I.e.,
say if i have 3 names in DB name1,name2,name3
i need to add in the table these three names as columns and tat to as inputfield(tablecelleditor) .Please help me with the code, i'll give full points to everyone who gives me correct answer 
Regards
Sharan and please this is Really Urgent!!! plzzzzzzzzzz
Edited by: Armin Reichert on Dec 30, 2007 7:47 PM

Hi,
You can add the following lines of code where-ever  you want to add the table:
    IWDTransparentContainer tr = (IWDTransparentContainer) viewObj.getElement("trans");  // Container where table will be added 
     IWDTable tab = (IWDTable) viewObj.createElement(IWDTable.class ,"Table ID");
     tr.addChild(tab);
     IWDNodeInfo nodeInfo = wdContext.nodeProducts().getNodeInfo();
     tab.bindDataSource(nodeInfo); // datasource of your table.
     // First Column
     IWDTableColumn tc1 = (IWDTableColumn) viewObj.createElement(IWDTableColumn.class, "TC1");
     IWDCaption cap1 = (IWDCaption) viewObj.createElement(IWDCaption.class,"cap1");
     cap1.setText("Column Heading 1"); // name1 of your column
     tc1.setHeader(cap1);
     IWDInputField inp1 = (IWDInputField) viewObj.createElement(IWDInputField.class,"INP1");
     tc1.setTableCellEditor(inp1);
     IWDAttributeInfo attrInfo1 = wdContext.nodeProducts().getNodeInfo().getAttribute(IPrivateTEST.IProductsElement.PRODUCT_ID);
     inp1.bindValue(attrInfo1);
     tab.addColumn(tc1);
     // Second Column
     IWDTableColumn tc2 = (IWDTableColumn) viewObj.createElement(IWDTableColumn.class, "TC2");
     IWDCaption cap2 = (IWDCaption) viewObj.createElement(IWDCaption.class,"cap2");
     cap2.setText("Column Heading 2");
     tc2.setHeader(cap2);
     IWDInputField inp2 = (IWDInputField) viewObj.createElement(IWDInputField.class,"INP2");
     tc2.setTableCellEditor(inp2);
     IWDAttributeInfo attrInfo2 = wdContext.nodeProducts().getNodeInfo().getAttribute(IPrivateTEST.IProductsElement.NAME);
     inp2.bindValue(attrInfo2);
     tab.addColumn(tc2);
     // Third Column
     IWDTableColumn tc3 = (IWDTableColumn) viewObj.createElement(IWDTableColumn.class, "TC3");
     IWDCaption cap3 = (IWDCaption) viewObj.createElement(IWDCaption.class,"cap3");
     cap3.setText("Column Heading 3");
     tc3.setHeader(cap3);
     IWDInputField inp3 = (IWDInputField) viewObj.createElement(IWDInputField.class,"INP3");
     tc3.setTableCellEditor(inp3);
     IWDAttributeInfo attrInfo3 = wdContext.nodeProducts().getNodeInfo().getAttribute(IPrivateTEST.IProductsElement.DETAILS);
     inp3.bindValue(attrInfo3);
     tab.addColumn(tc3);
For any further doubts you can always come back to me.
thanks & regards,
Manoj

Similar Messages

  • How to add a new column to a existing table and add data to this column?

    I have a table with about 10 millions row and I want to add a new column to this table, then fill this new column with prepared data.
    How to do it ?
    Thank you

    Can I use insert statement to add the data to new-added column?No.
    07:19:37 oracle >create table test (x number);
    Table created.
    Elapsed: 00:00:03.05
    07:19:53 oracle >
    07:19:53 oracle >
    07:19:53 oracle >insert into test values (1);
    1 row created.
    Elapsed: 00:00:00.00
    07:20:01 oracle >insert into test values (2);
    1 row created.
    Elapsed: 00:00:00.00
    07:20:10 oracle >insert into test values (3);
    1 row created.
    Elapsed: 00:00:00.00
    07:20:12 oracle >
    07:20:13 oracle >commit;
    Commit complete.
    Elapsed: 00:00:00.00
    07:20:14 oracle >
    07:20:19 oracle >select * from test;
             X
             1
             2
             3
    Elapsed: 00:00:00.00
    07:20:22 oracle >
    07:20:36 oracle >alter table test add (y number);
    Table altered.
    Elapsed: 00:00:00.05
    07:20:41 oracle >
    07:20:41 oracle >
    07:20:41 oracle >
    07:20:41 oracle >select * from test;
             X          Y
             1
             2
             3
    Elapsed: 00:00:00.00
    07:20:43 oracle >
    07:20:44 oracle >
    07:20:44 oracle >update test set y=1;
    3 rows updated.
    Elapsed: 00:00:00.02
    07:20:52 oracle >commit;
    Commit complete.
    Elapsed: 00:00:00.00
    07:20:56 oracle >select * from test;
             X          Y
             1          1
             2          1
             3          1
    Elapsed: 00:00:00.00
    07:20:58 oracle >Anand

  • Need to add 2 new columns to the existing table control of C223 transaction

    Hi ABAP Gurus,
    I have to do a screen enhancement for transaction C223.
    Below is the requirement:
    need to add 2 new columns to the existing table control of C223 transaction.
    there is no customer exits, screen exit or user exit present for this transaction C223, i have found one enhancement spot for this transaction.
    i dont have any idea how to do this in standard transaction C223, the table control in C223 saves the data to MKAL table and the table control uses the structure MKAL_EXPAND in the screen program.
    i have created an append structure for  the 2 fields to the standard table MKAL.
    Can anyone please suggest me how this can be done in standard screen C223, will the enhancement spot can be used to do this....
    please sugest...
    Thanks & Regards

    Hi Santosh,
    Thanks for the reply. I have looked into this Enhancement Spot CPFX_SCREEN_SET , inside this there is only one method INPUT_DISABLED having below parameters
    IM_MKAL     Importing     Type     MKAL                                                                                Production Version
    EX_MSGID     Exporting     Type     SY-MSGID                                                                                Messages, Message
    EX_MSGTY     Exporting     Type     SY-MSGTY                                                                                Messages, Message
    EX_MSGNO     Exporting     Type     SY-MSGNO                                                                                Messages, Message
    EX_MSGV1     Exporting     Type     SY-MSGV1                                                                                Messages, Message
    EX_MSGV2     Exporting     Type     SY-MSGV2                                                                                Messages, Message
    EX_MSGV3     Exporting     Type     SY-MSGV3                                                                                Messages, Message
    EX_MSGV4     Exporting     Type     SY-MSGV4                                                                                Messages, Message
    EX_INPUT_DISABLE     Exporting     Type     CHAR1                                                                                Display Only if X Was Set
    the BADI definition present here is a SAP internal so we cant implement the BADI , but we can created a enhancement spot implementation for this. as per my understanding on this the enhancement spot is only for making the table control fields display / change .  i dont think this can be used to add two new coloumns to C223 table control.
    I am not sure thats why seeking your help/valuable sugestion on this.
    Please provide your sugestion on this , so that i can come to conclusion on this issue.
    Thanks & Regards
    Siddhartha Mishra

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • How to add an unique column to an existing table?

    How to add an unique column to an existing table?
    I have a large table which has no unique constraint. and I want to add an unique column for it. How to do it?
    Does adding a sequence is a good choice? How to do it?
    Thank you

    Hi,
    alter table tablename
    add constraint contraint_name unique (columnname);but before that you need to check in the table.column there is no duplicate record exist.
    Does adding a sequence is a good choice?
    Your talking about unique constraint then yes.
    Regards,
    Taj

  • How to add a new column (Project Number) in the action items table under NPD Module?

    There are two projects with same name and created by same person in NPD.
    So when it is displayed in "Action Items" table, It looks similar.
    To avoid this, I need one more column (Project Number) to be added in the "Action Items" table and " Strategic briefs and projects" table.
    So, How to add a new column (Project Number) in the "Action Items" table and " Strategic briefs and projects" table under NPD Module?
    Please do the needful.

    There is no out of the box configuration available to add columns to NPD action items.   As always we welcome enhancement requests. 
    Thanks
    Kelly

  • How can I add a new column in compress partition table.

    I have a compress partition table when I add a new column in that table it give me an error "ORA-22856: CANNOT ADD COLUMNS TO OBJECT TABLES". I had cretaed a table in this clause. How can I add a new column in compress partition table.
    CREATE TABLE Employee
    Empno Number,
    Tr_Date Date
    COMPRESS PARTITION BY RANGE (Tr_Date)
    PARTITION FIRST Values LESS THAN (To_Date('01-JUL-2006','DD-MON-YYYY')),
    PARTITION JUNK Values LESS THAN (MAXVALUE));
    Note :
    When I create table with this clause it will allow me to add a column.
    CREATE TABLE Employee
    Empno Number,
    Tr_Date Date
    PARTITION BY RANGE (Tr_Date)
    PARTITION FIRST Values LESS THAN (To_Date('01-JUL-2006','DD-MON-YYYY')),
    PARTITION JUNK Values LESS THAN (MAXVALUE));
    But for this I have to drop and recreate the table and I dont want this becaue my table is in online state i cannot take a risk. Please give me best solution.

    Hi Fahed,
    I guess, you are using Oracle 9i Database Release 9.2.0.2 and the Table which you need to alter is in OLTP environment where data is usually inserted using regular inserts. As a result, these tables generally do not get much benefit from using table compression. Table compression works best on read-only tables that are loaded once but read many times. Tables used in data warehousing applications, for example, are great candidates for table compression.
    Reference : http://www.oracle.com/technology/oramag/oracle/04-mar/o24tech_data.html
    Topic : When to Use Table Compression
    Bug
    Reference : http://dba.ipbhost.com/lofiversion/index.php/t147.html
    BUG:<2421054>
    Affects: RDBMS (9-A0)
    NB: FIXED
    Abstract: ENH: Allow ALTER TABLE to ADD/DROP columns for tables using COMPRESS feature
    Details:
    This is an enhancement to allow "ALTER TABLE" to ADD/DROP
    columns for tables using the COMPRESS feature.
    In 9i errors are reported for ADD/DROP but the text may
    be misleading:
    eg:
    ADD column fails with "ORA-22856: cannot add columns to object tables"
    DROP column fails with "ORA-12996: cannot drop system-generated virtual column"
    Note that a table which was previously marked as compress which has
    now been altered to NOCOMPRESS also signals such errors as the
    underlying table could still contain COMPRESS format datablocks.
    As of 10i ADD/SET UNUSED is allowed provided the ADD has no default value.
    Best Regards,
    Muhammad Waseem Haroon
    [email protected]

  • How can I add a new column to an Attachments Table

    How can I add a new column to an Attachments Table??
    And I want to remove the usage column also!
    Thanks!

    I tried to remove the usage column doing this:
    OAAttachmentTableBean attachTable = (OAAttachmentTableBean)webBean.findChildRecursive("attachTable");
    if (attachTable != null)
    attachTable.findChildRecursive("UsageTypeColumn").setRendered(false);
    but I'm getting null pointer exception on "UsageTypeColumn"...
    :(

  • How to add a new column to specific position

    Hi,
    How to add a new column to specified position in a existing table.
    I have using the oracle database 10g.
    This below code is not working in oracle 10 g
    example:
    ALTER TABLE EMPLOYEE ADD DEPT NUMBER FIRST:
    ALTER TABLE EMPLOYEE ADD DEPT NUMBER AFTER JOB:
    Please provide the correct syntax.

    Hi,
    When you add a column to the existing table, the column added i.e., for ex updatedon appers in the last. If you want the columns to be
    displayed in Specific order. Just give the column names in the SELECT.. statement.
    For your Information, But it is not good in Table design. Just to give something useful.
    If you want to add a column at a specified position,
    Rename the position column to the new column name
    For Ex: (OLD_COLUMN_NAME-Hiredate)
    ALTER TABLE EMP RENAME COLUMN OLD_COLUMN_NAME TO TEMP_HIREDATE;Add a New Column to Table
    ALTER TABLE EMP ADD LAST_DATE DATE;Then, Alter the Table to rename the new column that is added.
    ALTER TABLE EMP RENAME COLUMN LAST_DATE TO OLD_COLUMN_NAME;And, Rename TEMP_HIREDATE to your actual collumn.
    ALTER TABLE EMP RENAME COLUMN TEMP_HIREDATE TO LAST_DATE;In practise, this won't be a good approach but you can get something useful about renaming the
    column atleast.
    Thanks,
    Shankar

  • How to add a new column to a report

    I want to add a new column to my existing report. I modified the using report wizard and added the new column. When I pressed 'Finish' I lost all my previous settings. Without changing the existing stuff, how can add a column to a table.
    Any help is appreciated.
    Regards
    Leena
    null

    go to the data model editor
    click on query .
    add new columns in select statement.
    add the corresponding fields in layout model
    compile it
    run it
    srini

  • Add a new column in Agreement Items table control (ME31K/ME32K/ME33K)

    Hi guys,
    I have a big issue.
    How can I add a new column at Agreement Items table control (ME31K/ME32K/ME33K) level.
    Thanks a lot.

    I think i solved the problem . The single way to to that is to modify the SAP standard Screen.

  • How to add the new dep area in existing cod

    Dear all,
    how to add the new dep area in existing cod we are planing to implement the IFRS by using leading ledger and non leading ledger present we are using OL leading ledger
    present we are using dep area 01 ,15
    how to achive the parallel accounting in asset accounting how to add new dep area 30 in existing COD
    if any document plz refer me  

    Hi Bhayyapu,
    Please refer to the links given below.
    New Depreciation area
    Adding a New Depreciation Area to Existing Assets - Financial Accounting (FI) - SAP Library
    Hope this will help you.
    Regards
    Eugene

  • How to add a new column as "Warehouse name" in Goods Receipt PO screen?

    Hi, Experts
    I hope to add a new column or just "display" warehouse name besides Whse column in Goods Receipt PO.  How can I do?
    Thanks

    still not work.
    Maybe I did something wrong in UDF definition. Please help to check.   Thanks
    I named UDF as WhseName, and set it as Alphanumeric and lengh is 20, structure is Regular. And all below check-boxes are not ticked.
    And in Goods Receipt PO screen, I marked the UDF as Visible and Active.
    Then I ALTSHIFF2 in the UDF fields, and FMS screen displayed.
    Then I chose the 3rd one: Search in Existing User-defined value According to Saved Query
    T05
    Auto Refresh when field changes is not ticked.

  • How to add a new column in between two other columns

    I need to add a new column in between two other existing columns. Does anyone know how to do that? The ALTER statement adds the column at the end. Can someone give an example.
    Thanks
    Murali
    null

    There is no simpler way of doing this because it is not strictly necessary: you can always see your data in the order you want simply by going SELECT col1, col2, col98, col4, etc. Thus the column order only matters when you execute SELECT * FROM...
    If that really is important enough to you you'll have to drop and re-create the table, for which there are a number of different strategies.
    Your final comment suggests that you don't retain your database build scripts. If you did then rebuilding your constraints would be painless. There is a lesson there. The good news is that if you have TOAD (download from www.quest.com) you can generate DDL scripts from your existing schema.
    HTH, APC

  • How to add a new column in SIM datawarehouse screen

    Hi All,
    Need to add one new column in SIM datawarehouse screen and map that with a database table column.Navigation for the that screen is -Shipping/Receiving->Warehouse Delivery ->select ASN->Select Container ->We get a detail screen.There need to add a new column.How to achive this.

    Hi....
       You can edit it from screen painter.. directly....with edit mode....
    > 1. goto -> secondary window -> dictionary fields or program fields...
    > 2. enter the table or program name... and drag that filed in to your table control header
    > 3. Or you can enter I/O field from tool box and text field from tool box for header of that I/O field
    > 4. You can adjust visible length... for your new field...
    > 5. Save and activate.
    Did you faced any problem with that?
    Thanks,
    Naveen Inuganti.

Maybe you are looking for