Primary key in internal table

hi experts,
              psl tell me how to assign a primary key to an intarenal table field while using hashed table.
thanks
mani

Hi,
you have to use INSERT INTO TABLE..
TYPES: BEGIN OF TYPE_MATERIAL,
                MATNR TYPE MATNR,
                WERKS TYPE WERKS_D,
                MENGE TYPE EKPO-MENGE,
             END OF TYPE_MATERIAL.
* Internal table with MATNR as the key..
DATA: T_HASHED TYPE HASHED TABLE OF TYPE_MATERIAL
                            WITH UNIQUE KEY MATNR.
* Work area
DATA: WA TYPE TYPE_MATERIAL.
WA-MATNR = 'TEST'.
WA-WERKS = 'TEST'.
* Insert the values..
INSERT WA INTO TABLE T_HASHED.
Thanks
Naren

Similar Messages

  • Primary Key in Internal tables?

    Hi all,
    Im doing a ABAP- certification, so I need an exact answer , not the 'I think...' or 'it should...' answers.
    I often heard the sentence 'every internal Table has a key, even if you dont define one!'. OK, I was told, that SAP takes the non-numeric fields, and bind them to the prim.-key.
    But now I wrote this little program:
    Report ZYX.
    DATA: Begin of wa,
      one type i,
      two type i,
      three type i,
      End of wa.
    DATA: it LIKE table of wa,
              temp type i.
    Do 100 times.
      temp = temp + 1.
      wa-one = temp.
      wa-two = temp + 1.
      wa-three = temp + 2.
    enddo.
    sort it descending.
    WRITE: / wa-one,wa-two,wa-three.
    Why doesnt it sort the table in ANY way descending?
    why doesnt this table seems to have a primary key?
    Is that a mistake by the SAP?

    I think it means both
    I copy here what I found in SAPHelp and you understand:
    Die Standardschlüsselfelder eines strukturierten Zeilentyps sind alle Felder, die weder numerisch (i, p, f) noch selbst Tabellentypen sind. Der Standardschlüssel bei nicht-strukturiertem Zeilentyp ist die gesamte Tabellenzeile, falls der Zeilentyp selbst kein Tabellentyp ist. Falls es keine entsprechende Komponente gibt bzw. der Zeilentyp selbst ein Tabellentyp ist, bleibt der Standardschlüssel leer, was aber nur bei Standardtabellen möglich ist.

  • Is there any restriction on the length of all Primary keys in a table

    Hi all,
    Is there any restriction on the length of all Primary keys in a data base table?
    i have some 10 fields as primary key in a DB table and length exceeds 120 and getting a warning.
    Please let me know will there be any problems in future with respect to the same?
    With regards,
    Sumanth

    Well actually there are constraints like
    Total of internal lengths of all primary key columns        1024 Bytes
    Number of primary key columns per table                     512
    For other information about SAP database please refer to http://sapdb.org/sap_db_features.htm  
    Thanks & Regards,
    Vivek Gaur
    Alwayz in high spirits

  • Is it possible to create many primary key for a table?

    hello sir/mam.
    i am selva, i am new to abap,
    is it possible to create many primary key for a table?
    please guide me.

    Hi Selva,
    Many Primary Keys = Composite Key.
    i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
    This can be achieved by checking the primary key check box in se11.
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • How to define Composite primary key for a Table

    Hi ,
    I am basically more into Java Programming , with little bit knowledge on Oracle as DataBase .so please excuse for my silly doubts .
    Can anybody please tell me how to define a Composite Primary Key on a Table .
    Thanks in advance .
    Edited by: user672373773 on Sep 25, 2009 8:54 AM

    Here is an example right out of the Oracle documentation and the syntax for adding PK since you mention adding a composite PK.
    Example creating composite index
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_indexing.htm#sthref594
    Syntax for adding a PK (composite or not)
    alter table oooooooo.tttttttt
    add constraint tttttttt_PK
    primary key (sample_column2,
    sample_column1)
    using index
    tablespace IDXSPC
    pctfree 05
    initrans 04
    maxtrans 08
    storage (initial 16k
    next 16k
    maxextents 32
    pctincrease 0);
    -- dictionary management with restricted storage, change as desired.
    HTH -- Mark D Powell --

  • How to get the PRIMARY KEY of a table at runtime ???

    Hi everybody,
    My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
    So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
    Any suggestions will be appreciated..
    Thanks,
    Sekhar

    U will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
    pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
    Or else you can try with 'DDIF_TABT_GET'
    Or try this code
    PARAMETERS: p_table TYPE tabname OBLIGATORY.
    DATA: go_strucdescr   TYPE REF TO cl_abap_structdescr,
          gt_tab_fields   TYPE ddfields.
    FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
    TRY .
    *   Get the details of the DDIC table
        go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
      CATCH cx_sy_move_cast_error .
        MESSAGE 'Error while casting' TYPE 'S'. RETURN.
    ENDTRY.
    * Check if input is a DDIC table
    CHECK go_strucdescr->is_ddic_type( ) = 'X'.
    * Get the details of the table fields
    gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
    * Display the Key fields of the table
    LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
      WRITE: / <gwa_tab_field>-fieldname.
    ENDLOOP.

  • How can I obtain the primary key of a table for an entity relation?

    hello everybody
    I am doing a consultation to a table in my data base, good this table has alone two fields, the first one is the code or pk and the second one is the description, to be presisos they are names of city and code.
    From the beginning!!: This method this one in another class that is a Dialog that is going to call to the class SelecPlace ();
      SelecPlace sl = new SelecPlace();
    public void capturarLugar(){  //  Simple void method in the mentioned class
            String place = txtProcedencia.getText() ;  //  a JTextField
            sl.executeStatement(place) ;                  
        }ok, now we see part of the code of the class SelectPlace
    public class SelecPlace extends AbstractTableModel{
        Connection con = null;
        Statement sentencia = null ;
        ResultSet rs = null;
        ResultSetMetaData rsmd = null ;
        String[] nameColum = {} ;
        Vector datos = new Vector() ;
        public SelecPlace() { }
        public void executeStatement(String query){
          try{
             con = DBManager.getConnection() ;
             sentencia = con.createStatement(rs.TYPE_SCROLL_INSENSITIVE,
                                                                          rs.CONCUR_UPDATABLE) ;
             String sql = "select * from Place where descripcion like %"+query+"%'";
              rs = sentencia.executeQuery(sql) ;
              rsmd = rs.getMetaData();
              int nroColumnas = rsmd.getColumnCount() ;
              nameColum = new String[nroColumnas] ;
              //obtengo los nombres de columnas en cache
               for(int colum = 0; colum < nroColumnas; columna++){
                    nameColum[colum] = rsmd.getColumnLabel(columna + 1) ;
               datos = new Vector();
                while(rs.next()){
                    Vector newRow = new Vector();
                    for(int i = 0; i < getColumnCount(); i++){
                    newRow.addElement(rs.getObject("place_ID"));
                    newRow.addElement(rs.getObject("description"));
                    datos.addElement(nuevaFila);
                fireTableChanged(null);
            }catch(SQLException e){
                System.err.println(e);
                e.printStackTrace(System.err);
                System.out.println("error in statement");
            }catch(ClassNotFoundException cnfe){
                System.err.println(cnfe);
        }Ok, this code me works and I obtain in this case the field description of the table Place
    Now my question is, how can I obtain the primary field of my table?
    I need this value of this field that in the base of information in a bigint, and to take it to the first class before mentioned, for that I am working with a data base related

    Certain duffymo and everyone!!, good I give you my scheme:
    And generalizing my question, I want to obtain the value of the primary key of a table in the database, I obtain more values of the same row, but I need the primary key, and you see one with the primary key I want to turn a Long and it to insert with code java in foreign clave in another table of the database
    Good of this form I believe that it would not be breaking the integrity relacional of the tables

  • Default key in internal tables

    what is 'Default key'? for what type of internal tables it is used? Can you please explain with examples?
    Thanks a lot.

    <i>Key
    The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
    <b>At tables with structured row type, the standard key is formed from all character-type columns of the internal table.</b> If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty. At tables with non-structured row type, the standard key consists of the entire row. If the row type is also a table, an empty key is defined.
    The user-defined key can contain any columns of the internal table that are no internal table themselves, and do not contain internal tables. References are allowed as table keys. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.</i>
    Regards,
    Rich Heilman

  • What is the best practice for creating primary key on fact table?

    what is the best practice for primary key on fact table?
    1. Using composite key
    2. Create a surrogate key
    3. No primary key
    In document, i can only find "From a modeling standpoint, the primary key of the fact table is usually a composite key that is made up of all of its foreign keys."
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/logical.htm#i1006423
    I also found a relevant thread states that primary key on fact table is necessary.
    Primary Key on Fact Table.
    But, if no business requires the uniqueness of the records and there is no materilized view, do we still need primary key? is there any other bad affect if there is no primary key on fact table? and any benifits from not creating primary key?

    Well, natural combination of dimensions connected to the fact would be a natural primary key and it would be composite.
    Having an artificial PK might simplify things a bit.
    Having no PK leads to a major mess. Fact should represent a business transaction, or some general event. If you're loading data you want to be able to identify the records that are processed. Also without PK if you forget to make an unique key the access to this fact table will be slow. Plus, having no PK will mean that if you want to used different tools, like Data Modeller in Jbuilder or OWB insert / update functionality it won't function, since there's no PK. Defining a PK for every table is a good practice. Not defining PK is asking for a load of problems, from performance to functionality and data quality.
    Edited by: Cortanamo on 16.12.2010 07:12

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • Multiple composite primary key in Master Table

    Dears ,
    I am try to find any solution about Multiple composite primary key by search in forum , but i didn't success ... i am try to built master detail , the master structure table built with multiple composite primary key , i know that apex 4.2 still support tow primary key , in detail table i solved the problem by depend on rowid , and now i can use multiple composite primary key in detail table , the problem with master table because it's support only tow primary key , there are any solution by manual process or any something else ?
    Thanks
    Abo Yahya

    Hi,
    I've never done this so all I can do is give some suggestions. It takes more effort because you are going beyond what APEX currently supports. That said, you might try searching the forum with this search string:
    key AND table AND instead
    Make sure the ANDs are capitailized in the search criteria. Also, look at this thread {thread:id=395870} and the forum thread asociated with this message {message:id=10542916}.
    Best wishes,
    Howard

  • Composite primary key in oe_order_headers_all table?

    Hi all
    What are columns involved in composite primary key in oe_order_headers_all table? how to identify that?
    (Order_number, order_type, org_id) are the combination of composite primary key or anything else ?

    select * From all_constraints where table_name = 'OE_ORDER_HEADERS_ALL'
    SELECT AIC.* FROM ALL_INDEXES AI, ALL_IND_COLUMNS AIC
    WHERE AI.TABLE_NAME='OE_ORDER_HEADERS_ALL'
    AND AI.UNIQUENESS='UNIQUE'
    AND AI.INDEX_NAME = AIC.INDEX_NAME
    order by AI.INDEX_NAME
    Hope this helps,
    Sandeep Gandhi

  • Two Primary keys on one table

    We are at the end of completing a project and we ran into a last minute bug. We are using two primary keys on a table to form a unique key. The problem we have is the program hangs up and gives us the following error,
    ORA-20001: Error in DML: p_rowid=CUA, p_alt_rowid=SIT_ID, p_rowid2=, p_alt_rowid2=. ORA-01422: exact fetch returns more than requested number of rows,
    probably meaning we only have one key setup in the DML
    processing when our table has two.
    we created a process with the Primary key set up in the DML but how does the secondary key column value work and is that what it's used for,because we tryed with no success. Is there a way around this problem without having to change our table by inserting only one primary key.
    Thanks in advance.
    Garry

    I am facing a similar problem , I used the two primary keys for navigating to the form page (forms with reports) so that the form page may display distinct records.
    Its not posing any error but its not showing the value of other columns associated with that record.
    Only the columns contained in the page item in the form page , that's are used as primary keys or that have been specified in the navigation part of the report page, are being shown ,
    Like for example I have got 5 columns
    a,b,c,d,e out of which a and b are my primary keys .
    I am using these to fetch values in the form page of forms with reports.
    We can specify three keys at the most , in my case I am having two , if in place of the third key I specify some column then in the form page it displays the correct record details of the three columns specified( 2 keys and one simple column), and it doesn't displays the value of other columns.
    Please help me out of this .

  • How many primary keys for one table?can we add more primary keys

    In general Table have one  primary key.is it possible to more than one primary key in a table?(ie is it possible to add more than one pirmary key in a table). Help me out.

    pls do check this link
    [http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm]
    All the key fields of a table must be stored together at the beginning of the table. A non-key field may not occur between two key fields.
    A maximum of 16 key fields per table is permitted. The maximum length of the table key is 255.
    If the key length is greater than 120, there are restrictions when transporting table entries. The key can only be specified up to a maximum of 120 places in a transport. If the key is larger than 120, table entries must be transported generically.

  • Primary Key missing in Table OBJS

    Hi,
    I have a problem in establishing relationship between Course Type and Course in Training and Event Management.
    Course Type is created in Active status and Course is Planned (ISTAT2).
    How can I create cours ein active status?
    How can I establish the relationship A020 between D and E object.
    How can I see the Participant list in PSV1 , I get an Error Primary Key misisng in Table OBJS.
    I am uploading the data with LSMW.
    Thanks
    PV

    Please go through documentation of report "RHSOBJCH". Also check following SAP notes:
    520488
    134311
    138411
    Regards

Maybe you are looking for

  • New version of Spry available on Labs!

    Hey Spry Fans, We just uploaded the latest version of Spry to Labs. We made many improvements to the framework, adding new attributes and features requested by forum users. * Switched to using namespaced attributes. Attributes are now of the form spr

  • IPhoto Library seems to be empty after running the iPhoto Library Upgrader

    Hi, I just transfered my account from a previous Mac Pro running 10.8.5 to a new MacBook Pro running 10.9.   I tried to open my iPhoto Library and it suggested me to download the iPhoto Library Upgrader, so I did, and upgraded the iPhoto Library, but

  • Web Dynpro based Workflow Inbox.

    Hi All. Can someone help me with this post. http://scn.sap.com/community/bpm/business-workflow/blog/2013/11/02/dear-sap-why-are-the-existing-webdynpro-based-workflow-inboxes-not-working-out-of-the-box I have posted my query at the end of this post lo

  • Wireless dropouts with WAG325N

    Hi all, I need some assistance with my newly purchased WAG325N.  I have made multiple attempts last night with support live but I always get the "this hardware is outside my scope" message. Story: I used to have a Billion 7402GL wireless modem router

  • Journald corruption

    There have been several threads about this but the usual diagnosis seems to be that corruption is caused by lack of a shutdown hook or by unclean shutdowns of the system. I'm seeing regular journal corruption even when I've had no unclean shutdowns a