Inner join on internal table

HI all,
How to access data from two internal table using join condition ?
suppose i have tow internal table itab and jtab and i want to access data by using inner join on this tow table.
please tell .
thanx..

hi,
You can use PROVIDE ENDPROVIDE statements in ABAP to achive this.
Check the below documenttaion.
PROVIDE
Syntax
PROVIDE FIELDS {*|{comp1 comp2 ...}}
               FROM itab1 INTO wa1 VALID flag1
               BOUNDS intliml1 AND intlimu1
               [WHERE log_exp1]
        FIELDS {*|{comp1 comp2 ...}}
               FROM itab2 INTO wa2 VALID flag2
               BOUNDS intliml2 AND intlimu2
               [WHERE log_exp2]
        BETWEEN extliml AND extlimu
        [INCLUDING GAPS].
ENDPROVIDE.
Effect
The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables itab1 itab2 ... are processed together. A single table can appear several times. For every table itab you must specify a FIELDS clause. After FIELDS you must specify the character * for all components or a list comp1 comp2 ... for specific components of the relevant table. The names of the components comp1 comp2 ... can only be specified directly.
To be able to process internal tables using PROVIDE, all tables itab1 itab2 ... must be fully typed index tables and contain two special columns that have the same data type (d, i, n, or t) for all relevant tables. For every table you must specify the names intliml1 intliml2 ... and intlimu1 intlimu2 ... of these columns using the addition BOUNDS.
The columns intliml1 intliml2 ... and intlimu1 intlimu2 ... in every row of the relevant internal tables must contain values that can be interpreted as limits of closed intervals. Within a table, the intervals specified in these columns must not overlap and must be sorted in ascending order. The intervals therefore make up a unique key for every row.
For every table you must specify a work area wa1 wa2 ... compatible with the row type and a variable flag1 flag2 ..., for which a character-type data type with length 1 is expected. In the PROVIDE loop, the components specified after FIELDS are filled with values in the relevant work areas wa1 wa2 ... for every specified internal table. The variables flag1 flag2 ... are also filled. A work area wa1 wa2 ... or a variable flag1 flag2 ... cannot be specified more than once.
With the BETWEEN addition you must specify an interval extliml, extlimu. It must be possible to convert the data objects extliml and extlimu into the data types of the respective columns intliml1 intliml2 ... and intlimu1 intlimu2 ... of the individual tables.
The interval limits intliml1 intliml2 ... and intlimu1 intlim2 for every row of all relevant internal tables itab1 itab2 ... that are within the closed interval made up by extliml and extlimu divide the latter into new intervals and every interval limit closes one interval in the original direction. If, within a relevant table, a lower interval limit follows an upper interval limit with no space or gap between them and the components of the corresponding rows specified after FIELDS have the same content, the two intervals are combined and the corresponding interval limits intliml1 intliml2 ... and intlimu1 intlimu2 ... are ignored for the new intervals.
For every interval that is created in such a way and overlaps with at least one of the intervals of a table involved, the PROVIDE loop is passed once. The components of every work area wa1 wa2 ... specified after FIELDS and the variables flag1 flag2 ... are filled with values as follows:
The components intliml1 intliml2 ... and intlimu1 intlimu2 ... of every work area wa1 wa2 ... are filled with the interval limits of the current interval.
If the current interval overlaps with one of the intervals of an involved table, the remaining components of the corresponding work area are assigned the contents of the relevant components of this table row and the variable flag1 flag2 ... is set to the value "X". Otherwise, the work area components and the variables flag1 flag2 ... are set to their Initial value.
Except for intliml1 intliml2 ... and intlimu1 intlimu2 ..., the components not specified after FIELDS are always set to their initial value. The components intliml1 intliml2 ... and intlimu1 intlimu2 ... are always assigned.
The ABAP runtime environment checks for every table involved, whether the condition of sorted and non-overlapping intervals is met within the interval made up by extliml and extlimu and, if necessary, triggers an exception that can be handled.
If the INCLUDING GAPS addition is specified, the system passes the PROVIDE loop for every interval, that is also when the current interval does not overlap with at least one of the intervals of an involved table. In the latter case, the variable flag is of initial value for every relevant table.
You can use the WHERE addition to specify a condition for every table itab1 itab2 ... involved. After WHERE, you can specify any logical expression log_exp1 log_exp2 ... ; the first operand of every comparison must be a component of the internal table. As such, all logical expressions except for IS ASSIGNED, IS REQUESTED, and IS SUPPLIED are possible. You can only specify components that are in the list after FIELDS. Here it is not possible to specify a component using character-type data objects in brackets. The table entries for which the condition is not met are ignored by the PROVIDE loop. You can leave the PROVIDE loop following the instructions in the section Leaving loops.
System fields
The system fields sy-subrc and sy-tabix are set to the value 0 before every loop pass and at ENDPROVIDE. Only if the loop is not passed once, is sy-subrc set to 4 at ENDPROVIDE.
Notes
The relevant internal tables should not be modified in the PROVIDE loop.
The WHERE condition can be used to remove overlaps between the tables involved or to ensure the sorting of the intervals.
In two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
|01|02|03|04|05|06|07|08|09|10|11|12|13|14|
|   Itab1 Int1    |     |Itab1 Int2 |     |
|        |      Itab2 Int1       |        |
|  |          ... BETWEEN ...             |
|  | i1  |   i2   | i3  |   i4   |i5|     |
The interval specified in the BETWEEN addition to the PROVIDE statement is shown in the fourth row. It serves as a basis for the five intervals in the fifth row represented by i1 to i5. These can be processed in the PROVIDE loop.
Because each of the five intervals overlaps with one of the intervals from rows two and three, the PROVIDE loop is passed five times.
Only the component col3 of wa1 is filled in the first pass, only the component col3 of wa2 in the third pass, and the components col3 of both work areas in the second and fourth passes. The fields valid1 and valid2 are set accordingly.
DATA: BEGIN OF wa1,
        col1 TYPE i,
        col2 TYPE i,
        col3 TYPE string,
      END OF wa1.
DATA: BEGIN OF wa2,
        col1 TYPE i,
        col2 TYPE i,
        col3 TYPE string,
      END OF wa2.
DATA: itab1 LIKE STANDARD TABLE OF wa1,
      itab2 LIKE STANDARD TABLE OF wa2.
DATA: flag1(1) TYPE c,
      flag2(1) TYPE c.
wa1-col1 = 1.
wa1-col2 = 6.
wa1-col3 = 'Itab1 Int1'.
APPEND wa1 TO itab1.
wa1-col1 = 9.
wa1-col2 = 12.
wa1-col3 = 'Itab1 Int2'.
APPEND wa1 TO itab1.
wa2-col1 = 4.
wa2-col2 = 11.
wa2-col3 = 'Itab2 Int1'.
PROVIDE FIELDS col3 FROM itab1 INTO wa1
                               VALID flag1
                               BOUNDS col1 AND col2
        FIELDS col3 FROM itab2 INTO wa2
                               VALID flag2
                               BOUNDS col1 AND col2
        BETWEEN 2 AND 14.
  WRITE: / wa1-col1, wa1-col2, wa1-col3, flag1.
  WRITE: / wa2-col1, wa2-col2, wa2-col3, flag2.
  SKIP.
ENDPROVIDE.
The list output is as follows:
   2           3  Itab1 Int1 X
   2           3
   4           6  Itab1 Int1 X
   4           6  Itab2 Int1 X
   7           8
   7           8  Itab2 Int1 X
   9          11  Itab1 Int2 X
   9          11  Itab2 Int1 X
  12          12  Itab1 Int2 X
  12          12
Exceptions
Catchable Exceptions
CX_SY_PROVIDE_INTERVAL_OVERLAP
Cause: In one of the involved tables there are overlapping intervals within extlim1 and extlim2.
Runtime Error: UNCAUGHT_EXCEPTION
CX_SY_PROVIDE_TABLE_NOT_SORTED
Cause: One of the involved tables is not sorted in ascending order by the intervals within extlim1 and extlim2.
Runtime Error: UNCAUGHT_EXCEPTION
Edited by: Velangini Showry Maria Kumar Bandanadham on Apr 28, 2008 1:36 PM

Similar Messages

  • Join on Internal tables

    Hello ppl,
    I have 2 internal tables.
    I want to write a select query to select 2 fields from one internal table and 1 field from another internal table.
    These 3 fields will be selected in a third internal table.
    Fields to be selected: gt_mast-matnr
                                    gt_mast-werks
                                    gt_afko-aufld
    Into internal table gt_csbe.
    How to achieve this?
    Please help.
    Thanks,
    David.

    Hi,
    It can achieved by using Inner Join.
    Refer the sample code for using Inner Join:
    Inner joins using 3 tables 
    Try this :-
    SELECT stpo~stlnr stpo~idnrk mast~matnr mara~mtart stpo~menge 
    INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast 
    JOIN stpo ON stpo~stlnr = mast~stlnr 
    JOIN mara ON mara~matnr = mast~matnr 
    WHERE stpo~stlty = 'M' "AND stpo~idnrk IN s_matnr 
    AND mast~werks = 1000. 
    Here s_matnr is a select-options on the selection-screen. 
    Or this. 
         Select single Vbrk~Bukrs Vbrk~Kunrg    Vbrk~Vbeln 
                       Vbrk~Fkdat Vbrk~Bstnk_Vf Vbrk~Zterm 
                       Tvzbt~Vtext 
                       Vbak~Vbeln Vbak~Bstdk 
                       Likp~Vbeln Likp~lfdat    Likp~Lfuhr 
           into w_vbrk 
           from vbrk 
          inner join       Tvzbt on Tvzbt~Zterm        = Vbrk~Zterm      and 
                                    Tvzbt~Spras        = sy-langu 
          Inner join       Vbfa  as SalesLnk 
                                 on SalesLnk~vbeln     = pu_vbeln        and 
                                    SalesLnk~vbtyp_v   = c_order 
                inner join Vbak  on Vbak~Vbeln           = SalesLnk~Vbelv
          Inner join       Vbfa  as DeliveryLnk 
                                 on DeliveryLnk~vbeln   = pu_vbeln       and 
                                    DeliveryLnk~vbtyp_v = c_Delivery 
                inner join Likp  on Likp~Vbeln          = DeliveryLnk~Vbelv 
          where vbrk~vbeln = pu_Vbeln. 
    This code locates sales, delivery and payment terms info from a billing document number. 
    or
    Here, this one also works fine :
    select zfpcd~cadivi zfpcd~proforma zfpcd~factura zfpcd~aniofactura 
    zfpcd~montousd zfpcd~montoap zfpcd~ebeln zfpcd~inco1 
    zfpcd~lifnr lfa1~name1 zcdvs~status zfpcd~conint 
    into it_lista 
    from zfpcd inner join zcdvs 
    on zfpcd~ebeln = zcdvs~ebeln 
    and zfpcd~proforma = zcdvs~proforma 
    and zfpcd~lifnr = zcdvs~lifnr 
    inner join lfa1 
    on zfpcd~lifnr = lfa1~lifnr 
    where zcdvs~status = '04'. 
    <REMOVED BY MODERATOR>
    Cheers,
    Chandra Sekhar.
    Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:43 PM

  • Inner join on Buffred table and not buffered table.

    Hi guys,
       Can you suggest me how can i write select query using inner join on buffered table and not buffered table. i written like this. is it right?
    SELECT a~vbeln                         
             a~vkorg   
             a~kunnr                         
             a~kunag                         
             a~wadat_ist 
             a~xblnr                         
             b~bukrs
       FROM likp AS a INNER JOIN tvko AS b
        ON avkorg = bvkorg BYPASSING BUFFER
      INTO TABLE itab_likp
      WHERE vbeln = s_vbeln.              
    Thanks.
    RAJ

    Hi Raj ,
    Please find below my Commentes :
    1. When you use "Bypassing buffer" clause in Select statement , the data what is there in the buffer of application sever is always ignored and Read is performed from the Physical database always. This Clause is advisable where you require realtime data (Not recommended generally in reporting)
    2. It is advisable that you should not use small table in the innerjoin with big table. In the query you have written there are 2 tables:- LIKP and TVKO outof which TVKO is a master table containing very few records than LIKP (Contains huge data for Delivery header).
    So my recommendation will be : -
    1. Eliminate the "Bypassing Buffer" clause from your Query
    2. Break the select query into 2 select queries breaking the join and with some ABAP logic populate the Internal table "itab_likp".
    This will be optimum way inwhich you can write the select query for your senarion. Also Ensure that indexes are being used for better selectivity.
    Hope this will help to you.
    Regards,
    Nikhil

  • How to join two internal table rows in alternative manner into one internal table?

    How to join two internal table rows in alternative manner into one internal table?
    two internal tables are suppose itab1 &  itab2 & its data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    d
    e
    f
    g
    h
    i
    Header 1
    Header 2
    Header 3
    1
    2
    3
    4
    5
    6
    7
    8
    9
    INTO itab3 data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    1
    2
    3
    d
    e
    f
    4
    5
    6
    g
    h
    i
    7
    8
    9

    Hi Soubhik,
    I have added two additional columns for each internal table.
    Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
    Row_Count  - It represents the Row Count Number, increase the row count value 1 by one..
    ITAB1:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    a
    b
    c
    1
    1
    d
    e
    f
    1
    2
    g
    h
    i
    1
    3
    ITAB2:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    1
    2
    3
    2
    1
    4
    5
    6
    2
    2
    7
    8
    9
    2
    3
    Create the Final Internal table as same as the ITAB1/ITAB2 structure.
    "Data Declarations
    DATA: IT_FINAL LIKE TABLE OF ITAB1.          "Final Internal Table
    FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1,     "TAB1
                                   <FS_TAB2> TYPE TY_TAB2.     "TAB2
    "Assign the values for the additional two column for ITAB1
    LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
         <FS_TAB1>-TABLE_COUNT = 1.             "Table value same for all row
         <FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
    ENDLOOP.
    "Assign the values for the additional two column for ITAB2
    LOOP AT ITAB2 ASSIGNING <FS_TAB2>.    
         <FS_TAB2>-TABLE_COUNT = 2.                  "Table value same for all row
         <FS_TAB2>-ROW_COUNT = SY-TABIX.      "Index value
    ENDLOOP.
    "Copy the First Internal Table 'ITAB1' to Final Table
    IT_FINAL[] = ITAB1[].
    "Copy the Second Internal Table 'ITAB2' to Final Table
    APPEND IT
    LOOP AT ITAB2 INTO WA_TAB2.
    APPEND WA_TAB2 TO IT_FINAL.
    ENDLOOP.
    "Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
    SORT IT_FINAL BY  ROW_COUNT TABLE_COUNT.
    After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
    Regards
    Rajkumar Narasimman

  • Join 2 internal tables

    Hello,
    i have to join the whole content of a table with the content of a aggregated table. i "moved" the content of the 2 dictionary tables into 2 internal tables and i want to join these 2 internal tables now.
    first of all, is it generally possible to join 2 internal tables, for example with a read or loop statement?!
    at second, i know how i would solve the problem in oracle 10g, but it looks like that open-sql supports not the same features like orcale. knows anyone of you how i can rebuild the following oracle statement in abap.
    select a.id, a.col1, b.col2
    from table_a as a, (select id, sum(col2) as col2 from table_c group by id) as b where a.id = b.id order by 1
    thx

    Hello Markus
    ABAP open sql ahould be something like
    select aid acol1 sum( b~col2 )
    from table_a as a
    join table_c as b
      on aid = bid
      group by b~id
    not sure abour the order by; don't know oracle syntax exactly.
    Try!
    Regards,
    Clemens

  • Joining Two Internal Tables - ( Urgent )

    Could anybody please give me the whole code for joining two internal tables
    and putting the data in a third internal table. Please, very urgent.
                                                                                    Regards,
                                                                                    SAURAV

    Hi,
      Refer this code
    *&      Form  SUB_READ_VBRK
          text
    FORM sub_read_vbrk.
      SELECT vbeln
             rplnr
             bukrs
             FROM vbrk
             INTO TABLE it_vbrk
             WHERE vbeln IN s_vbeln
             AND   rplnr NE ' '.
      IF sy-subrc EQ 0.
        SORT it_vbrk BY rplnr.
      ENDIF.
    ENDFORM.                    " SUB_READ_VBRK
    *&      Form  SUB_READ_FPLTC
          text
    FORM sub_read_fpltc.
      IF NOT it_vbrk[] IS INITIAL.
        SELECT fplnr
               fpltr
               ccnum
               FROM fpltc
               INTO TABLE it_fpltc
               FOR ALL ENTRIES IN it_vbrk
               WHERE fplnr EQ it_vbrk-rplnr
               AND   ccins EQ 'GIFC'.
        IF sy-subrc EQ 0.
          SORT it_fpltc BY fplnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " SUB_READ_FPLTC
    *&      Form  SUB_COLLECT_DATA
          text
    FORM sub_collect_data.
    *--Local variables
      DATA : lv_count(3) TYPE c.
      IF NOT it_fpltc[] IS INITIAL.
        LOOP AT it_fpltc INTO wa_fpltc.
          lv_count = wa_fpltc-fpltr+3(3).
          wa_final-ccnum = wa_fpltc-ccnum.
          wa_final-rfzei = lv_count.
          CLEAR : wa_vbrk.
          READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_final-vbeln = wa_vbrk-vbeln.
            wa_final-bukrs = wa_vbrk-bukrs.
          ENDIF.
          APPEND wa_final TO it_final.
          CLEAR : wa_vbrk,
                  wa_fpltc,
                  lv_count.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " SUB_COLLECT_DATA
    Regards,
    prashant

  • How to join several internal tables?

    Hi,
    I have several internal tables. And there is a very complex LOOP to extract data from these internal tables and many other logic inside it. The LOOP is very time-consuming.
    I am thinking to join these internal tables into one big internal table, to save some logic inside the complex LOOP. But as I know there is no "join" function for internal tables.
    So is there any workaround method to perform a "join" operation on internal tables?
    Thanks a lot!

    Hi,
    I have several internal tables. And there is a very complex LOOP to extract data from these internal tables and many other logic inside it. The LOOP is very time-consuming.
    I am thinking to join these internal tables into one big internal table, to save some logic inside the complex LOOP. But as I know there is no "join" function for internal tables.
    So is there any workaround method to perform a "join" operation on internal tables?
    Thanks a lot!

  • Join two internal tables

    hi all
        please give a query for joining of three internal tables and store into another table,and we should retrive data from that third table
    please take those fields as material number,plant,storage location,stock,units

    Hello Raja,
    SELECT EKKNEBELN EKKNEBELP EKKNKOSTL EKKNPS_PSP_PNR EKKN~SAKTO
          EKETWEMNG EKETETENR EKETBEDAT EKPOKNTTP EKPOLOEKZ EKPOMATNR
          EKPOWERKS EKPOMATKL  EKPOMENGE EKPOMEINS EKPONETPR EKPOPEINH
          EKPONETWR EKPOMTART EKPOEFFWR EKKOBUKRS EKKOBSART EKKOERNAM
          EKKOLIFNR EKKOEKORG EKKOEKGRP EKKOWAERS EKKO~BEDAT
          EKKO~MEMORY INTO TABLE G_T_OUTTAB
       FROM ( EKKN
               INNER JOIN EKET
               ON EKETEBELN = EKKNEBELN
               AND EKETEBELP = EKKNEBELP
               INNER JOIN EKPO
               ON EKPOEBELN = EKETEBELN
               AND EKPOEBELP = EKETEBELP
               INNER JOIN EKKO
               ON EKKOEBELN = EKPOEBELN )
             WHERE EKKN~EBELN IN S_EBELN
               AND EKKN~EBELP IN S_EBELP
               AND EKKN~KOSTL IN S_KOSTL
               AND EKKN~PS_PSP_PNR IN S_WBS
               AND EKKN~SAKTO IN S_SAKTO
               AND EKPO~KNTTP IN S_KNTTP
               AND EKPO~LOEKZ IN S_LOEKZ
               AND EKPO~MATKL IN S_MATKL
               AND EKPO~MATNR IN S_MATNR
               AND EKPO~WERKS IN S_WERKS
               AND EKKO~BEDAT IN S_BEDAT
               AND EKKO~BSART IN S_BSART
               AND EKKO~BUKRS IN S_BUKRS
               AND EKKO~EKGRP IN S_EKGRP
               AND EKKO~EKORG IN S_EKORG
               AND EKKO~ERNAM IN S_ERNAM
               AND EKKO~LIFNR IN S_LIFNR
               AND EKPO~MTART IN S_MTART
               AND EKKO~MEMORY IN S_MEMORY
               AND EKET~BEDAT IN S_DAT_ET.
    Try with this code.
    If useful reward.
    Vasanth

  • Can we join two internal tables

    Hi to all,
    i want take data from one database(db) table into internal table from this we want to retrieve data from other db table and put this data into another internal table .provided that two db tables are depends on foreign key relations .

    You can do this a number of ways.  You can use an inner join in your select statement and put the required data into an internal table or you can do two selects from the db and loop at the first itab,  then loop at the second where the keys match and put the required data into a third internal table.
    Here is an example of using an inner joine to get data from db tables into one internal table.
    report zrich_0001.
    data: begin of ima occurs 0,
          matnr type mara-matnr,
          mtart type mara-mtart,
          werks type marc-werks,
          dispo type marc-werks,
          end  of ima.
    select-options: s_matnr for ima-matnr.
    select mara~matnr mara~mtart marc~werks marc~dispo
           into table ima
                 from mara
                     inner join marc
                         on mara~matnr = marc~matnr
                                 where mara~matnr in s_matnr.
    loop at ima.
      write:/ ima-matnr, ima-mtart, ima-werks, ima-dispo.
    endloop.
    Regards,
    Rich Heilman

  • Join 2 internal tables into 1 internal table

    itab 1
    field 1
    1
    2
    3
    5
    itab2
    field 1
    1
    2
    3
    4
    6
    The result require is
    itab3
    filed 1
    1
    2
    3
    4
    5
    6
    how to achieve this if any one can give the exact code for this it will be of great help to me.
    thanks
    naveen

    hi ,
    create the new internal table with all required fields and select the data from those tables through inner-join query as example follows.
    REPORT Z0292_INT_SELECT.
    DATA : BEGIN OF WA,
    PONO TYPE Z0292_PURITEM-PONO,
    ITEM TYPE Z0292_PURITEM-ITEM,
    POD TYPE Z0292_PURHEA-POD,
    VENID TYPE Z0292_PURHEA-VENID,
    END OF WA.
    DATA : ITAB LIKE TABLE OF WA WITH HEADER LINE.
    SELECT APONO AITEM BPOD BVENID
    INTO TABLE ITAB
    FROM Z0292_PURITEM AS A INNER JOIN Z0292_PURHEA AS B
    ON APONO = BPONO.
    LOOP AT ITAB.
    WRITE : / ITAB-PONO,ITAB-ITEM,ITAB-POD,ITAB-VENID.
    ENDLOOP.
    sagun desai  
    Posts: 51
    Questions: 9
    Registered: 2/27/06
    Forum points: 48 
       Re: how to get the data in one internal table? with 3 different tables..  
    Posted: Jul 31, 2007 10:34 AM    in response to: rhymmeanne         Reply      E-mail this post 
    DATA : BEGIN OF IT_A005 OCCURS 0,
    vkorg TYPE a005-vkorg,
    vtweg TYPE a005-vtweg,
    kschl TYPE a005-kschl,
    matnr TYPE a005-matnr,
    kunnr TYPE a005-kunnr,
    datab TYPE a005-datab,
    end of it_a005.
    DATA : begin of IT_MVKE OCCURS 0,
    matnr TYPE MVKE-matnr,
    vkorg TYPE MVKE-vkorg,
    vtweg TYPE MVKE-vtweg,
    kondm TYPE mvke-kondm,
    end of it_mvke.
    DATA : begin of IT_KNVV OCCURS 0,
    kunnr TYPE KNVV-kunnr,
    vkorg TYPE KNVV-vkorg,
    vtweg TYPE KNVV-vtweg,
    kdgrp TYPE knvv-kdgrp,
    konda TYPE knvv-konda,
    end of it_knvv.
    DATA : BEGIN OF IT_FINAL OCCURS 0,
    vkorg TYPE a005-vkorg,
    vtweg TYPE a005-vtweg,
    kschl TYPE a005-kschl,
    kondm TYPE mvke-kondm,
    matnr TYPE a005-matnr,
    kdgrp TYPE knvv-kdgrp,
    konda TYPE knvv-konda,
    kunnr TYPE a005-kunnr,
    datab TYPE a005-datab,
    END OF IT_FINAL.
    SELECT * FROM A005 INTO TABLE IT_A005.
    SELECT * FROM MVKE INTO CORRESPONDING FIELDS
    OF TABLE IT_MVKE
    FOR ALL ENTRIES IN IT_A005
    WHERE MATNR = IT_A005-MATNR
    AND VKORG = IT_A005-VKORG
    AND VTWEG = IT_A005-VTWEG.
    SELECT * FROM KNVV INTO CORRESPONDING FIELDS
    OF TABLE IT_KNVV
    FOR ALL ENTRIES IN IT_A005
    WHERE KUNNR = IT_A005-KUNNR
    AND VKORG = IT_A005-VKORG
    AND VTWEG = IT_A005-VTWEG.
    LOOP AT IT_A005.
    IT_FINAL-vkorg = IT_a005-vkorg.
    IT_FINAL-vtweg = IT_a005-vtweg.
    IT_FINAL-kschl = IT_a005-kschl.
    IT_FINAL-MATNR = IT_a005-matnr.
    IT_FINAL-KUNNR = IT_a005-kunnr.
    IT_FINAL-DATAB = IT_a005-datab.
    READ TABLE IT_MVKE WITH KEY MATNR = IT_A005-MATNR
    AND VKORG = IT_A005-VKORG
    AND VTWEG = IT_A005-VTWEG.
    IT_FINAL-kondm = IT_mvke-kondm.
    READ TABLE IT_KNVV WITH KEY KUNNR = IT_A005-KUNNR
    AND VKORG = IT_A005-VKORG
    AND VTWEG = IT_A005-VTWEG.
    IT_FINAL-kdgrp = IT_knvv-kdgrp.
    IT_FINAL-konda = IT_knvv-konda.
    APPEND IT_FINAL.
    CLEAR : IT_FINAL, IT_MVKE, IT_KNVV.
    ENDLOOP.
    You can try with this code.
    It should work.
    if it ok for you then you can close this issue.
    Cheers,
    Sagun Desai.

  • 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

  • Inner Join of 3 tables is correct or not?

    Hi Guys ,
                 I have a requirement where i have to join 3 tables i  dont know whether the inner Join which i wrote for 3 tables is correct or not.I am not getting any Syntax error but whether the logci below which i wrote gets all the records or not.
    The Requirement is
    "c.     Select the BOL Number entered in the screen and query the table LIKP with the BOL number in the field LIKP-BOLNR.  Gather the list of ALL delivery documents (LIKP-VBELN) that is outputted.
    d.     Query the list of the delivery documents obtained into the table VBFA in the field VBFA- VBELV.  From the output that is displayed, select the Follow-On Document Field (VBFA-VBELN) for that item whose Subsequent Document Category (VBFA- VBTYP_N) is R and the Movement Type (VBFA- BWART) is 641.  Get the Follow-On document number for each of the above Delivery Document number.
    e.     Query the table EKBE with the Follow On document obtained above in the field Material Document (EKBE- BELNR).  Perform this activity for each of the follow on document obtained above.  Get the resultant Purchase Order (EKBE-EBELN) and Item Number (EKBE-EBELP) from the query.  After querying will all the Follow-On Documents, get the unique list of PO number and Item Number.
    The logic which i wrote is
                    Begin of t_PoolSTO_out,
                  BOLNR type LIKP-BOLNR,
                  EBELN type EKBE-EBELN,
                  EBELP type EKBE-EBELP,
                  VBELN type LIKP-VBELN,
                  VBELNV type VBFA-VBELN,
             End of t_PoolSTO_out.
          Data: i_PoolSTO type Standard table of t_PoolSTO_out.
      Select
            a~BOLNR
            c~EBELN
            c~EBELP
            a~VBELN
            b~VBELN
            from LIKP as a
            Inner Join VBFA as b on aVBELN = bVBELV
            Inner Join EKBE as c on bVBELN = cBELNR
            into Table i_PoolSTO
            Where a~BOLNR in S_LBLNE and
                  b~VBTYP_N = 'R' and
                  b~BWART = '641'.
              My doubt is whether the logic works or not i Mean does i getall the rrecords based on the requirement.?
                      If not please tell any alternative logic?
    Thanks,
    Gopi Anne.

    Hi Gopi,
    Your code is Good.
    But try to avoid Inner join with more number of Tables ...because this is a performance issue..
    try to use..
    select (primary key fields mainly,other fields) from LIKP into itab where bolnr in p_bolnr(paramater).
    next try to use for all entries option..
    select (primary key fields mainly,other fields) from VBFA for all entries in itab where (give the condition)....
    simillarly do for the other select ....ok this will try to reduce the performance issue....
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • Left ouer join with internal table

    Good morning to everybody
    I need created a internal table with 2 internal table but 1 is primary.
    I tried use "left outer join" but it allows  only with table and not with internal tabel
    I would to be this result
    a             a xxx
    b                         
    c             c zzz
    d             d sss
    e
    f              f ttt
    How can i do it?
    Thanks a lot for your support
    Beste regatrds

    Hi,
    The following code is for your reference:
    data: begin of wa1,
          key type c,
          end of wa1.
    data: begin of wa2,
          key type c,
          var(3) type c,
          end of wa2.
    data: begin of wa3,
          key1 type c,
          key2 type c,
          var(3) type c,
          end of wa3.
    data: itab1 like standard table of wa1,
          itab2 like standard table of wa2,
          itab3 like standard table of wa3.
    wa1-key = 'a'.
    append wa1 to itab1.
    wa1-key = 'b'.
    append wa1 to itab1.
    wa1-key = 'c'.
    append wa1 to itab1.
    wa1-key = 'd'.
    append wa1 to itab1.
    wa1-key = 'e'.
    append wa1 to itab1.
    wa1-key = 'f'.
    append wa1 to itab1.
    clear wa1.
    wa2-key = 'a'.
    wa2-var = 'zzz'.
    append wa2 to itab2.
    wa2-key = 'c'.
    wa2-var = 'yyy'.
    append wa2 to itab2.
    wa2-key = 'd'.
    wa2-var = 'ttt'.
    append wa2 to itab2.
    wa2-key = 'f'.
    wa2-var = 'sss'.
    append wa2 to itab2.
    clear wa2.
    loop at itab1 into wa1.
      read table itab2 into wa2
      with key key = wa1-key
      binary search.
      if sy-subrc = 0.
        wa3-key1 = wa1-key.
        wa3-key2 = wa2-key.
        wa3-var = wa2-var.
        append wa3 to itab3.
        clear wa3.
      else.
        append wa1 to itab3.
      endif.
    endloop.
    loop at itab3 into wa3.
      write:/ wa3-key1, wa3-key2,wa3-var.
    endloop.
    Hope it helps.
    Regards,
    Chris Gu

  • Select (join) into internal table with nested structures

    Hello Experts,
    i wonder about the correct notation of a select statement.
    I have an internal table it_zoll including  two structures as defined below.
    The select is a join on the two tables zollp and zolls. As coded below the select is syntactically correct, but the fields
    in the nested structures are not filled ....
    Any ideas how to write the select statement ? (The internal table it_zoll must have the nested structures for other reasons ..)
    Declaration:
    TYPES: BEGIN OF ty_zollp,
      belnr     TYPE  zollp-belnr,
      werks     TYPE  zollp-werks,
      gebnr     TYPE  zollp-gebnr,
           END OF ty_zollp.
    TYPES: BEGIN OF ty_zolls,
      grnum     type  zolls-grnum,
      werks     type  zolls-werks,
      name1     TYPE  zolls-name1,
           END OF ty_zolls.
    DATA: BEGIN OF wa_zoll.
    DATA: zollp type ty_zollp.
    DATA: zolls type ty_zolls.
    DATA: END OF wa_zoll.
    DATA: it_zoll LIKE TABLE OF wa_zoll.
    Select:
      SELECT
        zollp~belnr   zollp~werks  zollp~gebnr
        zolls~grnum zolls~werks  zolls~name1
          FROM zollp
          JOIN zolls ON   zolls~werks = zollp~werks
                     AND  zolls~grnum = zollp~grnum
          INTO CORRESPONDING FIELDS OF TABLE it_zoll
          WHERE zollp~werks = werks
          AND   zollp~gebnr IN s-gebnr
          AND ...
    Thank you !

    DATA: BEGIN OF ty_zollp,
      belnr     TYPE  zollp-belnr,
      werks     TYPE  zollp-werks,
      gebnr     TYPE  zollp-gebnr,
           END OF ty_zollp.
    DATA: BEGIN OF ty_zolls,
      grnum     type  zolls-grnum,
      werks     type  zolls-werks,
      name1     TYPE  zolls-name1,
           END OF ty_zolls.
    DATA: BEGIN OF wa_zoll.
    Include structure ty_zollp.
    Include structure ty_zolls.
    DATA: END OF wa_zoll.
    The above declaration had worked. Please try.
    Regards,
    Satish Kanteti

  • 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

  • Using external hard drive for itunes from mac to windows

    Hello, I have an external hard drive for my itunes music connected to a G4. I just bought a laptop (windows) and would like to connect the external drive to it so it will read my music from the external hard drive. How can i do that? Thanks, M

  • Old Computer Fried..

    My old computer died on me. All my songs were on my old itunes account. I now have a new computer. Is there any way to retrieve my old songs? My ipod does not have the songs on them either it reset itself. When I check my itunes account it shows my p

  • BACK-UP keeps failing.

    It seems everytime I fix a problem with my back ups something else breaks, and this one I don't know how to fix. Can someone please check out this error and help me resolving the problem. released channel: ORA_DISK_9 released channel: ORA_DISK_10 RMA

  • SPRY DATASET + Placeholder Problem

    Hi NG, i have the problem, that on loading time the whole table exploding, because the placeholder. I get here information to do following step, and i have done this: <div spry:region=.......class="SpryHiddenRegion"> // css .SpryHiddenRegion {     vi

  • How to check the apps authorization/privilege in OS Lion?

    I recently authorized an app to read from my screen (safari, terminal) when I select some words, I want to know how could I manage this authorization and where can I check the app modified which files in my system?