Linking two tables with no duplicated records!

Hi,
I have two tables now with both tables is having the common filed matnr.
now using this field MATNR from  first table ,i need to fetch projectno from the other table which has to be unique.if there are more than one entry found for MATNR in question then that must not be updated to the first table!
any ideas?
Raj

hi raj,
try this code.
data:
  ld_count type p,
  ld_tabix type sy-tabix.
loop at itab1.
  move sy-tabix to ld_tabix.
  ld_count = 0.
  loop at itab2 where matnr eq itab1-matnr.
    add 1 to ld_count.
  endloop.
  if ld_count = 1.
    read table itab2 with key matnr = itab1-matnr.
    move itab2-project to itab1-project.
    modify itab1 index ld_tabix.
  endif.
endloop.

Similar Messages

  • Outer join two tables with query search record attached to both tables

    When I create a query with two tables that have query search records attached with outer join, PS seems to do a natural join (cartesian). We are on PT8.48.
    Is there a workaround for this issue. I do not want to remove query search record on either of the tables.
    I am trying to create an Emergency contact report. I am using two tables PS_EMPLOYEES and PS_EMERGENCY_CNTCT. Here is the sql PeopleSoft query generated when I did Left outer Join.
    Query SQL:
    SELECT A.EMPLID, A.NAME, A.ADDRESS1, A.CITY, B.PRIMARY_CONTACT, B.ADDRESS1, B.CITY, B.STATE, B.POSTAL, B.RELATIONSHIP, A.DEPTID, A.JOBCODE, A.COMPANY, A.EMPL_TYPE
    FROM (PS_EMPLOYEES A LEFT OUTER JOIN PS_EMERGENCY_CNTCT B ON A.EMPLID = B.EMPLID ), PS_EMPLMT_SRCH_QRY A1, PS_PERS_SRCH_QRY B1
    WHERE A.EMPLID = A1.EMPLID
    AND A.EMPL_RCD = A1.EMPL_RCD
    AND A1.OPRID = 'SREESR'
    AND (B.EMPLID = B1.EMPLID OR B.EMPLID IS NULL )
    AND B1.OPRID = 'PS'
    Appreciate any help.

    I think there are fixes for this issue in later tools releases (Report ID 1544345000). I'm not sure about 8.48, but you might try the workaround documented in
    E-QR: Left Outer Joins with Security Records are returning unexpected results [ID 651252.1]
    on Oracle Support.
    Regards,
    Bob

  • Join two tables with no matching records

    Hi All,
    I have two tables which have got data as below. Now I need to join those two tables but there are no matching rows or columns in those tables. I have used OUTER JOIN but query was taking more than 5 mnts to run. Whats the best way to join two tables where
    there are no matching records.
    Table : Sections &Table : orders 
    I am expecting the final output like I have mentioned below.
    How can i write a JOIN. Note there are no matching records from both the tables.
    Pls.This is a very urgent requirement.Regards
    -pep

    Thanks Elrand. I have one question. What if I want to add 10 more parameters in @Section table then
    the logic I have written below will not work. I will have to make it dynamic. Any suggestions.?
    declare @test table (RowNo INT,CokeType NVARCHAR(MAX),BeginUsage dateTIME)
    declare @Section table (SectionName NVARCHAR(100))
    insert into @Section values ('CokeType')
    insert into @Section values ('BeginUsage')
    insert into @test values (1,'OMV - 02E (04/2012)','01-02-2014')
    insert into @test values (2,'OMV - 02E (04/2012)','01-03-2014')
    insert into @test values (3,'PCIC - 01 (01E/2013)','01-04-2014')
    insert into @test values (4,'PCIC - 01 (01E/2013)','01-05-2014')
    insert into @test values (5,'PCIC - 01 (E) - 07/2011 & Alba /2010 (C/F) 05/2011','01-06-2014')
    select * from @Section
    select * from @test
    SELECT
    RowNo,SectionName,
    CASE
    WHEN(SectionName = 'CokeType') THEN CokeType
    ELSE
    CAST (BeginUsage AS VARCHAR(MAX))
    END
    AS DATA
    FROM @Section AS S
    CROSS APPLY
    (SELECT T.RowNo,T.CokeType,T.BeginUsage FROM @test T) P
    ORDER BY SectionName DESC

  • MATERIALIZED view on two tables with Fast Refresh

    i Wanted to create MV on two tables with Fast refresh on commit.
    I followed below steps
    create materialized view log on t1 WITH PRIMARY KEY, rowid;
    create materialized view log on t2 WITH PRIMARY KEY, rowid;
    CREATE MATERIALIZED VIEW ETL_ENTITY_DIVISION_ASSO_MV
    REFRESH fast ON commit
    ENABLE QUERY REWRITE
    AS
    select A.ROWID B.ROWID,a.c1, DECODE(a.c1,'aaa','xxx','aaa') c2
    from t1 A
    join t2 b
    on AB.c1= CD.c2;
    i am getting below error.
    Error report:
    SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
    12054. 00000 - "cannot set the ON COMMIT refresh attribute for the materialized view"
    *Cause:    The materialized view did not satisfy conditions for refresh at
    commit time.
    *Action:   Specify only valid options.
    Basically i want to take record in MV by joinig two tables and if both of the base tables will updated then record should reflect in materialised view.
    Please do the needfull.

    does the table support PCT? the other restrictions on joins look to be ok in your statement.
    maybe try creating first with on demand instead of commit to see does it create.
    http://docs.oracle.com/cd/B19306_01/server.102/b14223/basicmv.htm
    >
    Materialized Views Containing Only Joins
    Some materialized views contain only joins and no aggregates, such as in Example 8-4, where a materialized view is created that joins the sales table to the times and customers tables. The advantage of creating this type of materialized view is that expensive joins will be precalculated.
    Fast refresh for a materialized view containing only joins is possible after any type of DML to the base tables (direct-path or conventional INSERT, UPDATE, or DELETE).
    A materialized view containing only joins can be defined to be refreshed ON COMMIT or ON DEMAND. If it is ON COMMIT, the refresh is performed at commit time of the transaction that does DML on the materialized view's detail table.
    If you specify REFRESH FAST, Oracle performs further verification of the query definition to ensure that fast refresh can be performed if any of the detail tables change. These additional checks are:
    A materialized view log must be present for each detail table unless the table supports PCT. Also, when a materialized view log is required, the ROWID column must be present in each materialized view log.
    The rowids of all the detail tables must appear in the SELECT list of the materialized view query definition.
    If some of these restrictions are not met, you can create the materialized view as REFRESH FORCE to take advantage of fast refresh when it is possible. If one of the tables did not meet all of the criteria, but the other tables did, the materialized view would still be fast refreshable with respect to the other tables for which all the criteria are met.

  • Infotype to link Personnel Number with Vendor Master Record

    Hi All,
    pls help me what infotype to link Personnel Number with Vendor Master Record in AP module.
    Customer require when Create Employee then system automatic gernerate Vendor Master.
    pls help us.
    Thanks

    Hi,
    PRAA works absolutely fine. I have external number range for vendors.
    There is an option so that you can create HR accounts in vendor accounts
    Path:Accounting> Financial accounting>Travel
    management>Personal-Related Master Data> Create Vendors (tr.code PRAA)
    Look at this description:
    From the HR master data, this program creates a batch input session for
    maintaining person-specific vendor master records.
    The report can process vendor master records as follows:
    o Initial set up (create/add missing company code segment)
    o Uupdate (change completely according to vendor and HR reference)
    o Change (only according to HR master data, for example, name
    Block
    The following infotypes from HR master data are taken into account for
    the key date specified:
    o Actions (Infotype 0000)
    o Organizational Assignment (Infotype 0001)
    o Personal Data (Infotype 0002)
    o Permanent Residence (Infotype 0006 Subtype 1)
    o Bank Details (Infotype 0009 Subtype 0 or 2)
    All other required data is taken from a reference vendor that you can
    specify as a parameter when you start the program. Note that for the
    reference vendor, reference data must exist for all company codes that
    are applicable according to HR master data. Since program RPRAPA00 cannot
    assign vendor master record numbers externally when creating
    vendor master records, you must be sure that the reference vendor is
    assigned to an account group that requires internal number assignment.
    If no house bank is specified in the reference vendor, this is
    determined via feature TRVHB (Implementation guide for 'Travel Expenses'
    -> Transfer to Data Medium Exchange -> Set up Feature for Determining
    House Bank according to the employee's organizational situation.
    The link between the HR employee's master record and the corresponding
    vendor master record is set up by entering the personnel number in the
    company code segment of the vendor master record.
    General program flow
    Program RPRAPA00 creates a sequential work file in the specified
    directory. Ensure that you use a global directory that can be accessed
    by all application servers; a directory is automatically proposed. The
    work file is later transformed into a batch input session by the
    subsequent program RFBIKR00, which is started automatically.
    In test run mode this program delivers information messages which
    document the creation of a batch input session. Since each information
    message must be confirmed manually, the test run should only be
    performed for a small number of personnel numbers.
    In productive run mode, however, the program RFBIKR00 is automatically
    started as a job; the information mentioned above is stored in the job
    log in this case.
    Initial setup of vendor master records
    Corresponding vendor master records are created from the infotypes
    listed above and the non-HR-specific information from the reference
    vendor. During the process, the personnel number is stored in the
    company code segment of the vendor master record. Persons who already
    have a vendor master record with corresponding personnel number are
    rejected in this run.
    If a vendor master record already exists for a personnel number, but
    without a company code segment for the company code in which the
    employee exists at the key date entered, the program adds the required
    company code segment to the vendor master record. You must however
    activate the checkbox "Create new company code segment for existing
    vendor master records".
    The HR master data used is the info type record valid on the key date
    entered.
    Update of vendor master records
    The corresponding vendor master records are updated from the infotypes
    listed above and the non-HR-specific information from the reference
    vendor. Persons who already have a vendor master record with
    corresponding personnel number are rejected in this run. The system uses
    HR master data from the infotype records valid for the key date.
    Change vendor master records according to HR master data
    All HR-specific data is changed in the vendor master records for
    personnel numbers that have changes since the date recorded under '...
    with last change since'. The system uses HR master data again from the
    infotype records valid for the key date specified.
    Block vendor master records
    All vendor master records which correspond with the selected personnel
    numbers are blocked for posting.
    User exits
    For the following situations, two empty routines are supplied in the
    includes RPRAPAEX and RPRAPAEX&H5F001 which you can adapt to your
    requirements.
    o The employee's last name is entered in the sort field in the vendor
    master record. If you do not want this to happen, you can program
    the situation you want in the user exit routine
    'set&H5Fmc&H5Ffield&H5Fby&H5Fuser'.
    o If the address editing in the vendor master record does not suit
    your requirements, it can also be changed. For this purpose you have
    the user exit routine 'set&H5Faddress&H5Fby&H5Fuser'.
    o If you want to assign numbers to the vendor master records to be
    created via external number assignment (for example, vendor master
    record number &H3D personnel number), you can adjust the user exit
    routing 'SET&H5FVENDOR&H5FNO&H5FBY&H5FUSER' (in include RPRAPAEX&H5F00). Note
    that
    the account group of the reference vendor must also have external
    number assignment.
    Note that in each case a thorough knowledge of the programming
    language
    ABAP/4 is necessary.
    Set up vendor master records in a separate system
    The distribution of personnel master data from a HR system to an FI
    system is a prerequisite for creating, changing, and blocking vendor
    master records.
    In the section Master Data Distribution (link to separate HR unit) of
    the ALE IMG, an explanation is given regarding the way in which the
    FI
    System is supplied with the relevant employee data from the HR System
    In the FI System, report RPRAPA00 described here can be used to
    create,
    change, and block vendor master records.
    Other wise try with VPE1 t.code.
    Regards
    Devi

  • Query for Linking Two Tables without Reference

    Hi Folks,
    Good Day!
    I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
    When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
    Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
    OTER and OCRD don't have connections. How can it be?
    I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
    Thank you much!
    Regards,
    Fringe

    Hi Fringe,
    Okay, I already understood your case here. I presume your configuration as follows:
    OTER (Territory)
    territryID - descript
    1 - Philippine
    2 - Indonesia
    3 - Germany
    OPRC (Cost Centre)
    PrcCode - PrcName
    25 - Philippine
    33 - Indonesia
    47 - Germany
    Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
    SELECT PrcCode FROM OPRC WHERE PrcName=(
    SELECT TOP 1 descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0])
    However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
    OTER (Territory)
    territryID - descript
    1 - PHI
    2 - INA
    3 - DEU
    OPRC (Cost Centre)
    PrcCode - PrcName
    PHI - Philippine
    INA - Indonesia
    DEU - Germany
    When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
    SELECT descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0]
    You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
    Best Regards,
    Hendry Wijaya

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • How to link two tables?

    Hello,
    I'm trying to create invoices with Pages, but my question is how can I link two tables in one Pages document?
    Or having two Header Rows with some 'normal' rows between would also be great. (even better)
    I'm trying to calculate my subtotal etc. below my overview of articles.
    Thanks in advance!
    Andy

    (1) no way to link two tables in Pages.
    (2) you may have several header rows, several footer rows but you can't have standard rows between header (or footer) ones.
    You may achieve what you describe without the asked feature.
    Use correct ranges and you will be able to calculate subtotals.
    Yvan KOENIG (VALLAURIS, France) lundi 28 décembre 2009 19:02:38

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • In ER DIagram using toad( how can i link two tables)

    Hi,
    Any Toad expert can guide me that how can i link two tables in Toad in ER Diagram to show the relationship between two tables.
    Thanks

    Hi,
    I hope there is foreign key relationship in tables, if so then you can click on "Find table dependencies" icon which will draw lines between them.
    ~Vinod

  • How to match columns of two tables with

    Hello:
    I've two tables like below:
    Table1:(Base Table)
    Country|Prefix|Prefix_Length
    CountryA|001|3
    CountryB|0012|4
    CountryC|00443|5
    CountryD|0091|4
    Table2:(Detail Table)
    Population|Area|Prefix
    500|AreaA|0015921
    1000|AreaB|00122
    400|AreaC|00443743
    300|AreaD|0091333
    100|AreaA|001
    I need to match these two tables with prefix column (which length is not fixed in both tables: but it starts with 00 in both tables). Two different countries prefix can be similar up to a certain length. So, Prefix_Length can be used to determine (exactly) how long should be taken to search from Table2.
    Output:
    Country|Prefix|Area|Population
    CountryA|001|AreaA|600
    CountryB|0012|AreaB|1000
    CountryC|00443|AreaC|400
    CountryD|0091|AreaD|300
    Please help me with your valuable feedback.
    -Tanvir

    You have to explain how CountryA population is calculated:
    with base_table as (
                        select 'CountryA' country,'001' prefix,3 prefix_length from dual union all
                        select 'CountryB','0012',4 from dual union all
                        select 'CountryC','00443',5 from dual union all
                        select 'CountryD','0091',4 from dual
       detail_table as (
                        select 500 population,'AreaA' area,'0015921' prefix from dual union all
                        select 1000,'AreaB','00122' from dual union all
                        select 400,'AreaC','00443743' from dual union all
                        select 300,'AreaD','0091333' from dual union all
                        select 100,'AreaA','001' from dual
    -- end of on-the-fly data sample
    select  country,
            b.prefix,
            area,
            population
      from  base_table b,
            detail_table d
      where b.prefix = substr(d.prefix,1,prefix_length)
    COUNTRY  PREFI AREA  POPULATION
    CountryA 001   AreaA        500
    CountryA 001   AreaB       1000
    CountryA 001   AreaA        100
    CountryB 0012  AreaB       1000
    CountryC 00443 AreaC        400
    CountryD 0091  AreaD        300
    6 rows selected.
    SQL> SY.

  • How to get the table with no. of records after filter in webdynpro

    Dear Gurus,
    How to get the table with no. of records after filter in webdynpro?
    Thanks in advance.
    Sankar

    Hello Sankar,
    Please explain your requirement clearly so that we can help you easily.
    To get the table records from your context node use method get_static_attributes_table()
    data lo_nd_mynode       type ref to if_wd_context_node. 
    data lt_atrributes_table  type wd_this->elements_mynode. 
    lo_nd_mynode = wd_context->get_child_node( name = wd_this->wdctx_mynode ). 
    lo_nd_mynode->get_static_attributes_table( importing table = lt_atrributes_table ). 
    Note: You should have already defined your context node as a Dictionary Structure.
    BR,
    RAM

  • I need to implement Drag N Drop between two tables which saves both records

    I need to implement Drag N Drop between two tables which saves both records in a third page, by using drag n drop.

    check this video http://baigsorcl.blogspot.com/2011/01/drag-and-drop-collection-in-oracle-adf.html

  • How to give relationship between two tables with comon column with between oprator

    Hi Folks,
    I am using Sql Server 2008R2. I am getting a problem to establish relationship between two tables. 
    I have two Tables, 1.Inventory Details Table another one is Inventory Header Table.
    Inventory Details Table having a column Card No and inventory Header Table having columns  From card No and To Card No.
    I want to give relationship between these two tables with Card no. Could you please provide me the Sql Query.
    Your help would be greatly appreciated .
    Regards
    hasthi.
    email:[email protected]

    Hi Raju,
     We have two way that we can relate to the table either join or quality condition use following syntax/Query  for relating two tables 
    select * from Inventory_Details ID inner join  Inventory_Header IH on ID.CardNo between IH.FrmCardno and IH.ToCardNo
    or 
    Select * from  Inventory_Details ID ,Inventory_Header IH where ID.CardNo=IH.CardNo OrSelect * from  Inventory_Details ID ,Inventory_Header IH where ID.CardNo between IH.FrmCardno and IH.ToCardNo
    Hope this will help you 
    Niraj Sevalkar

  • How to update two tables with trigger

    Hi:
    how to update two tables with trigger ?
    I have two tables :
    (1)ASIA
    MI number;
    (2)ASIA_P
    ID number;
    When I insert a new value into the asia.MI ,I also can
    insert the same value into the asia_p.id field.
    I have write a trigger as follows but it does't work.
    create or replace trigger MI_TRG
    before insert on asia
    for each row
    declare
    seq number;
    begin
    select MI_SEQ.Nextval into seq from dual;
    :new.MI:=seq;
    insert into ASIA_PRO(MI_ID)
    values
    (seq);
    end MI_TRG;
    How to realize it ?
    thanks
    zzm

    Why do you say it does not work?

Maybe you are looking for

  • Help with Using One Master Account on a NAS server in ALAC

    I want to use my Netgear ReadyNAS server to hold my music, which I am going to re-rip into Apple Lossless (using dBpoweramp converter and a sony xl1b -so as to do 200 discs at a time). That server is mainly used by my home 2008 Mac Pro. So the iTunes

  • Move a file to external disk and remove the original

    This is a script that was supplied to me on these forums it has been working well, but all the transferring of the files took place locally so a 'Move' command does it eactly what it says, however I now need to move it to an external drive, as a resu

  • Photo Order in iCloud Sharing

    How can I keep my photos in the same order as they are in the album, once I upload to iCloud Photo Sharing?

  • Why already purchsed songs / albums are not  grayed out but are available to purchase again?

    Songs and albums that I have already purchased appear available to buy again. Even If I try to buy them (again) I get not notification that I have already purchased it before. I have reset all relative warnings in itunes account. Shouldn't they be gr

  • IDoc ORDERS05 structure

    Hi all, Anybody can tell me where I could find a full description of the structure/segments/fields of IDoc ORDERS05? I cannot find the full documentation anywhere. Many thanks, Aldo