QUESTION INNER JOIN FOR UPDATE

Dear All,
does oracle support this sql update statement?
UPDATE Tb1 INNER JOIN Tb2 ON Tb1.empid = Tb2.empid2 SET
Tb2.salary = Tb1.salary * 0.5
Best Regards
Terence Chua

No - because you are trying to update the salary in Tb2
in an update statement for TB1
If you are trying to update the salary in T1 based on the salary in T2, use the following
UPDATE Tb1
set Tb1.salary = (
select TB2.salary * 0.5
from TB2
where TB2.empid2 = TB1.empid
However, I am wondering if you have your model confused.
Can you please confirm that you have two separate tables.
TB1 has column EMPID
TB2 has column EMPID2
or - are TB1 and TB2 the same table
If they are the same table - please confirm if you have one EMPID column - or an EMPID column and an EMPID2 columns.

Similar Messages

  • INNER JOIN FOR BSEG

    HI experts,
                   Can v use BSEG and BKPF table in inner join.
    thanks.
    Khan

    Hi Khan,
    Need to do this way because u can't join cluster and pooled tables...
    1. FOR ALL ENTRIES.
    2. It is recommended that
    first select entries from only one table
    (say, BKPF),
    3. After that, using the internal table,
    FOR ALL ENTRIES, and BSEG table,
    select the relevant entries from BSEG table.
    4. Performance wise, this will be very fast.
    See the Below example and modify ur it according to ur requirement ...
    data: begin of tbl_bkpf occurs 0,
            bukrs  like bkpf-bukrs,
            belnr  like bkpf-belnr,
            gjahr  like bkpf-gjahr,
          end of tbl_bkpf.
    data: begin of tbl_bseg occurs 0,
            bukrs  like bkpf-bukrs,
            belnr  like bkpf-belnr,
            gjahr  like bkpf-gjahr,
          end of tbl_bseg.
    select bukrs belnr gjahr
           into table tbl_bkpf
           from bkpf
           where belnr in s_belnr. "Insert parameters here
    check sy-subrc eq 0.
    select belnr
           into table tbl_bseg
           from bseg
           for all entries in table tbl_bkpf
           where bukrs = tbl_bkpf-bukrs and
                 belnr = tbl_bkpf-belnr and
                 gjahr = tbl_bkpf-gjahr.
    sort tbl_bseg by bukrs belnr gjahr.
    loop at tbl_bkpf.
      read table tbl_bseg with key bukrs = tbl_bkpf-bukrs
                                   belnr = tbl_bkpf-belnr
                                   gjahr = tbl_bkpf-gjahr
                          binary search.
      if sy-subrc ne 0.
    ** ur logic here
      endif.
    endloop.
    This method hits the DB twice only, and using the BINARY SEARCH is a very efficient way to search a SORTED Internal Table.
    Hope it will solve your problem..
    <b>Reward points if useful..</b>
    Thanks & Regards
    ilesh 24x7

  • How to use Inner Join for these 4 table's

    Hi Guys,
                  My Requirement is i have to get the data into the final Internal table whose structure is like this (BWKEY   type  MBEW-BWKEY,
            MATNR   type  MBEW-MATNR,
            MAKTX   type  MAKT-MAKTX,
            BWTTY   type  MBEW-BWTTY,
            BWTAR   type  MBEW-BWTAR,
            MEINS   type  MARA-MEINS,
            BKLAS   type  MBEW-BKLAS,
            VPRSV   type  MBEW-VPRSV,
            STPRS   type  MBEW-STPRS,
            PEINH   type  MBEW-PEINH,
            CRCY(3)    type  c,
            LBKUM   type  MBEW-LBKUM,
            SALK3   type  MBEW-SALK3,
            LAEPR   type  MBEW-LAEPR,
            J_3ADEFSI   type  MARC-J_3ADEFSI,
            J_4kDEFSC   type  MARC-J_4kDEFSC,
            SCLAS   type  MARA-/AFS/SCLAS,
            EKALR   type  MBEW-EKALR,
            HKMAT   type  MBEW-HKMAT,
            HRKFT   type  MBEW-HRKFT,
            KOSGR   type  MBEW-KOSGR,
            PRCTR   type  MARC-PRCTR,
            MMSTA   type  MARC-MMSTA,
            SOBSK   type  MARC-SOBSK,
            PPRDL   type  MBEW-PPRDL,
            LPLPR   type  MBEW-LPLPR,
            PPRDZ   type  MBEW-PPRDZ,
            ZPLPR   type  MBEW-ZPLPR)
                  from 4 table's MBEW , MARA MAKT and MARC.
         Can anybody provide the logci for this based on the below requirement
    "Go to table MBEW with material number, plant and valuation type; fetch the information laid out in output format. There are some fields which need to come from tables MARC, MARA and MAKT. The common criterion is material number across these tables.
    MBEW-MATNR = MARC-MATNR
    MBEW-MATNR = MARA-MATNR
    MBEW-MATNR = MAKT-MATNR
    Thanks,
    Gopi.

    Hello Gopi,
    I did not have system now and just written in notepad..
    types : begin of ty_mbew ,
    MATNR type MBEW-MATNR,
    BWTTY type MBEW-BWTTY,
    BWTAR type MBEW-BWTAR,
    MEINS type MARA-MEINS,
    BKLAS type MBEW-BKLAS,
    VPRSV type MBEW-VPRSV,
    STPRS type MBEW-STPRS,
    PEINH type MBEW-PEINH,
    CRCY(3) type c, " What is this field ,i did not include in join
    LBKUM type MBEW-LBKUM,
    SALK3 type MBEW-SALK3,
    LAEPR type MBEW-LAEPR,
    J_3ADEFSI type MARC-J_3ADEFSI,
    J_4kDEFSC type MARC-J_4kDEFSC,
    SCLAS type MARA-/AFS/SCLAS,
    EKALR type MBEW-EKALR,
    HKMAT type MBEW-HKMAT,
    HRKFT type MBEW-HRKFT,
    KOSGR type MBEW-KOSGR,
    PRCTR type MARC-PRCTR,
    MMSTA type MARC-MMSTA,
    SOBSK type MARC-SOBSK,
    PPRDL type MBEW-PPRDL,
    LPLPR type MBEW-LPLPR,
    PPRDZ type MBEW-PPRDZ,
    ZPLPR type MBEW-ZPLPR,
    end of ty_mbew.
    types : begin of ty_makt ,
    matnr type makt-maktx,
    MAKTX type MAKT-MAKTX,
    end of ty_makt.
    types : begin of ty_final ,
    MATNR type MBEW-MATNR,
    MAKTX type MAKT-MAKTX,
    BWTTY type MBEW-BWTTY,
    BWTAR type MBEW-BWTAR,
    MEINS type MARA-MEINS,
    BKLAS type MBEW-BKLAS,
    VPRSV type MBEW-VPRSV,
    STPRS type MBEW-STPRS,
    PEINH type MBEW-PEINH,
    CRCY(3) type c,
    LBKUM type MBEW-LBKUM,
    SALK3 type MBEW-SALK3,
    LAEPR type MBEW-LAEPR,
    J_3ADEFSI type MARC-J_3ADEFSI,
    J_4kDEFSC type MARC-J_4kDEFSC,
    SCLAS type MARA-/AFS/SCLAS,
    EKALR type MBEW-EKALR,
    HKMAT type MBEW-HKMAT,
    HRKFT type MBEW-HRKFT,
    KOSGR type MBEW-KOSGR,
    PRCTR type MARC-PRCTR,
    MMSTA type MARC-MMSTA,
    SOBSK type MARC-SOBSK,
    PPRDL type MBEW-PPRDL,
    LPLPR type MBEW-LPLPR,
    PPRDZ type MBEW-PPRDZ,
    ZPLPR type MBEW-ZPLPR,
    end of ty_final.
    Internal tables
    data :i_mbew type standard table of ty_mbew,
    i_makt type standard table of ty_makt,
    i_final type standard table of ty_final.
    Work Areas
    data : wa_mbew like line of i_mbew,
    wa_makt like line of i_makt,
    wa_final like line of i_final.
    start-of-selection.
    get the data from MBEW,MARA,MARC Table
    select aMATNR aBWTTY
           aBWTAR bMEINS
           aBKLAS aVPRSV
           aSTPRS aPEINH
    *CRCY(3) type c,
    aLBKUM aSALK3 a~LAEPR
    c~J_3ADEFSI type MARC-J_3ADEFSI,
    c~J_4kDEFSC type MARC-J_4kDEFSC,
    b~SCLAS type MARA-/AFS/SCLAS,
    aEKALR aHKMAT
    aHRKFT aKOSGR
    cPRCTR cMMSTA
    cSOBSK aPPRDL
    aLPLPR aPPRDZ
    a~ZPLPR into corresponding fields of table i_mbew
            from mbew as a inner join mara as b on bmatnr = amatnr
            inner join marc as c on cmatnr = amatnr.
    if sy-subrc eq 0.
    select matnr maktx from makt into table i_makt
                 for all entries in i_mbew
                 where matnr = i_mbew-matnr
                 and   spras = sy-langu.
    endif.
    loop at i_mbew into wa_mbew.
    read the data from MAKT Table
    read table i_makt into wa_makt with key matnr = wa_mbew-matnr.
    if sy-subrc eq 0.
    move-corresponding wa_mbew to wa_final.
    move wa_makt-maktx to wa_final-maktx.
    append wa_final to i_final.
    endif.
    endloop.
    Thanks
    Seshu

  • Inner join for three table

    dear friends
    kna1- kunnr ,name1
    vbak - vbeln , erdat
    vbap - meins , kwmeng
    on above i have given three tables and their fields in front of this
    can any one tel me how to give inner join in select statement for the above tables

    Hi Create an appropriate internal table ITAB
    Select VBAK~VBELN
               VBAK~ERDAT
               VBAP~POSNR
               VBAP~MEINS
               VBAP~kwmeng
               KNA1~KUNNR
               KNA1~NAME1
    From VBAK
    Into Table ITAB
    Inner Join VBAP On VBAKVBELN = VBAPVBELN
    Inner Join KNA1 On VBAK~KUNNR = KNA1-KUNNR
    Where VBAK~VBELN In S_VBELN.
    Santhosh

  • Problem when doing inner join for three tables....

    DATA: V3 TYPE VBAP-MAKTL.
    SELECT single vbap~matkl into V3
           from VBAP
           inner join VBFA
           inner join LIPS
              on LIPSPOSNR = VBFAPOSNN
              and vbapvbeln = vbfavbelv
               and vbapposnr = vbfaposnv
                 where LIPSVBELN = VBFAVBELN = '0080000834'
                 and vbfa~vbtyp_n = 'J'
                 and LIPS~J_3ASIZE = '0884'.
    Error: Wrong expression "INNER" in from clause...

    Hello Tushar,
      Why you are using the 3 table inner join. If the volume of data is big then this statement will give to time out. Use "for all entries" statement to select the data from the table.
    Like
    select field1 field2 from LIPS into i_lips
        where LIPS~J_3ASIZE = '0884'.
    select f3 f4 from vbfa into i_vbfa for all entries in i_lips where field1 = i_lips-field1 and so on
    and 
    use same to select data from VBAP.
    Hope this will help

  • Inner Joins & for all entries

    Hi
    1) SELECT RSEGBUKRS RSEGBELNR RSEGGJAHR RSEGBUZEI RBKPLIFNR RSEGWERKS RSEGEBELN RSEGEBELP RSEGMATNR RSEGWRBTR RBKPRBSTAT RBKPZUONR RBKPRMWWR RBKPWAERS RBKP~KURSF
              INTO TABLE I_RSEG
               FROM RBKP
               INNER JOIN RSEG
               ON
               RBKPBELNR = RSEGBELNR AND
               RBKPGJAHR = RSEGGJAHR
               FOR ALL ENTRIES IN I_BKPF
               WHERE RBKP~BELNR = I_BKPF-BELNR
                 AND RBKP~GJAHR = I_BKPF-GJAHR
                 AND RSEG~WERKS IN S_WERKS
                 AND RBKP~LIFNR IN S_LIFNR.
    2) IF NOT I_BKPF[] IS INITIAL.
       SELECT belnr gjahr lifnr rbstat zuonr rmwwr waers kursf stblg
                        FROM rbkp into corresponding fields of table i_rbkp1
                           FOR ALL ENTRIES IN I_BKPF
                           WHERE BELNR = I_BKPF-BELNR
                           AND   GJAHR = I_BKPF-GJAHR
                           AND   LIFNR = S_LIFNR.
    ENDIF.
       I am replacing the first select statment using inner join with for all entries. but it is not yelding same result.First select statement retrieves records while second one does not using same where conditions. How inner join would work,can we replace inner join using for all entries.
    Regards,
    Karthik.k

    any one  suggest..
    Regards,
    Karthik

  • Inner Join for Dynamic Select statement

    Hi All,
      Can some one please help me in rewriting the below select statement where i have to remove the existing table1 by putting a dynamic table name which has the same table structure.
      select a~zfield1
               a~zfield2
          from ztab1 as a
           inner join ztab2 as b
               on b~ztab1-zfield3 = a~ztab2-zfield3
         where a~zfield4 = 'A'.
    I am looking something as below. But encountering an error when using the below statement
      select a~zfield1
               a~zfield2
          from (v_ztab1) as a
           inner join ztab2 as b
               on b~ztab1-zfield3 = a~ztab2-zfield3
         where a~zfield4 = 'A'.
      No Separate selects please. Please help me in rewriting the same select statement itself.
    Regards,
    PSK

    hi,
    What error you are getting ?
    Also INTO is missing from the statement.
    SELECT  pcarrid pconnid ffldate bbookid
      INTO  TABLE itab
      FROM  ( spfli AS p
                INNER JOIN sflight AS f ON pcarrid = fcarrid AND
                                           pconnid = fconnid    )
      WHERE p~cityfrom = 'FRANKFURT' AND
            p~cityto   = 'NEW YORK' .
    thanks

  • How to use inner joins for 4 0r 5 tables

    Hai Experts,
    plz check my code, n plz help to inner join all the tables
    TYPES : BEGIN OF ITAB,
           EBELN TYPE EKKO-EBELN,            "P.O.NUMBER
           AEDAT TYPE EKKO-AEDAT,            "DATE
           BPRME TYPE EKPO-BPRME,            "UNIT PRICE
           MENGE TYPE EKPO-MENGE,            "Purchase order quantity
           WERKS TYPE EKPO-WERKS,            "PLANT
           BRTWR TYPE EKPO-BRTWR,            "Gross order value in PO
           STRAS TYPE LFA1-STRAS,            "House number and street
           LIFNR TYPE LFA1-LIFNR,            "VENDOR NO
           NAME1 TYPE LFA1-NAME1,            "V NAME
           ORT01 TYPE LFA1-ORT01,            "CITY
           LAND1 TYPE LFA1-LAND1,            "LAND
           PSTLZ TYPE LFA1-PSTLZ,             "POSTAL CODE
           MAKTX TYPE MAKT-MAKTX,            "DESCRIPTION
    END OF ITAB.
    <b>and i got stucked here:</b>
    <u></u>
    SELECT EKKO~EBELN
             EKKO~AEDAT
             EKPO~BPRME
             EKPO~MENGE
             EKPO~WERKS
             EKPO~BRTWR
             LFA1~LIFNR
             LFA1~STRAS
             LFA1~NAME1
             LFA1~ORT01
             LFA1~LAND1
             LFA1~PSTLZ
             MAKT~MAKTX
             INTO TABLE ITAB
             FROM EKKO
             INNER JOIN EKPO LFA1 T001W MAKT
             ON EKKOEBELN = EKPOEBELN
                EKKO~EBELN
             WHERE EKKO~EBELN IN S_EBELN.

    hi Rajesh,
    you have to join the tables one by one:
    SELECT ekko~ebeln
                 ekko~aedat
                 ekpo~bprme
                 ekpo~menge
                 ekpo~werks
                 ekpo~brtwr
                 lfa1~lifnr
                 lfa1~stras
                 lfa1~name1
                 lfa1~ort01
                 lfa1~land1
                 lfa1~pstlz
                 makt~maktx
    INTO TABLE itab
    FROM ekko AS ekko
    INNER JOIN ekpo AS ekpo
    ON ekkoebeln EQ ekpoebeln
    INNER JOIN lfa1 AS lfa1
    ON ekkolifnr EQ lfa1lifnr
    INNER JOIN t001w AS t001w
    ON ekpowerks EQ t001wwerks
    INNER JOIN makt AS makt
    ON ekpomatnr EQ MAKTmatnr
    WHERE ekko~ebeln IN s_ebeln.
    This is the complete SELECT. BUT! The performance will be much better if you take out T001W and MAKT from the INNER JOIN. Do select on these tables in separate steps and merge the internal tables afterwards.
    hope this helps
    ec

  • In which case i  want to use  inner join  &  for alll entries statement

    Dear all,
    In which scenario i want to use for all entries statement and in which scenario i want to use innerjoin operation in ABAP.
    please give me the solution.
    Regards
    syam

    Dear all,
    In which scenario i want to use for all entries statement and in which scenario i want to use innerjoin operation in ABAP.
    please give me the solution.
    Regards
    syam

  • Inner join for two tables

    Hello All
    i have these to tables
    country: name,population
    borders: country1,country2
    every country have some neghbors, in borders table,
    now i should calculate sum of pupulation of all neighbors of every country
    thank u so much for ur help
    I use oracle 11g
    best

    This is the SQL to create the table
    now i hope i will get an answer
    --  File created - Tuesday-April-30-2013  
    --  DDL for Table BORDERS
      CREATE TABLE "intern"."BORDERS" ("COUNTRY1" CHAR(2), "COUNTRY2" CHAR(2), "LENGTH" NUMBER)
       COMMENT ON COLUMN "intern"."BORDERS"."COUNTRY1" IS 'a country code'
       COMMENT ON COLUMN "intern"."BORDERS"."COUNTRY2" IS 'a country code'
       COMMENT ON COLUMN "intern"."BORDERS"."LENGTH" IS 'length of the border between country1 and country2'
       COMMENT ON TABLE "intern"."BORDERS"  IS 'informations about neighboring countries'
    REM INSERTING into intern.BORDERS
    SET DEFINE OFF;
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ad','es',63);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('md','ua',939);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mk','yu',221);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ml','mr',2237);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ml','ne',821);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ml','sn',419);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mm','th',1800);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mn','ru',3543);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mr','sn',813);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mw','mz',1569);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mw','tz',475);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mw','zm',837);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mx','us',3141);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('my','th',506);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','sz',105);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','tz',756);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','za',491);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','zm',419);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','zw',1231);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('na','za',967);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('na','zm',233);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ne','ng',1497);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ne','td',1175);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ng','td',87);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('no','ru',196);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('no','se',1619);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('om','sa',676);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('om','ye',288);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('pl','ru',206);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('pl','sk',444);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('pl','ua',526);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('qa','sa',60);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ro','ua',531);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ro','yu',476);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ru','ua',1576);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('rw','tz',217);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('rw','ug',169);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sa','ye',1458);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sd','td',1360);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sd','ug',435);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sk','ua',97);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sy','tr',822);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sz','za',430);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tj','uz',1161);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tm','uz',1621);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tz','ug',396);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tz','zm',338);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('za','zw',225);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('zm','zw',797);
    --  DDL for Index BORDERS_KEY
      CREATE UNIQUE INDEX "intern"."BORDERS_KEY" ON "intern"."BORDERS" ("COUNTRY1", "COUNTRY2")
    --  Constraints for Table BORDERS
      ALTER TABLE "intern"."BORDERS" ADD CONSTRAINT "BORDERS_KEY" PRIMARY KEY ("COUNTRY1", "COUNTRY2") ENABLE
      ALTER TABLE "intern"."BORDERS" ADD CONSTRAINT "BORDERS_LENGTH_CHECK" CHECK (
                 Length > 0
            ) ENABLE
    --  File created - Tuesday-April-30-2013  
    --  DDL for Table COUNTRY
      CREATE TABLE "intern"."COUNTRY" ("NAME" VARCHAR2(40), "CODE" CHAR(2), "CAPITAL" VARCHAR2(40), "PROVINCE" VARCHAR2(40), "POPULATION" NUMBER, "AREA" NUMBER)
       COMMENT ON COLUMN "intern"."COUNTRY"."NAME" IS 'the country name'
       COMMENT ON COLUMN "intern"."COUNTRY"."CODE" IS 'the internet country code (two letters)'
       COMMENT ON COLUMN "intern"."COUNTRY"."CAPITAL" IS 'the name of the capital'
       COMMENT ON COLUMN "intern"."COUNTRY"."PROVINCE" IS 'the province where the capital belongs to'
       COMMENT ON COLUMN "intern"."COUNTRY"."POPULATION" IS 'the population number'
       COMMENT ON COLUMN "intern"."COUNTRY"."AREA" IS 'the total area'
       COMMENT ON TABLE "intern"."COUNTRY"  IS 'the countries of the world with some data'
    REM INSERTING into intern.COUNTRY
    SET DEFINE OFF;
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Andorra','ad','Andorra la Vella','Andorra la Vella',69865,468);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('United Arab Emirates','ae','Abu Dhabi','Abu Dhabi',2523915,82880);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Afghanistan','af','Kabul','Kabul',28513677,647500);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Antigua and Barbuda','ag','Saint Johns','Saint John',68320,442.6);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Netherlands','nl','Amsterdam','Noord-Holland',16318199,41526);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Norway','no','Oslo','Akershus',4574560,324220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Nepal','np','Kathmandu','Kathmandu',27070666,140800);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Nauru','nr',null,null,12809,21);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Niue','nu',null,null,2156,260);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('New Zealand','nz','Wellington','Wellington',3993817,268680);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Oman','om','Muscat','Muscat',2903165,212460);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Panama','pa','Panama','Panama',3000463,78200);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Peru','pe','Lima','Lima y Callao',27544305,1285220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('French Polynesia','pf','Papeete','Iles du Vent',266339,4167);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Papua New Guinea','pg','Port Moresby','National Capital District',5420280,462840);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Philippines','ph','Manila','National Capital Region',86241697,300000);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Pakistan','pk','Islamabad','Federal Capital Area',159196336,803940);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Poland','pl','Warsaw','Mazowieckie',38626349,312685);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saint Pierre and Miquelon','pm','Saint-Pierre','Saint-Pierre',6995,242);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Pitcairn Islands','pn',null,null,46,47);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Puerto Rico','pr','San Juan','San Juan',3897960,9104);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Palestine','ps','Ramallah','Gaza Strip',3762005,6220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Portugal','pt','Lisbon','Lisboa e Vale do Tejo',10524145,92391);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Palau','pw','Koror','Koror',20016,458);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Paraguay','py','Asuncion','Asuncion',6191368,406750);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Qatar','qa','Doha','Doha',840290,11437);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Reunion','re','Saint-Denis','Saint-Denis',766153,2517);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Romania','ro','Bucharest','Bucharest',22355551,237500);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Russia','ru','Moscow','Moscow',143782338,17075200);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Rwanda','rw','Kigali','Ville de Kigali',7954013,26338);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saudi Arabia','sa','Riyadh','Riyadh',25795938,1960582);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Solomon Islands','sb','Honiara','Guadalcanal',523617,28450);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Seychelles','sc',null,null,80832,455);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sudan','sd','Khartoum','Khartoum',39148162,2505810);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sweden','se','Stockholm','Stockholm',8986400,449964);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Singapore','sg',null,null,4353893,692.7);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saint Helena','sh','Jamestown','Saint Helena',7415,410);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Slovenia','si','Ljubljana','Osrednjeslovenska',2011473,20273);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Svalbard','sj','Longyearbyen','Svalbard',2756,62049);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Slovakia','sk','Bratislava','Bratislavsky',5423567,48845);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sierra Leone','sl','Freetown','Western',5883889,71740);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('San Marino','sm','San Marino','San Marino',28503,61.2);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Senegal','sn','Dakar','Dakar',10852147,196190);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Somalia','so','Mogadishu','Banadir',8304601,637657);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Suriname','sr','Paramaribo','Paramaribo',436935,163270);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sao Tome and Principe','st','Sao Tome','Agua Grande',181565,1001);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('El Salvador','sv','San Salvador','San Salvador',6587541,21040);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Syria','sy','Damascus','Damascus',18016874,185180);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Swaziland','sz','Mbabane','Hhohho',1169241,17363);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Turks and Caicos Islands','tc',null,null,19956,430);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Chad','td','NDjamena','Chari-Baguirmi',9538544,1284000);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Togo','tg','Lome','Maritime',5556812,56785);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Thailand','th','Bangkok','Bangkok Metropolitan Area',64865523,514000);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tajikistan','tj','Dushanbe','Dushanbe',7011556,143100);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tokelau','tk',null,null,1405,10);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Turkmenistan','tm','Asgabat','Asgabat',4863169,488100);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tunisia','tn','Tunis','Tunis',9974722,163610);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tonga','to','Nukualofa','Tongatapu',110237,748);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('East Timor','tp','Dili','Dili',1019252,15007);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Turkey','tr','Ankara','Ankara',68893918,780580);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Trinidad and Tobago','tt','Port of Spain','Port of Spain',1096585,5128);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tuvalu','tv','Vaiaku','Funafuti',11468,26);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Taiwan','tw','Taipei','Taipei Hsien',22749838,35980);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tanzania','tz','Dar es Salaam','Dar es Salaam',36588225,945087);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Ukraine','ua','Kiev','Kiev',47732079,603700);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Uganda','ug','Kampala','Central',26404543,236040);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('United Kingdom','uk','London','England',60270708,244820);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('United States','us','Washington','District of Columbia',293027571,9631418);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Uruguay','uy','Montevideo','Montevideo',3399237,176220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Uzbekistan','uz','Tashkent','Tashkent',26410416,447400);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Holy See','va',null,null,921,0.44);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saint Vincent and the Grenadines','vc','Kingstown','Saint George',117193,389);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Venezuela','ve','Caracas','Distrito Capital',25017387,912050);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('British Virgin Islands','vg','Road Town','Tortola',22187,153);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Virgin Islands','vi','Charlotte Amalie','Saint Thomas',108775,352);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Vietnam','vn','Ha Noi','Dong Bang Song Hong',82689518,329560);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Vanuatu','vu','Vila','Shefa',202609,12200);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Wallis and Futuna','wf','Matautu','Hahake',15880,274);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Samoa','ws','Apia','Apia Urban Area',177714,2944);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Yemen','ye','Sana','Amanah al-Asmah',20024867,527970);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Mayotte','yt','Mamoudzou','Mayotte',186026,374);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Serbia and Montenegro','yu','Belgrade','Central Serbia',10825900,102350);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('South Africa','za','Pretoria','Gauteng',42718530,1219912);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Zambia','zm','Lusaka','Lusaka',10462436,752614);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Zimbabwe','zw','Harare','Harare',12671860,390580);
    --  DDL for Index COUNTRY_KEY
      CREATE UNIQUE INDEX "intern"."COUNTRY_KEY" ON "intern"."COUNTRY" ("CODE")
    --  DDL for Index COUNTRY_NAME_UNIQUE
      CREATE UNIQUE INDEX "intern"."COUNTRY_NAME_UNIQUE" ON "intern"."COUNTRY" ("NAME")
    --  Constraints for Table COUNTRY
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_AREA_CHECK" CHECK (
                 Area >= 0
            ) ENABLE
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_KEY" PRIMARY KEY ("CODE") ENABLE
      ALTER TABLE "intern"."COUNTRY" MODIFY ("NAME" CONSTRAINT "COUNTRY_NAME_NOTNULL" NOT NULL ENABLE)
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_NAME_UNIQUE" UNIQUE ("NAME") ENABLE
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_POPULATION_CHECK" CHECK (
                 Population >= 0
            ) ENABLE

  • Inner join with for-all entries

    Why is the below inner join-for all entries does not result in expected output ?
    REPORT  ZTST3                                   .
    tables : ztst1,ztst2 .
    * table ztst1 has 4 fields : mandt,ebeln,ebelp,etenr,char4. ; ztst2 has
    * 3 fields : mandt,ebeln,ebelp,matnr
    *Entries in ztst1
    * EBELN       EBELP   ETERN  CHAR4
    * 5000000000  00010    0001    abc
    * 5000000000  00010    0002    cbd
    * 5000000000  00010    0003    efg
    *Entries in ztst2
    * EBELN       EBELP   matnr
    * 5000000000  00010    matabc
    *expected itab after inner join
    * EBELN       EBELP   CHAR4  MAtnr
    * 5000000000  00010   abc    matabc
    * 5000000000  00010   cbd    matabc
    * 5000000000  00010   efg    matabc
    data : begin of itab1 occurs 0,
           ebeln type ebeln,
           ebelp type ebelp,
           end of itab1.
    data : begin of itab occurs 0,
           ebeln type ebeln,
           ebelp type ebelp,
           char4 type char4,
           matnr type matnr,
           end of itab.
    start-of-selection.
    itab1-ebeln = '5000000000'.
    itab1-ebelp = '00010'.
    append itab1.
    select ztst1~ebeln
           ztst1~ebelp
           ztst1~char4
           ztst2~matnr into corresponding fields of table itab
    from ztst1 inner join ztst2
    on ztst1~ebeln = ztst2~ebeln and
       ztst1~ebeln = ztst2~ebelp
    for all entries in itab1
    where
    ztst1~ebeln eq itab1-ebeln and
    ztst1~ebelp eq itab1-ebelp .
    * why does it return no entries;
    break-point.

    For example in the bellow case
    *Entries in ztst1
    EBELN       EBELP   ETERN  CHAR4
    5000000000  00010    0001    abc
    5000000000  00010    0002    cbd
    5000000000  00010    0003    efg
    5000000002  00020    0003    efg
    5000000002  00020    0003    efg
    *Entries in ztst2
    EBELN       EBELP   matnr
    5000000000  00010    matabc
    5000000002  00020    abc
    may it will return you 2 records yes, than I think you have under stand the working of u201Cfor all entriesu201D ?
    And the following case I think it will work fine.
    *Entries in ztst1
    key  EBELN       EBELP   ETERN  CHAR4
    1       5000000000  00010    0001    abc
    2       5000000000  00010    0002    cbd
    3       5000000000  00010    0003    efg
    4       5000000002  00020    0003    efg
    5       5000000002  00020    0003    efg
    *Entries in ztst2
    EBELN       EBELP   matnr
    5000000000  00010    matabc
    5000000002  00020    abc
    select  ztst1~key
    ztst1~ebeln
           ztst1~ebelp
           ztst1~char4
           ztst2~matnr into corresponding fields of table itab
    from ztst1 inner join ztst2
    on ztst1~ebeln = ztst2~ebeln and
       ztst1~ebelp = ztst2~ebelp
    for all entries in itab1
    where
    ztst1~ebeln eq itab1-ebeln and
    ztst1~ebelp eq itab1-ebelp .
    Sorry, I donu2019t have system with me right now and I am sending you with out testing but I am sure that it is working the same way.
    Please Reply if any problem
    Kind Regards,
    Faisal

  • Inner join Vs For all entries

    Hi Expert,
    Could you please help me in this inner join , Inner join is performance wise is not good so i want to replace instated of inner join for all entries. But when i am checking  records of internal table there is difference. in inner join i am getting 11 records but for all entries i am getting  5 records .
    Please help me out where excatly i have done mistake.
    SELECT maralvorm maramatkl
            maramatnr marameins
            maraprdha maraspart
            marcausss marcbearz
            marcbeskz marcbstmi
            marc~wzeit                                       
            marcdisgr marcmaabc                             *         marcdismm marcdispo
            marcdispr marcdzeit
            marcplifz marcdisls
            marcbstma marcbstrf
            marc~basmg                                    
            marceisbe marcfevor
            marcfxhor marclvorm
            marcmatnr marcmmsta
            marcprctr marcsobsl
            marctranz marcwerks
            marc~xchar                                        
            marclgpro marcfhori
            marc~rgekz                                      
            mbewbklas mbewbwkey
            mbewlbkum mbewsalk3
            mbewmatnr mbewpeinh
            mbewstprs maktmaktx
            maktmatnr cepcabtei
            cepc~prctr
            marcschgt marcminbe
            marc~ekgrp
            marc~eprio                              
            marc~kausf                                        
            marc~shflg                                      
            marc~shzet                                       
            marc~fabkz
            marc~lgrad
            marc~shpro
            marc~eislo
            marc~rwpro
            marc~lgfsb
            marczzfdwe marczzfdwi                
            marczzsspe marczzsspi              
    INTO TABLE i_matl
    FROM ( mara
          INNER JOIN marc
          ON marcmatnr = maramatnr
          INNER JOIN mbew
          ON mbewmatnr = marcmatnr
          AND mbewbwkey = marcwerks
          INNER JOIN makt
          ON maktmatnr = maramatnr
          INNER JOIN cepc
          ON cepcprctr = marcprctr
          AND cepcdatbi >= sy-datum )               "*       WHERE maralvorm IN sp$00094
            AND mara~matkl IN sp$00084
            AND mara~meins IN sp$00091
            AND mara~prdha IN sp$00066
            AND mara~spart IN sp$00085
            AND marc~disgr IN sp$00089
            AND marc~dismm IN sp$00067
            AND marc~dispo IN sp$00061
            AND marc~dispr IN sp$00083
            AND marc~fevor IN sp$00090
            AND marc~lvorm IN sp$00092
            AND marc~mmsta IN sp$00086
            AND marc~beskz IN s_beskz
            AND marc~sobsl IN sp$00068
            AND marc~werks IN sp$00062
            AND marc~xchar IN sp$00093
            AND marc~maabc IN sp$00099                        
            AND marc~lgrad IN s_lgrad
            AND marc~lgpro IN s_lgpro
            AND marc~rwpro IN s_rwpro               
            AND marc~lgfsb IN s_lgfsb
             AND marc~schgt INs_schgt                          *         AND marc~shflg IN s_shflg
            AND marc~shzet IN s_shzet                
            AND marc~fabkz IN s_fabkz                    
            AND marc~shpro IN s_shpro                
            AND marc~eislo IN s_eislo               
            AND marc~zzfdwe IN s_zzfdwe                          
            AND marc~zzfdwi IN s_zzfdwi              
            AND marc~zzsspe IN s_zzsspe
            AND marc~zzsspi IN s_zzsspi
            AND mbew~bklas IN sp$00063
            AND mbew~lbkum IN sp$00088
            AND makt~maktx IN sp$00059
            AND makt~spras = c_en
            AND makt~matnr IN sp$00060
            AND cepc~prctr IN sp$00087.
    I am using for all entries
    fetching data from  marc data base table
      SELECT matnr werks lvorm  xchar mmsta
          maabc  ekgrp dispr dismm
          dispo plifz ausss disls
          beskz sobsl minbe eisbe
          bstmi bstma bstrf fhori
          rgekz fevor bearz tranz
          basmg dzeit wzeit lgrad
          prctr fxhor lgpro disgr
          kausf rwpro lgfsb schgt
          eprio shflg shzet fabkz
          shpro eislo zzfdwe zzfdwi
          zzsspe zzsspi
          FROM marc  INTO  TABLE i_marc
          WHERE  werks IN sp$00062
              AND lvorm IN sp$00092
              AND xchar IN sp$00093
              AND mmsta IN sp$00086
              AND maabc IN sp$00099
              AND dispr IN sp$00083
              AND dismm IN sp$00067
              AND dispo IN sp$00061
              AND beskz IN s_beskz
              AND sobsl IN sp$00068
              AND fevor IN sp$00090
              AND lgrad IN s_lgrad
              AND lgpro IN s_lgpro
              AND disgr IN sp$00089
              AND rwpro IN s_rwpro
              AND lgfsb IN s_lgfsb
              AND schgt IN s_schgt
              AND shflg IN s_shflg
              AND shzet IN s_shzet                
              AND fabkz IN s_fabkz                    
              AND shpro IN s_shpro                
              AND eislo IN s_eislo               
              AND zzfdwe IN s_zzfdwe                          
              AND zzfdwi IN s_zzfdwi              
              AND zzsspe IN s_zzsspe
              AND zzsspi IN s_zzsspi.
      IF sy-subrc EQ 0.
        SORT i_marc BY matnr werks.
      ENDIF.
    DELETE ADJACENT DUPLICATES FROM i_marc comparing matnr werks.
    *fetching data from mara data base table
      IF  NOT i_marc[] IS  INITIAL.
        SELECT matnr lvorm  matkl
               meins spart prdha
            FROM mara INTO TABLE i_mara
            FOR ALL ENTRIES IN i_marc
             WHERE matnr = i_marc-matnr
             AND   lvorm IN sp$00094
             AND   matkl IN sp$00084
             AND   meins IN sp$00091
             AND   prdha IN sp$00066
             AND   spart IN sp$00085.
      ENDIF.
      IF sy-subrc EQ 0.
        SORT i_mara BY matnr.
      ENDIF.
    DELETE ADJACENT DUPLICATES FROM i_mara comparing matnr.
    *fetching data from mbew data base table
      IF  NOT i_mara[] IS  INITIAL.
        SELECT matnr bwkey  bwtar lbkum
               salk3 stprs peinh bklas
               FROM mbew  INTO TABLE i_mbew
               FOR ALL ENTRIES IN i_marc
               WHERE matnr = i_marc-matnr
                    AND bwkey = i_marc-werks
                    AND bklas IN sp$00063
                    AND lbkum IN sp$00088.
      ENDIF.
      IF sy-subrc EQ 0.
        SORT i_mbew BY matnr bwkey bwtar.
      ENDIF.
    *DELETE ADJACENT DUPLICATES FROM i_mbew comparing  matnr bwkey bwtar.
    *fetching data from  makt data base  table
      IF NOT i_mara[] IS INITIAL.
        SELECT matnr spras maktx
          FROM makt INTO TABLE i_makt
          FOR ALL ENTRIES IN i_mara
          WHERE matnr = i_mara-matnr
           AND maktx IN sp$00059
           AND makt~spras = c_en.
      ENDIF.
      IF sy-subrc EQ 0.
        SORT i_makt BY matnr spras.
      ENDIF.
    DELETE ADJACENT DUPLICATES FROM i_makt.
    *fetching data from cpec data base table
      IF NOT i_marc[] IS INITIAL.
        SELECT prctr  datbi kokrs abtei
            FROM cepc INTO TABLE i_cepc
            FOR ALL ENTRIES IN i_marc
            WHERE prctr = i_marc-prctr
                 AND prctr IN sp$00087
                 AND datbi >= sy-datum.
      ENDIF.
      IF sy-subrc EQ 0.
        SORT i_cepc BY prctr datbi kokrs.
      ENDIF.
    *DELETE ADJACENT DUPLICATES FROM i_cepc.
    LOOP AT i_cepc INTO wa_cpec.
    read table i_marc into wa_marc with key
                       prctr = wa_cpec-prctr binary search.
       if sy-subrc = 0.
        i_matl-abtei  = wa_cpec-abtei.
        i_matl-prctr1 = wa_cpec-prctr.
        i_matl-ausss =  wa_marc-ausss.
        i_matl-bearz =  wa_marc-bearz.
        i_matl-beskz =  wa_marc-beskz.
        i_matl-bstmi =  wa_marc-bstmi.
        i_matl-wzeit =  wa_marc-wzeit.
        i_matl-disgr =  wa_marc-disgr.
        i_matl-maabc =  wa_marc-maabc.
        i_matl-dismm =  wa_marc-dismm.
        i_matl-dispo =  wa_marc-dispo.
        i_matl-dispr =  wa_marc-dispr.
        i_matl-dzeit =  wa_marc-dzeit.
        i_matl-plifz =  wa_marc-plifz.
        i_matl-disls =  wa_marc-disls.
        i_matl-bstma =  wa_marc-bstma.
        i_matl-bstrf =  wa_marc-bstrf.
        i_matl-basmg =  wa_marc-basmg.
        i_matl-eisbe =  wa_marc-eisbe.
        i_matl-fevor =  wa_marc-fevor.
        i_matl-fxhor =  wa_marc-fxhor.
        i_matl-lvorm1 = wa_marc-fevor.
        i_matl-matnr1 = wa_marc-matnr.
        i_matl-mmsta = wa_marc-mmsta.
        i_matl-prctr = wa_marc-prctr.
        i_matl-sobsl = wa_marc-sobsl.
        i_matl-tranz = wa_marc-tranz.
        i_matl-werks = wa_marc-werks.
        i_matl-xchar = wa_marc-xchar.
        i_matl-lgpro = wa_marc-lgpro.
        i_matl-fhori = wa_marc-fhori.
        i_matl-rgekz = wa_marc-rgekz.
        i_matl-schgt  = wa_marc-schgt.
        i_matl-minbe  = wa_marc-minbe.
        i_matl-ekgrp  = wa_marc-ekgrp.
        i_matl-eprio  = wa_marc-eprio.
        i_matl-kausf  = wa_marc-kausf.
        i_matl-shflg  = wa_marc-shflg.
        i_matl-shzet  = wa_marc-shzet.
        i_matl-fabkz  = wa_marc-fabkz.
        i_matl-lgrad  = wa_marc-lgrad.
        i_matl-shpro  = wa_marc-shpro.
        i_matl-eislo  = wa_marc-eislo.
        i_matl-rwpro  = wa_marc-rwpro.
        i_matl-lgfsb  = wa_marc-lgfsb.
        i_matl-zzfdwe = wa_marc-zzfdwe.
        i_matl-zzfdwi = wa_marc-zzfdwi.
        i_matl-zzsspe = wa_marc-zzsspe.
        i_matl-zzsspi = wa_marc-zzsspi.
    endif.
        READ  TABLE i_mara INTO wa_mara WITH KEY
                            matnr = wa_marc-matnr  binary search.
        i_matl-lvorm =  wa_mara-lvorm.
        i_matl-matkl =  wa_mara-matkl.
        i_matl-matnr =  wa_mara-matnr.
        i_matl-meins =  wa_mara-meins.
        i_matl-prdha =  wa_mara-prdha.
        i_matl-spart =  wa_mara-spart.
        READ TABLE  i_makt INTO wa_makt WITH KEY
                            matnr = wa_mara-matnr binary search.
        i_matl-matnr3 = wa_makt-matnr.
        i_matl-maktx = wa_makt-maktx.
        READ TABLE i_mbew INTO wa_mbew WITH  KEY
                              matnr = wa_marc-matnr binary search.
        i_matl-bklas = wa_mbew-bklas.
        i_matl-bwkey = wa_mbew-bwkey.
        i_matl-lbkum = wa_mbew-lbkum.
        i_matl-salk3 = wa_mbew-salk3.
        i_matl-matnr2 = wa_mbew-matnr.
        i_matl-peinh  = wa_mbew-peinh.
        i_matl-stprs = wa_mbew-stprs.
       READ TABLE i_cepc INTO wa_cpec WITH KEY
                             prctr = wa_marc-prctr.
        APPEND  i_matl.
        CLEAR: wa_cpec, wa_mbew, wa_mara, wa_marc.
      ENDLOOP.
    Thaks
    Waiting your reply.

    Hi Sasmita,
    I think your final loop is the problem. As you are looping through the CEPC internal table, and reading the other tables. For different materials there might be a same profit center, the read table will fetch you only first occurance of the profit center from the mara or marc table.
    So loop through either mara or marc table and read the remaining and populate your final internal tables. This might solve your problem.
    Regards,
    Ramesh Babu S
    *Reward points if it is helpful....

  • Inner join Vs for all entries for performance

    hi,
        i need to fetch data from 5 tables where i have common key vbeln, is this suggestable to write a select query with inner join or write an inner join for 2 tables with more fileds and for remaining using for all entries.... please suggest how can i increase the performance...all points are rewarded....
    thnaks alot.

    Is this a dialog program or a data extract? Rob is right in that the difference is negligible IF the number of records involved are only a few.
    On the other hand, if you are extracting a large number of records, then the performance depends on a number of things and is generally unpredictable.
    The way I approach it is by first developing the extract program with a join because it is easier to code. If the program run time is within the acceptable range, I would let it be and migrate to production. If the performance is of high priority and if the join appears to take long time, then I will comment out the code and try the FAE approach. If the run time with FAE is not markedly better, then I would go back to join.

  • Inner join and outer  join in infosets

    hi everyone,
    i have a doubt in infosets...
    when and why we use inner and outer joins(right outer join and left outer join) for infoset
    please give a real time scenario........
    Thanks in advance.
    Bye.

    Hello,
    Inner join:
    For example, the requirement is to show all sales documents where you have delivery exists. In this case, you join both sales ods and delivery ods in a infoset as inner join. This will match the record against the reference documents and pull only matched records.  
    Outer Join:
    Suppose you want to pull all billing/invoice details along with their FI documents related data in a report. Assume that always there might be a situation that invoice exists but not posted to FI, however, you want to have all billing documents details either it has FI document or not. In this case, you link both Billing data and FI document data in a outer join.  This will pull all invoices data either FI document exists or not.   Other words, you want to show one side of data always but adding additional details from differenent source if data exists.
    Hope, it clarifies your doubt. Let me know if any questions.
    Thanks
    Viswa

  • Inner join on four tables

    hi all,
    i am facing the problem with the inner join in the select query for 4 tables.
    can i use the inner join for tables in SAP 6.0 version,
    it is going to dump.
    here is my code
    SELECT DISTINCT apernr abegda aendda awagetype aamount acurrency
            altrctry brufnm banred bvorna bnachn cgroupcode d~vdsk1
    FROM pa9011 AS a INNER JOIN pa0002 AS b ON bpernr = apernr
                      INNER JOIN pa9013 AS c ON cpernr = bpernr
                      inner join pa0001 as d on dpernr = cpernr
                      INTO CORRESPONDING FIELDS OF TABLE it_bonus
    WHERE a~pernr IN s_pernr AND
           a~begda IN s_date AND
           a~subty EQ s_subty AND
           a~wagetype EQ wa_perbonus AND
           a~ltrctry = gc_ind AND
           a~amount > 0 AND
           b~endda = '99991231' AND
           c~groupcode IN s_loc AND
           c~endda = '99991231' and
           d~endda = '99991231'
        ORDER BY a~pernr.

    hi this is the dump ,
    In a SELECT access, the read file could not be placed in the target
    field provided.
    Either the conversion is not supported for the type of the target field,
    the target field is too small to include the value, or the data does not
    have the format required for the target field.

Maybe you are looking for

  • Installing 12.1.1 upgrade driver, sess disconnected & now adpatch fails

    We are upgrading EBS HRMS QA instance from 11.5.10.2 to 12.1.1 in hrdev (10.37.2.4) machine. ================================================= I had a telnet session from my desktop machine to the AIX 6.1 server machine. While Installing 12.1.1 upgra

  • Where can I download Firefox 17.0.8esr for Solaris 10 (SPARC)?

    I need to upgrade from 17.0.7esr to 17.0.8esr on Solaris 10 (SPARC) servers. For some reason there is no /contrib/ folder under http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/17.0.8esr/ That is where I normally find the Solaris tarball I nee

  • JSP Variable Passing

    I have a jsp page which lists several links on it.  When the user clicks a link it fires an event which should set some bean variables based on which link the user selected.  However I am new to java and unsure how it will know what link was selected

  • I cannot install my copy of Photoshop elements on my new PC with windows 8, it wasOK with Windows7

    I cannot install my copy of Photoshop elements on my new PC with windows 8, it was OK with Windows 7. Can I get an update for this? BizRit

  • Reporting(ods to cube data)

    hi friends, i have 3 recodrs , i loaded from flat file to ods again i loaded ods to cube. now i added 1 record in flat file. first i had sent delta to ods, again i had sent to cube. so in cube first 3 records and 1 recoprd delta. if i will go to rrmx