How to create a Foreign key relationship between 2 user defined tables...

Hi Folks,
I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
Any help would be highly appreciated...
Thanks

Hi
1.  In the 2nd table call the field of the 1st table which is a primary key.
2.  Give the same field and dataelement name.
3.  Select that field and then click on the foreign key field icon which is beside Search Help button.
4. Then give short text, and the 1st table name.
5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
7. Then again click on copy.
Regards
Haritha.

Similar Messages

  • How to read and write data to a user defined table?

    I have created a srf with 2 edit box and a ok buttin, I want to insert data to the user defined table i created using sql query while i press OK button..
    Please provide the complete code to insert and select da from the user defined table.

    Hi,
    You can use the code below.
    Dim ret As Long
    d
    Private Sub Add_Table_Click()
        Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
        Set oUserTablesMD = oCompany.GetBusinessObject(oUserTables)
        ' When adding user tables or fields, use a prefix
        ' identifying your partner name space. This will
        ' prevent collisions from different partner add-ons
        ' SAP's name space prefix is "BE_"
        'Set the two mandatory fields
        oUserTablesMD.TableName = "T1"
        oUserTablesMD.TableDescription = "Table1"
        'Add the table (which contains 2 default, mandatory fields, 'Code' and 'Name')
        ret = oUserTablesMD.Add
        If ret <> 0 Then
            oCompany.GetLastError ret, Str
            MsgBox Str
        Else
            MsgBox "Table: " & oUserTablesMD.TableName & " was added successfully"
        End If
    End Sub
    Private Sub Add_UDF_Click()
        Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
        Set oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)
        oUserFieldsMD.TableName = "T1"
        oUserFieldsMD.Name = "AlbUDF"
        oUserFieldsMD.Description = "Albert UDF"
        'Add the field to the table
        lRetCode = oUserFieldsMD.Add
        If lRetCode <> 0 Then
            oCompany.GetLastError ret, Str
            MsgBox Str
        Else
            MsgBox "Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table"
        End If
    End Sub
    Private Sub Add_Data_Click()
        Dim oUserTable As SAPbobsCOM.UserTable
        Set oUserTable = oCompany.UserTables.Item(1)
        oUserTable.GetByKey ("T1")
        'Set default, mandatory fields
        oUserTable.Code = "A"
        oUserTable.Name = "Albert"
        'Set user field
        oUserTable.UserFields.Fields.Item("U_AlbUDF").Value = "1"
        oUserTable.Add
        If ret <> 0 Then
            oCompany.GetLastError ret, Str
            MsgBox Str
        Else
            MsgBox "Value to field: '" & oUserTable.UserFields.Fields.Item("U_AlbUDF").Name & "' was updated successfuly to " & oUserTable.TableName & " Table"
        End If
    End Sub
    Regards,
    Noor

  • How to represent foreign key relationship between entity services

    Hi All,
    I have two entity services sbu and lob with remote persistensy(web service).In the sql database also i have these two tables.
    lob table attributes: lobId and lobName.
    sbu table attributes:sbuId,sbuName,and lobId.Here lobId a is foreign key referring to primary key of lob table.
    I want to represent this in the entity services.
    Can you plz tell me how can i do this?.
    Thanks
    Sampath.G

    Hi Sampath,
    to avoid creating a lob entity set the lobId and the timestamp attributes. because this is not smoothly done in the service browser, continue writing your UI.
    in old caf implementation this blog serie gives you a short overview...
    /people/raphael.vogel/blog/2006/05/18/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-i
    /people/raphael.vogel/blog/2006/05/18/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-ii
    /people/raphael.vogel/blog/2006/05/19/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-iii
    /people/raphael.vogel/blog/2006/05/21/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-iv
    Regards, Jens

  • How to create a foreign key for the table from two different tables?

    Hi All,
    I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
    code 1:
    CREATE TABLE SAMPLE_CONS_CHECK
            (NAME VARCHAR2(10),
            SERIES  VARCHAR2(5)
    CREATE TABLE SAMPLE_CONS2_CHECK
            (NAME  VARCHAR2(5),
             MODEL  NUMBER
    CREATE TABLE SAMPLE_CONS3_CHECK
            (NAME  VARCHAR2(5),
             MODEL_NO  NUMBER
            )code 2
    alter table SAMPLE_CONS_CHECK
    add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
    alter table SAMPLE_CONS2_CHECK
    add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
    alter table SAMPLE_CONS3_CHECK
    add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
    ALTER TABLE SAMPLE_CONS3_CHECK ADD
    CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
         NAME
    ) REFERENCES SAMPLE_CONS_CHECK
        NAME
    ) ON DELETE CASCADE;
    ALTER TABLE SAMPLE_CONS3_CHECK ADD
    CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
         NAME
    ) REFERENCES SAMPLE_CONS2_CHECK
        NAME
    ) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
    How can i solve this problem? Can anyone halp me about this?
    Thanks
    Edited by: orasuriya on Aug 8, 2009 2:02 AM

    Actually the design is completely incorrect.
    What you say is
    I have
    'foo', 'foo series'
    'foo','foo model'
    'foo',666
    By virtue of table3 referring to both table1 and table2.
    This means you actually need to have 1 (one) table:
    'foo','foo series','foo model', 666
    And the 'problem' disappears.
    Sybrand Bakker
    Senior Oracle DBA

  • HOw to create a foreign key in Derby netbeans 5.0

    I am trying to create a primary key in my database/web java application. I am using netbeans 5.0 and java vr5. I have put the following line in the DERBY SQL editor:
    ALTER TABLE staff ADD CONSTRAINT staff_fk FOREIGN KEY (staffID) REFERENCES staff (staffID);
    this returns Error: staffID is not a colum in Table of VTI skill
    However I have got a staffID Column in the table. Is this a BUG in netbeasn 5.0 or am I doing this incorrectly please can anyone show me a way round this problem. Iam suppose to use CMP or something please help.
    thanks in advance

    ALTER TABLE "staff" ADD CONSTRAINT "staff_fk" FOREIGN KEY ("staffID") REFERENCES "staff" ("staffID");

  • How to create an encrypted key for a user table

    I have an airshow website where volunteers and vendors can apply online (www.hollisterairshow.com) . The city attorney requires that we have a wet signature on a printed application form so the volunteer/ vendor currently has to print their application at the time they apply online, then sign it and mail it in and this works fine. Unfortunately, we have had a lot of instances where volunteers/ vendors needed to print their application again and the only way we could do this was for an administrator to print their application to a pdf file and e-mail the file to them. So, I'd like to improve this process by automatically sending an e-mail to the applicant when they apply online with a link to a printable page and containing a key pointing to their application. This way, volunteers/ vendors could print and sign their application whenever they want and as many times as they need to. Each volunteer is a single row in a volunteer table and each vendor is a single row in a vendor table.
    The key I use in the tables is a sequential key automatically incremented by MySQL so I would end up sending them a link looking something like www.hollisterairshow.com/printvolunteerapp.php?volunteernumber=27 . This would work, but it wouldn't be hard for a volunteer to change it to a different volunteernumber and so get access to someone else's personal information, which would not be acceptable. So, I'm thinking I need a secondary key that is somehow scrambled and used as an secondary index in the table so I'd be sending a link that mght look like www.hollisterairshow.com/printvolunteerapp.php?volunteerkey=sygew . So I'd really appreciate some advice on how to create a scrambled secondary index for each volunteer or vendor and plug it into the link I send them in the e-mail.
    Thanks for any advice.
    Tony

    Your question is not clear whether you want to create account or you want to create agent.
    For creating local agent you can refer
    http://bhabaniranjan.com/configure-odi-11g-local-agent/
    For creating EE Agent you can refer
    http://bhabaniranjan.com/configure-odi-java-ee-agent-on-windows-server-2008-64-bit/
    For creating account, login to supervisor and then go to security tab. There you can create different user to login to odi Studio. Let me know If i understand you correctly or not.
    Thanks.

  • Foreign key relationship between vbrp and j_1iexchdr

    Hi folks,
    Which field links vbrk and j_1iexchdr tables.
    Thanks.
    Sai.

    Hi Raj.
    I tried it using rdoc but i'm not getting, to retrive bukrs (company code) can i use ekko table, Right now I am developing excise invoice.
    Thanks.
    Sai.

  • How to create a foreign key in dictionary  in dynpro

    actually I have used the method given in one of replies by using the <u><b>ddl</b> scripts</u>.I want to ask whether it really works if yes then plz send me all the commands to be written in the script files  .please do send it urgently

    actually I have used the method given in one of replies by using the <u><b>ddl</b> scripts</u>.I want to ask whether it really works if yes then plz send me all the commands to be written in the script files  .please do send it urgently

  • Problem with Foreign Key relationships in SAP R/3 4.7

    Hi Experts,
    I am trying to create a foreign key relationship between 2 transparent tables in SAP R/3 4.7
    Table 1:ZAAVNDR (MANDT (pk), VENDORNO (pk), NAME, REGION, COUNTRY (fk)) Foreign Key Table
    Table 2: ZAAVNDRREF(MANDT(pk), COUNTRY (pk)) ---Check table
    I have added few valid countries in check table but when I am adding some records in foreign key table with invalid countries these records are not being restricted and are still successfully going into the table.
    Could any one please help in this.
    Thanks in anticipation.
    -Amit

    Hi Sandra,
    Many thanks for your response and providing time of yours.
    Now, I have done exactly the same thing, but still it is the same.
    I have created two new tables as below:
    ZAAVREF (Check table)
    MANDT (PK)
    COUNTRY (PK) Domain:ZAACOUNT (CHAR 10)
    ZAAV1 (Foreign key table)
    MANDT (PK)
    COUNTRY (PK) Domain:ZAACOUNT (CHAR 10)
    Then I have created FK on country of foreign key table ZAAV1 and then SE16 (for table ZAAVREF)->Create Entries-> Entered values for Country only->Save....Records entered with valid Country values.
    After that SE16 (for table ZAAV1)->Create Entries-->Entered an Invalid country->Save->Still the record entered to the Database successfully....
    Could you please let me know where I am going wrong.
    I am using SAP R/3 4.7 and creating tables using Tools->ABAP Workbench->Development->ABAP dictionary

  • SQL data modeller -- how to create 1 to 1 relationship foreign key ?

    hi guys...
    i got 2 tables..
    table 1 - CFR
    CFR_ID = primary key
    table 2 - USER_PLAN
    USER_ID = primary key
    PLAN_ID,
    CFR_ID = foreign key reference (table 1)
    The business flows go like this..
    insdie CFR table, it contain all records / transactions of a particular user/plan. everytime a new transaction occurs for a plan/user, a new CFR_ID / row will be generated.
    after which, the newly generated CFR_ID for the new row , will be updated to the CFR_ID in USER_PLAN
    Thus, there is always a 1 to 1 relationship between the 2 table regardless how many CFR_ID is generated for a particular USER_PLAN. as the CFR_ID in the USEr_plan table will always be the latest one generated inside the CFR table.
    However, in the data modeller, i am unable to create such foreign key relationship... ANY idea how do i create a 1 on 1 foreign key relationship ? or there is no such way..
    Thanks and Best Regards,
    Noob

    Hi philips,
    Thanks for the wonderful reply..
    Just to double comfirm with you,
    even if i had set a unique constraint on CFR_ID(foreign key column), inside the relationship model, the relationship between the foreign key is still showing as a 1:m relationship right ?
    just that a character 'U' will appear beside the CFR_ID column.
    However the diagraphm is still showing a 1:M relationship.
    is this correct ?
    Regards,
    Noob

  • Maintenance View for custom table with foreign key relationship

    Hi Folks,
         I have created a custom table with foreign key relationship with other check tables. I want to create a maintenance view / tablemaintenance generator. What all things I need to take care for the foreign keys related fields while creating the maintenance view / tablemaintenance generator.
    Regards,
      santosh

    Hi,
    You do not have to do anything explicitely for the foreign key relationships in the table maintainance generator.
    Create the table maintainance generator via SE11 and it will take care of all teh foreign key checks by itself.
    Regards,
    Ankur Parab

  • How to implement one to many relationship between two Document Line Table

    Hi,
    I want to implement the following relationship into user defined tables:
    Example Situation:
    There are tables A, B and C.
    For one record of Table A, there could be multiple records in table B.
    For one record of Table B, there could be multiple records in table C.
    i.e. A(1) -> B(n) [One to many relationship]
         B(1) -> C(n) [One to many relationship]
    finally: A(1) -> B(n) -> C(n)
    How can I achieve this? If I make Table A as Document and table B & C as Document Line and then make them UDO, will it work? Kindly suggest me a solution.
    Regards,
    Sudeshna.

    Hi,
    I think that the database representation is exactly what you ask for. 3 tables, A, B, C. A should have a UDF that is linked to B table, and B should have a UDF that is linked to C table.
    You should manage the database transactions, and the UI to support all this stuff.
    Regards,
    IBai Peñ

  • Mapping in OWB with primary key and foreign key relationship

    Hi all,
    I am new to this datawarehousing field. I have just started my career. I have to now create a mapping in owb where a table has a field which is a primary key of another table in the same staging area. If you guys could help me out with the a method it can be created that would be very helpful to me.
    I thought of 2 ideas,
    1. If I can use a look up, but then I am not sure if i can use a lookup for primary key, foreign key relationship. If I can use also, I do not know how to use that.
    2. What if I can directly take that the first table and link the primary key of that table to the second table which uses that primary key of the first table as one of its fields.
    I do not know how feasible these methods are. Please guys help me out.
    Thanks in advance.

    I have a similar case where table a and table b having relation but table a got inserted with data and table b is empty so there no values for foriegn key column in table b to realte with table a.
    Now i want to load table b foriegn key with primary key column values of table a.
    how can we do this in owb
    thanks
    kumar

  • Questions about creating a foreign key on a large table

    Hello @ll,
    during a database update I lost a foreign key between two tables. The tables are called werteart and werteartarchiv_pt. Because of its size, werteartarchiv_pt is a partitioned table. The missing foreign key was a constraint on table werteartarchiv_pt referencing werteart.
    Some statistics about the sizes of the mentioned tables:
    werteart 22 MB
    werteartarchiv_pt 223 GB
    werteartarchiv_pt (Index) 243 GB
    I tried to create the foreign key again, but it failed with the following error (Excuses for the german error message):
    sqlplus ORA-00604: Fehler auf rekursiver SQL-Ebene 1
    sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 erweitert
    The statement I used:
    alter table werteartarchiv_pt
    add constraint werteartarchiv_pt_fk1
    foreign key (schiene, werteartadresse, merkmale)
    references werteart (schiene, werteartadresse, merkmale)
    on delete cascade
    initially deferred deferrable;
    So the problem seems to be, that Oracle needs a lot of temporary tablespace to generate the foreign key and I do not know how much and why.
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.
    2a) Is it possible to tweak the statement without using the temporary tablespace?
    2b) If it is not possible to avoid the usage of the temporary tablespace, is there a formula how to calculate the needed temporary tablespace?
    3) Is it possible to modify data in the tables while the foreign key is created or is the whole table locked during the process?
    Any help or hint is appreciated.
    Regards,
    Bjoern

    RollinHand wrote:
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.Because it's validating the data to ensure the foreign key won't be violated. If you had specified ENABLE NOVALIDATE when creating it then the existing data in the table wouldn't need to be checked and the statement should complete instantly (future data added would be checked by the constraint).
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm
    Search for "Enable Novalidate Constraint State"

  • Create a foreign key from a field that is part of a mulitple primary key

    Hi,
    i had a table named T_A, with a double primary key : (A,B)
    Then i created a table named T_B with a field : C.
    I want this field T_B.C to take only values that already exist in field T_A.A.
    So i tried to create a foreign key on my field T_B.C, pointing on the field T_A.A : an error message appeared "not possible to create a foreign key on a field that is not a primary key".
    How can i solve this....? If U have any idea, please mail me !!
    THANX very much.

    Add column A as foreign key into the table T_BHow?
    (was the question from the original poster. Adding a column to table T_B that happen to have same name as the corresponding column in table T_A would not allow you to add the foreign key).
    SQL> create table t_a (a number, b number, primary key(a, b)) ;
    Table created.
    SQL> create table t_b(a number, c number, constraint foreign key references t_a(a)) ;
    create table t_b(a number, c number, constraint foreign key references t_a(a))
    ERROR at line 1:
    ORA-02270: no matching unique or primary key for this column-list
    SQL>

Maybe you are looking for

  • JSF + Tomahawk component NullPointerException

    Hi All, I made a sun JSF portlet by using the tomahawk 1.1.3 file upload component. The bean "UploadedFile myFile" is not getting set in the "MyBean.java" file. I get a java.lang.NullPointerException when I am trying to myFile.getName() or myFile.get

  • Problem on  "at selection-screen output." command

    Hi , in my programe a part of code is :- selection-screen : begin of block b0 with frame title text-000.    selection-screen:  skip 1.   parameters: s_box1  radiobutton group g1 user-command u1  default            'X',               s_box2 radiobutto

  • Does N810 support Bluetooth SAP(SIM Access Profile...

    Does N810 indeed support Bluetooth SAP? If so, N810 must have its own GSM modem, does N810 have modem?

  • Dvd creator for mac

    Anybody got any experience in using this to burn dvds from imovie projects or can suggest which software is best for this purpose?

  • Full Online + REDO Log backup failing

    Hi Experts, We have a failing backup when running a 'Full Online + REDO Logs' scheduled via DB13 (ERP6/Windows 2008/Oracle 10.2.0.4) Whilst it is successful in backing up the datafiles and the REDO logs to the remote destination, it fails to catalog