Select with inner join

hi friends,
can we use where clause in select statement with inner join.
i am using following code which gives error (The column name "WERKS" has two meanings . .).
  SELECT AMATNR ACHARG AERSDA BMENGE B~MEINS
      FROM MCHA AS A INNER JOIN CHVW AS B
      ON ACHARG = BCHARG
      INTO TABLE T_OUTPUT1
      WHERE WERKS = PLANT AND CHARG = P_CHARG.
thanks.

Yes u can  use where clause in select statement with inner join.
SELECT AMATNR ACHARG AERSDA BMENGE B~MEINS
FROM MCHA AS A INNER JOIN CHVW AS B
ON ACHARG = BCHARG
INTO TABLE T_OUTPUT1
WHERE WERKS = PLANT AND CHARG = P_CHARG.
" mention  the table name in where condition also like awerks or bwerks.
egards
Rajendra

Similar Messages

  • Performance tuning of select with inner join

    Hi experts,
    I need to improve the performanve in these two big selects, could you give me some tips, please?Thanks!
      SELECT AWBELN BPOSNR ARFBSK AWFDAT ALIFRE AKNUMV
             BZZ_TKNUM BKOWRR BZZ_VSART BZZ_DTABF
             CTKNUM CVSART C~TDLNR
             CDTABF CSHTYP C~SDABW
             DTPNUM DVBELN
             EERDAT EVSTEL EKUNNR EANZPK EBTGEW EGEWEI
             E~LFDAT
         INTO CORRESPONDING FIELDS OF TABLE GT_AGENCY
            FROM WBRK AS A
              INNER JOIN WBRP AS B
                 ON AWBELN = BWBELN AND
                    B~KOWRR EQ ''
              INNER JOIN VTTK AS C
                 ON BZZ_TKNUM = CTKNUM
              INNER JOIN VTTP AS D
                 ON CTKNUM = DTKNUM
              INNER JOIN LIKP AS E
                 ON DVBELN = EVBELN
              WHERE A~WBELN IN SO_WBELN AND
                    A~RFBSK IN SO_RFBSK AND
                    A~WFDAT IN SO_WFDAT AND
                    A~LIFRE IN SO_TDLNR AND
                    B~ZZ_VSART IN SO_VSART AND
                    B~ZZ_DTABF IN SO_DTABF AND
                    C~VSART IN SO_VSART AND
                    D~TKNUM IN SO_REBEL AND
                    D~VBELN IN SO_VBELN AND
                    E~ERDAT IN SO_ERDAT AND
                    E~VSTEL IN SO_VSTEL AND
                    E~KUNNR IN SO_KUNNR.
      SORT GT_AGENCY BY TDLNR VSTEL TKNUM TPNUM VBELN.
      DELETE ADJACENT DUPLICATES FROM GT_AGENCY
      COMPARING TDLNR VSTEL TKNUM TPNUM VBELN.
      IF NOT GT_AGENCY[] IS INITIAL.
        SELECT VFKPTDLNR VFKPFKNUM VFKPFKPOS VFKPKNUMV          VFSIKPOSN VFKPREBEL VFSIVBELN vfsivbtyp
          INTO corresponding fields of TABLE GT_SHIPCOST
          FROM VFKP
          JOIN VFSI ON VFSIKNUMV = VFKPKNUMV
          WHERE VFKP~TDLNR IN SO_TDLNR
             AND VFKP~FKNUM IN SO_FKNUM
             AND VFKP~FKPOS IN SO_FKPOS
             AND VFKP~STBER IN SO_STBER
           AND VFKP~FKPTY IN SO_FKPTY
           AND ( VFSI~VBTYP = 'J'(S01) OR
                 VFSI~VBTYP = 'T'(S03) or
                 vfsi~vbtyp = 'a' ).
      ENDIF.
    Thanks a lot!
    Patricia

    Hi
    1) Dont use nested seelct statement
    2) If possible use for all entries in addition
    3) In the where addition make sure you give all the primary key
    4) Use Index for the selection criteria.
    5) You can also use inner joins
    6) You can try to put the data from the first select statement into an Itab and then in order to select the data from the second table use for all entries in.
    7) Use the runtime analysis SE30 and SQL Trace (ST05) to identify the performance and also to identify where the load is heavy, so that you can change the code accordingly
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5d0db4c9-0e01-0010-b68f-9b1408d5f234
    1. Use Inner Joins
    2. INTO TABLE
    3. No nested loop
    4. FOR ALL ENTRIES
    5. Use as much of the key as possible
    5. try to use primary or secondary keys in where condition. When using key fields, start with first key field.
    6. Select only the fields you need for display/processing - avoid select *
    Reward if useful
    regards
    Anji

  • ORA-00947 Error on straight SELECT with INNER JOINs

    I have a REAL bizarre situation. I have a SQL SELECT Statement that is joining a few tables. I actually have a WHERE clause where I am filtering by a coulmn within one of the joins. However, if I try to SELECT that coulmn, I am getting an Oracle error ORA-00947. I can even SELECT * and get ALL the columns back form ALL the tables I'm joing on, including the one that is not allowing me just to select it.
    Has anyone ever seen anything like this before???
    I appreciate your review and am hopeful for a reply.
    Thanks.
    PSULionRP

    Jez....Not sure if I need to worry about proprietary stuff here...Here's the SQL and the column I'm trying to select is CDM_SUPPLIER_UTILITY.SUPPLIER_CD.
    When I do that is when I get the ORA-00947 error. And our version is...
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    SELECT CDM_CALENDAR.CALENDAR_DT,
    CDM_OFFER.SUPPLIER_NAME,
    CDM_SUPPLIER_UTILITY.SUPPLIER_CD,
    ABS(SUM(CDM_MONEY.TRANSACTION_AMT))
    FROM CDEDM.CDM_TRANSACTIONS CDM_TRANSACTIONS
    INNER JOIN CDEDM.CDM_MONEY CDM_MONEY
    ON CDM_MONEY.TRANSACTION_FK = CDM_TRANSACTIONS.TRANSACTION_GK_PK
    INNER JOIN CDEDM.CDM_OFFER CDM_OFFER
    ON CDM_OFFER.OFFER_GK_PK = CDM_MONEY.OFFER_FK
    INNER JOIN CDEDM.CDM_CALENDAR CDM_CALENDAR
    ON CDM_CALENDAR.CALENDAR_DT_PK = CDM_MONEY.TRANSACTION_DT_FK
    INNER JOIN CDEDM.CDM_BILL_ACCOUNTS CDM_BILL_ACCOUNTS
    ON CDM_BILL_ACCOUNTS.BILL_ACCT_GK_PK = CDM_MONEY.BILL_ACCOUNTS_FK
    INNER JOIN CDEDM.CDM_SUPPLIER_UTILITY CDM_SUPPLIER_UTILITY
    ON CDM_SUPPLIER_UTILITY.SUPPLIER_UTILITY_GK_PK = CDM_BILL_ACCOUNTS.SUPPLIER_FK
    WHERE CDM_SUPPLIER_UTILITY.SUPPLIER_CD = 'MC2'
    AND CDM_CALENDAR.CALENDAR_DT BETWEEN NEXT_DAY(trunc(SYSDATE-12),'Saturday')
    AND NEXT_DAY(trunc(SYSDATE-5),'Saturday')
    AND CDM_TRANSACTIONS.TRAN_DECODE IN
    'Debit/Bill Installment Billing',
    'Debit/Bill Electric Service',
    'Debit by Transfer of Payment TO Uncollec',
    'Debit Miscellaneous Electric',
    'Credit for Transfer TO Uncollectible',
    'Credit for Tranfer FROM Uncollectible',
    'Credit Miscellaneous Electric',
    'Credit Alteration',
    'Credit Allowance',
    'Bill Consumption On An Inactive Meter'
    AND CDM_MONEY.TRANSACTION_LEVEL_CD IN
    'A',
    GROUP BY CDM_CALENDAR.CALENDAR_DT,
    CDM_OFFER.SUPPLIER_NAME,
    CDM_SUPPLIER_UTILITY.SUPPLIER_CD

  • SUBQUERY with INNER JOIN in ABAP

    Hi Expert
    How Can I write SUBQUERY with INNER JOIN in ABAP.
    thanks

    Thanks Sidhharth for your Respose
    Actually I need data from VBAP, VBAK, VBUP, VBUK and VBKD with all functional validation satisfied for a sales order item data. The requirement is to report all item data with other information from table VBAK, VBUP, VBUK and VBKD in a corresponding record with ALL data in VBAP.
    Your help is appriciated.
    see the below query for reference
    select   alias_vbap~vbeln from  vbap as
    alias_vbap inner join vbak as alias_vbak
    on  alias_vbapvbeln eq  alias_vbakvbeln
    "and  alias_vbak~bukrs_vf eq '2400'
    inner join vbuk as alias_vbuk
    on alias_vbukvbeln = alias_vbapvbeln
    inner join vbup as alias_vbup
    on alias_vbupvbeln = alias_vbapvbeln
    and alias_vbupposnr = alias_vbapposnr
    left OUTER join veda as alias_veda
    on alias_vedavbeln = alias_vbapvbeln
    and alias_vedavposn = alias_vbapposnr
    left outer join vbkd as alias_vbkd
    on alias_vbkdvbeln = alias_vbapvbeln
    and alias_vbkdposnr = alias_vbapposnr

  • Select Query with Inner Join

    Dear Experts,
    I have writen a inner join code with MKPF and MSEG which taking too much time, while I have used index.
    Indexes are:
    MSEG
    MATNR
    WERKS
    LGORT
    BWART
    SOBKZ
    MKPF
    BUDAT
    MBLNR
    My Select Query is :
      SELECT B~MATNR
                   B~MAT_KDAUF
                   B~MAT_KDPOS
                   B~BWART
                   B~MENGE
                   B~MEINS
                   B~AUFNR
        INTO TABLE IT_MSEG
        FROM MKPF AS A
          INNER JOIN MSEG AS B
             ON AMBLNR EQ BMBLNR
            AND AMJAHR EQ BMJAHR
        WHERE A~BUDAT IN BUDAT
          AND B~MATNR IN MATNR
          AND B~WERKS IN WERKS
          AND B~LGORT IN LGORT
          AND B~BWART IN BWART.

    hi,
    you can use  for all entries  it will work faster then joins
    About it:*
    FOR ALL ENTRIES WHERE
    Syntax
    ... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
    Effect
    If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
    The internal table itab must have a structured line type and the component comp must be compatible with the column col.
    The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
    The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
    Notes
    In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
    The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
    Example
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    hope it will help you
    Rahul sharma
    Edited by: RAHUL SHARMA on Sep 11, 2008 8:10 AM

  • Select quer with inner join

    table
    can any please modify the query
    thanking in advance
    BEGIN OF t_initord OCCURS 0,
    vbeln LIKE vbak-vbeln, " Sales Order
    posnr LIKE vbap-posnr, " Sales Order Line Item
    auart LIKE vbak-auart, " Sales Order Type
    bezei LIKE tvakt-bezei, " Sales Order Type Text
    billdo Like vbrk-vbeln, "billing document number
    matnr LIKE vbfa-matnr, " Material
    maktx LIKE makt-maktx, " Material Description
    bstnk LIKE vbak-bstnk, " Customer PO number
    bukrs LIKE vbak-bukrs_vf, " Company Code..
    vkorg LIKE vbak-vkorg, " Sales Org
    vtweg LIKE vbak-vtweg, " Distribution Channel
    spart LIKE vbak-spart, " Division
    vkgrp LIKE vbak-vkgrp, " Sales Group
    augru LIKE vbak-augru, " Order Reason
    abgru LIKE vbap-abgru, " Reson for rejection
    kwmeng LIKE vbap-kwmeng, " Order Line quantit
    deliv LIKE likp-vbeln, " Delivery Number
    delit LIKE lips-posnr, " Delivery Number
    rfmng LIKE vbfa-rfmng, " Delivery Qty..
    vbtyp_n LIKE vbfa-vbtyp_n, " R12 Defect 8938.
    mrnkz LIKE vbkd-mrnkz, " Subsequent Invoicing
    docurr LIKE vbak-waerk, " Document Currency
    netwr LIKE vbap-netwr, " Line Item Amt in Doc curr
    ocdate LIKE vbak-aedat, " Order change date
    objnr LIKE vbap-objnr, " Object number
    rad LIKE sy-datum, " Requested Arrival Date
    submi LIKE ekko-submi, " Collective number
    plant1 LIKE vbap-werks, " Supplying Plant
    ernam LIKE vbak-ernam, " Order Created by
    erdat LIKE vbak-erdat, " Order Created on
    lifnr LIKE ekko-lifnr, " Vendor
    soldto LIKE vbak-kunnr, " Sold-to Party
    shipto LIKE vbak-kunnr, " Ship-to Party
    etenr LIKE vbep-etenr, " Sales Order schedule line
    bmeng LIKE vbep-bmeng, " Order Sch Line quantity
    vrkme LIKE vbap-zieme, " Sales Order UOM
    cad LIKE sy-datum, " Confirmed Arrival Date
    ktokk LIKE lfa1-ktokk, " Vendor account group
    docurramt LIKE vbap-netwr, " Document Currency Amount
    locurr LIKE vbak-waerk, " Local Currency
    locurramt LIKE vbap-netwr, " Local Currency Amount
    werks1 LIKE vbap-werks, " Supplying Plant
    werks_name1 LIKE t001w-name1, " Plant description
    lifnr_name1 LIKE lfa1-name1, " Name of the Vendor
    stat TYPE g_stat_typ, " Status Code
    lstatus TYPE g_stext_typ, " Last Status
    soappr TYPE tj30t-txt30, " Sales Order Approval
    bdnum LIKE vbfa-vbeln, " Billing doc number
    bdlin LIKE vbrp-posnr, " Billing Item
    uecha_b LIKE vbrp-uecha, " Item of Batch split
    uecha_d LIKE lips-uecha, " Item of Batch split
    END OF t_initord.
    This is the internal table
    to get the details wrote a select query
    can any one please correct the select query
    SELECT t1vbeln t2posnr t1auart t4bezei
    t2matnr t5maktx
    t1bstnk t1bukrs_vf t1vkorg t1vtweg t1spart t1vkgrp
    t1augru t2abgru t2kwmeng t8vbeln
    t8posnn t8rfmng t8vbtyp_n t7mrnkz t2waerk t2netwr
    t1aedat t1objnr t1vdatu t1submi t2werks t1ernam t1~erdat
    t6lifnr t1kunnr t9~kunnr
    INTO TABLE t_initord
    FROM vbak AS t1
    INNER JOIN vbap AS t2
    ON t1vbeln EQ t2vbeln
    LEFT OUTER JOIN tvakt AS t4
    ON t1auart EQ t4auart
    AND t4~spras EQ c_en
    LEFT OUTER JOIN makt AS t5
    ON t2matnr EQ t5matnr
    AND t5~spras EQ c_en
    LEFT OUTER JOIN vbpa AS t9
    ON t1vbeln EQ t9vbeln
    AND t9~parvw EQ c_we
    LEFT OUTER JOIN ekko AS t6
    ON t1submi EQ t6ebeln
    LEFT OUTER JOIN vbkd AS t7
    ON t1vbeln EQ t7vbeln AND
    t7~posnr EQ c_initposnr
    LEFT OUTER JOIN vbfa AS t8
    ON t2vbeln EQ t8vbelv AND
    t2posnr EQ t8posnv
    WHERE t1~vbeln IN s_slord
    AND t1~vkbur IN s_sloff
    AND t1~vkgrp IN s_slgrp
    AND t1~kunnr IN s_custag
    AND t1~auart IN s_ortyp
    AND t1~vkorg IN s_slorg
    AND t1~vtweg IN s_disch
    AND t1~spart IN s_divi
    AND t1~erdat IN s_date
    AND t1~bukrs_vf IN s_ccode
    AND t2~ernam IN s_slcre.
    i need to modify the above query to get the additional information into the above table
    billing doument number
    document currency
    document currency amount
    billed quantity
    sold to country
    ship to country

    You can also refer to this code... for making your code better..
    SELECT MATNR
           WERKS
           DISMM
           DISPO
           BESKZ INTO TABLE I_MARC FROM MARC
                 WHERE WERKS IN S_WERKS  AND BESKZ = 'F' AND DISMM <> 'ND'.
      IF NOT I_MARC IS INITIAL.
      SELECT MATNR
             MAKTX INTO TABLE I_MAKT FROM MAKT
                   FOR ALL ENTRIES IN I_MARC
                   WHERE MATNR = I_MARC-MATNR.
      ENDIF.
    REFRESH I_MDPS.
    REFRESH I_MDEZ.
    REFRESH I_MT61D.
    REFRESH I_MDPS2.
    REFRESH I_MDEZ2.
    LOOP AT I_MARC INTO WA_MARC.
    CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
      EXPORTING
        MATNR                          = WA_MARC-MATNR
        WERKS                          = WA_MARC-WERKS
    TABLES
       MDEZX                           = I_MDEZ
    EXCEPTIONS
       MATERIAL_PLANT_NOT_FOUND       = 1
       PLANT_NOT_FOUND                = 2
       OTHERS                         = 3
    LOOP AT I_MDEZ.
       I_MDEZ2-MATNR = WA_MARC-MATNR.
       I_MDEZ2-WERKS = WA_MARC-WERKS.
       MOVE-CORRESPONDING I_MDEZ TO I_MDEZ2.
       APPEND I_MDEZ2.
    ENDLOOP.
    CLEAR I_MDEZ.
    CLEAR I_MDEZ2.
      ENDLOOP.
    Deleting teh records from the internal table which are
    nither purchase order nor purchase requisition.
    if pur_ord = 'X' and Pur_req = 'X'.
      delete i_mdez2 where delkz <> 'BA' and delkz <> 'BE'.
    endif.
    if pur_ord = 'X' and Pur_req <> 'X'.
      delete i_mdez2 where delkz <> 'BE'.
    endif.
    if pur_req = 'X' and pur_ord <> 'X'.
      delete i_mdez2 where delkz <> 'BA'.
    endif.
    Populating the final internal table to be displayed.
    Sort i_mdez2 by matnr werks.
    SORT I_MAKT BY MATNR.
      LOOP AT I_MDEZ2 WHERE LIFNR IN S_LIFNR.
              wa_final-werks = i_mdez2-werks.
              WA_FINAL-LIFNR = I_MDEZ2-LIFNR.
              WA_FINAL-EXTRA = I_MDEZ2-EXTRA.
              WA_FINAL-MNG01 = I_MDEZ2-MNG01.
              WA_FINAL-AUSKT = I_MDEZ2-AUSKT.
              WA_FINAL-UMDAT = I_MDEZ2-UMDAT.
              WA_FINAL-WERKS = I_MDEZ2-WERKS.
              WA_FINAL-MATNR = I_MDEZ2-MATNR.
              wa_final-delkz = i_mdez2-delkz.
    For Message to be displayed with the Purchase Order and Purchase Requisition.
              PERFORM TEXT_EXCEPTION.
              READ TABLE I_MAKT INTO WA_MAKT WITH KEY MATNR = WA_FINAL-MATNR BINARY SEARCH.
              IF SY-SUBRC = 0.
                WA_FINAL-MAKTX = WA_MAKT-MAKTX.
              ENDIF.
           APPEND WA_FINAL TO I_FINAL .
      ENDLOOP.
        IF SY-SUBRC <> 0.
           MESSAGE I058.
           leave program.
        ENDIF.
    Selecting the Purchase Organisation from the EKKO table.
    if not i_final is initial.
      SELECT EBELN EKORG LIFNR INTO TABLE I_EKKO FROM EKKO
             FOR ALL ENTRIES IN I_FINAL
             WHERE LIFNR = I_FINAL-LIFNR.
    Selecting the name of the vendor from the LFA1 table.
      select lifnr name1 into table i_lfa1 from lfa1
             for all entries in i_final
             where lifnr = i_final-lifnr.
    Selecting the current date from the eban table.
       select matnr lfdat into table i_eban from eban
            for all entries in i_final
            where matnr = i_final-matnr." and bnfpo = i_ekpo-bnfpo.
    endif.
    if not i_ekko is initial.
    Selecting the Unit Price from EKPO for finding the Extended amount.
      SELECT EBELN ebelp NETPR MATNR  banfn bnfpo INTO TABLE I_EKPO FROM EKPO
             FOR ALL ENTRIES IN I_EKKO
             WHERE EBELN = I_EKKO-EBELN.
    endif.
    if not i_ekpo is initial.
    Selecting the current date from the Eket table.
    select ebeln ebelp eindt into table i_eket from eket
           for all entries in i_ekpo
           where ebeln = i_ekpo-ebeln and ebelp = i_ekpo-ebelp.
    endif.
    *Sorting the internal tables.
    SORT I_EKKO BY LIFNR.
    sort i_lfa1 by lifnr.
    SORT I_EKPO BY MATNR.
    sort i_eket by ebeln ebelp.
    sort i_eban by matnr.
      LOOP AT I_FINAL INTO WA_FINAL.
        READ TABLE I_EKKO INTO WA_EKKO WITH KEY LIFNR = WA_FINAL-LIFNR.
           WA_FINAL-EKORG = WA_EKKO-EKORG.
          wa_final-ebeln = wa_ekko-ebeln.
         read table i_lfa1 into wa_lfa1 with key lifnr = wa_final-lifnr.
           wa_final-name1 = wa_lfa1-name1.
           READ TABLE I_EKPO INTO WA_EKPO WITH KEY MATNR = WA_FINAL-MATNR.
             wa_final-ebelp = wa_ekpo-ebelp.
             WA_FINAL-NETPR = WA_EKPO-NETPR.
           if wa_final-delkz = 'BA'.
             read table i_eban into wa_eban with key matnr = wa_final-matnr.
             wa_final-dat00 = wa_eban-lfdat.
           endif.
           if wa_final-delkz = 'BE'.
             read table i_eket into wa_eket with key ebeln = wa_final-ebeln ebelp = wa_final-ebelp.
              wa_final-dat00 = wa_eket-eindt.
           endif.
           WA_FINAL-EXTND_AMOUNT = WA_FINAL-MNG01 * WA_FINAL-NETPR.
        MODIFY I_FINAL FROM WA_FINAL TRANSPORTING EKORG name1 dat00 EXTND_AMOUNT.
      ENDLOOP.
    In this I have taken many internal tables... according to the database table I am extracting from .. then I am bringing all the record in the final internal table which will be containing teh records from all the internal table that i have used..
    Regards,
    Jayant
    <b>Please award if helpful</b>

  • Trying to convert SELECT query to Update query with INNER JOINS

    Assalam O Alaikum!
    I've tried to convert this query of mine but failed.
    I wish to use it for update datasource in data GridView. I'm fetching data with it but converting it to update is not helping giving multiple errors.
    I tried to share the pic but they don't let me do so. Its actually a gridView with check boxes. check the item and update it..
    Here is the query. Please help me with that.
    <pre>
    SELECT [rightsId], [saveRights], [updateRights],
    [viewRights], [deleteRights], [printRights],
    [processRights], [verifyRights], [unProcessRights],
    [unVerifyRights], CONVERT(VARCHAR(100),tblGroup.groupId)as groupId, convert(varchar(100),tblmenu.[menuId])as menuid
    FROM [tblRights] inner join tblMenu ON
    tblMenu.menuId=tblRights.menuId INNER JOIN
    tblGroup ON tblGroup.groupId=tblRights.rightsId
    </pre>

    code is fine the above query works fine with the fetching(select) but when I try to write it with update it doesn't. Here is the asp code. I'm doing nothing with c# or vb.
      <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                DataSourceID="ratGrid" AutoGenerateColumns="False"
                CssClass="GridViewStyle" Width="100%" AllowSorting="True" AutoGenerateEditButton="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
                <Columns>
                    <asp:BoundField DataField="rightsId" HeaderText="rightsId" ItemStyle-Width="75px" SortExpression="rightsId" Visible="False">
                    <ItemStyle Width="75px" />
                    </asp:BoundField>
                    <asp:CheckBoxField DataField="saveRights" HeaderText="Save" SortExpression="saveRights" />
                    <asp:CheckBoxField DataField="updateRights" HeaderText="Update" SortExpression="updateRights" />
                    <asp:CheckBoxField DataField="viewRights" HeaderText="View" SortExpression="viewRights" />
                    <asp:CheckBoxField DataField="deleteRights" HeaderText="Delete" SortExpression="deleteRights" />
                    <asp:CheckBoxField DataField="printRights" HeaderText="Print" SortExpression="printRights" />
                    <asp:CheckBoxField DataField="processRights" HeaderText="Process" SortExpression="processRights" />
                    <asp:CheckBoxField DataField="verifyRights" HeaderText="Verify" SortExpression="verifyRights" />
                    <asp:CheckBoxField DataField="unProcessRights" HeaderText="UnProcess" SortExpression="unProcessRights" />
                    <asp:CheckBoxField DataField="unVerifyRights" HeaderText="UnVerify" SortExpression="unVerifyRights" />
                    <asp:BoundField DataField="groupId" HeaderText="groupId" ReadOnly="True" SortExpression="groupId" Visible="False" />
                    <asp:BoundField DataField="menuid" HeaderText="menuid" SortExpression="menuid" ReadOnly="True" Visible="False" />
                </Columns>
                <RowStyle CssClass="RowStyle" BackColor="#FFF7E7" ForeColor="#8C4510" />
                <PagerStyle CssClass="PagerStyle" ForeColor="#8C4510" HorizontalAlign="Center" />
                <SelectedRowStyle CssClass="SelectedRowStyle" BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle CssClass="HeaderStyle" BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle CssClass="AltRowStyle" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
            </asp:GridView>
            <asp:SqlDataSource ID="ratGrid"
                 runat="server"
                ConnectionString="<%$ ConnectionStrings:Conn_Str %>"
                SelectCommand="SELECT [rightsId], [saveRights], [updateRights],
    [viewRights], [deleteRights], [printRights],
    [processRights], [verifyRights], [unProcessRights],
    [unVerifyRights], CONVERT(VARCHAR(100),tblGroup.groupId)as groupId, convert(varchar(100),tblmenu.[menuId])as menuid
    FROM [tblRights] inner join tblMenu ON
    tblMenu.menuId=tblRights.menuId INNER JOIN
    tblGroup ON tblGroup.groupId=tblRights.rightsId"
               FilterExpression="menuId like '{0}%' and [groupId] like '{1}%'" >
                            <FilterParameters>
                <asp:ControlParameter ControlID="ddlmenu" Name="menu"
                        PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ddlgroup" Name="Country"
                        PropertyName="SelectedValue" Type="String" />
                </FilterParameters>
            </asp:SqlDataSource>
    Your table needs key(s) and you need to assign the key as DataKeys property for the GridView to make your UpDate and Delete work without coding.

  • How to re-write this big SELECT Query with INNER JOINs?

    Hi Experts
    I have a performance killer SELECT query with an inner join of 3 tables u2013 VBAP, VBAK and VBEP together, which populates records to an internal table INT_COLL_ORD. Based on these records selected, in another SELECT query, records are fetched from VBUK table to the internal table INT_VBUK.
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP E~EDATU
    INTO TABLE INT_TAB_RES
    FROM VBAP AS A INNER JOIN VBAK AS D
    ON D~VBELN EQ A~VBELN AND D~MANDT EQ A~MANDT
    INNER JOIN VBEP AS E
    ON E~VBELN EQ A~VBELN AND E~POSNR EQ A~POSNR AND E~MANDT EQ A~MANDT
    WHERE  A~VBELN IN s_VBELN AND
           D~auart in s_auart AND
           D~vkorg in s_vkorg AND
           D~vbtyp eq 'C'     AND
           ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
           OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
           A~ABGRU EQ SPACE AND
           A~MTVFP IN R_MTVFP AND
           A~PRCTR IN R_PRCT AND
           E~ETENR EQ '1'.
    SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
    DELETE ADJACENT DUPLICATES FROM INT_TAB_RES COMPARING VBELN POSNR.
    CHECK NOT INT_TAB_RES [] IS INITIAL.
    SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
    FROM VBUK FOR ALL ENTRIES IN INT_TAB_RES
    WHERE VBELN = INT_TAB_RES-VBELN AND UVALL NE 'A'.
    Now, the requirement is:
    I want to split this query. Like, first join VBAK and VBUK first. With this selection, go to the inner join of VBAP and VBEP (on key VBELN) to get the results. How can I re-write this Query?
    Please help.
    Thx n Rgds

    Hi Nagraj
    As of your suggestion, I have re-written the query as below:
    * Declarations
    TYPES: BEGIN OF TYP_COLL_ORD,
            VBELN  LIKE VBAK-VBELN,
            POSNR  LIKE VBUP-POSNR,
            MATNR  LIKE VBAP-MATNR,
            KWMENG LIKE VBAP-KWMENG,
            KBMENG LIKE VBAP-KBMENG,
            ERDAT  LIKE VBAK-ERDAT,
            ERZET  LIKE VBAK-ERZET,
            PSTYV  LIKE VBAP-PSTYV,
            AUART  LIKE VBAK-AUART, u201Calready exists in type
            ETTYP  LIKE VBEP-ETTYP,
            EDATU  LIKE VBEP-EDATU.
    TYPES: END OF TYP_COLL_ORD.
    DATA: INT_COLL_ORD TYPE TABLE OF TYP_COLL_ORD WITH HEADER LINE.
    TYPES: BEGIN OF TYP_VBUK,
            AUART  LIKE VBAK-AUART, u201Chave added this field
            VBELN  LIKE VBUK-VBELN,
            UVALL  LIKE VBUK-UVALL,
            CMGST  LIKE VBUK-CMGST.
    TYPES: END OF TYP_VBUK.
    DATA: INT_VBUK TYPE TABLE OF TYP_VBUK WITH HEADER LINE.
    *QUERY#1 u2013 for VBAK & VBUK Join
    SELECT A~AUART B~VBELN B~UVALL B~CMGST
    INTO TABLE INT_VBUK
    FROM VBAK AS A INNER JOIN VBUK AS B
    ON A~VBELN EQ B~VBELN
    WHERE A~VBELN IN s_VBELN AND
    A~auart in s_auart AND
    A~vkorg in s_vkorg AND
    A~vbtyp eq 'C' AND
    B~UVALL NE 'A'.
    IF NOT INT_VBUK[] IS INITIAL.
    SORT INT_VBUK BY VBELN.
    DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
    *QUERY#2 u2013 for VBAP & VBEP Join
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV B~ETTYP B~EDATU
    INTO TABLE INT_COLL_ORD
    FROM VBAP AS A INNER JOIN VBEP AS B
    ON B~VBELN EQ A~VBELN AND B~POSNR EQ A~POSNR AND B~MANDT EQ A~MANDT
    FOR ALL ENTRIES IN INT_VBUK
    WHERE A~VBELN = INT_VBUK-VBELN AND
    ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
    OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
    A~ABGRU EQ SPACE AND
    A~MTVFP IN R_MTVFP AND
    A~PRCTR IN R_PRCT AND
    B~ETENR EQ '1'.
    ENDIF.
      SORT INT_COLL_ORD BY  VBELN POSNR ETTYP.
      DELETE ADJACENT DUPLICATES FROM INT_COLL_ORD
        COMPARING VBELN POSNR.
      CHECK NOT INT_COLL_ORD[] IS INITIAL.
      LOOP AT INT_COLL_ORD.
        CLEAR: L_MTART,L_ATPPR,L_ETTYP.
        IF L_PREVIOUS_ETTYP NE INT_COLL_ORD-ETTYP OR
          L_PREVIOUS_AUART NE INT_COLL_ORD-AUART.
          READ TABLE INT_OVRCTL WITH KEY AUART = INT_COLL_ORD-AUART ETTYP = INT_COLL_ORD-ETTYP.
          CHECK SY-SUBRC NE 0.
    Now, the issue is:
    Please note that declaration for INT_COLL_ORD has a field AUART, which is used in further parts of program (see the statement just above)
    But, since neither VBAP nor VBEP contains AUART field, it cannot be fetched through the QUERY#2. So this value is not populated into INT_COLL_ORD through SELECT Query.
    Since this field is used in later part of program & that the internal table has no value for this field, it dumps!!
    How to include this value into the INT_COLL_ORD?
    Plz suggest....

  • Help with Inner Join query in SQL

    Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
    My table structure is :
    table_packages
    packageID
    package
    packageDetails
    etc
    table_destinations
    destinationID
    destination
    destinationDetails
    etc
    table_packagedestinations
    packageID
    destinationID
    ..so nothing that complicated.
    So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
    So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
    This is the PHP from the header, including my INNER JOIN query....
    PHP Code:
    <?php
    $ParampackageID_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    $ParamSessionpackageID_WADApackages = "-1";
    if (isset($_SESSION['WADA_Insert_packages'])) {
      $ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
    $ParampackageID2_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    mysql_select_db($database_connPackages, $connPackages);
    $query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
    $WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
    $row_WADApackages = mysql_fetch_assoc($WADApackages);
    $totalRows_WADApackages = mysql_num_rows($WADApackages);
    $colname_educationalDestinations = "1";
    if (isset($_GET['PackageID'])) {
      $colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
    mysql_select_db($database_connPackages, $connPackages);
    $query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
    $educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
    $row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
    $totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
    ?>
    And where I'm trying to display the destinations themselves, I have : 
    <table>
            <tr>
                     <td>Destinations :</td>
                </tr>
               <?php do { ?>
            <tr>
                 <td><?php echo $row_educationalDestinations['destination']; ?></td>
            </tr>
            <?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
    </table>
    If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working. 
    Thanks.

    First off, you need to get the database tables so that there is a relationship between them.
    In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
    table_packages
    packageID
    package
    packageDetails
    destination
    destinationDetails
    etc
    If there is a one to many relationship, then the following would be true
    packages
    packageID
    package
    packageDetails
    etc
    destinations
    destinationID
    packageID
    destination
    destinationDetails
    etc
    The above assumes that there are many destinations to one package with the relationship coloured orange.
    Once you have the above correct you can apply your query as follows
    SELECT *
    FROM packages
    INNER JOIN destinations
    ON packages.packageID = destinations.packageID
    WHERE packages.packageID = %s
    ORDER BY destination ASC
    The above query will show all packages with relevant destinations

  • Performance problem with inner join

    Hi
    With this Query
    SELECT *
    FROM TABLE1
    INNER JOIN TABLE2
    ON TABLE1.Col1 = TABLE2.Col2 AND TABLE1.Col2 = TABLE2.Col2
    WHERE TABLE1.Col3 = 'AB' AND
    TABLE2.Col4 = 'ZZ';
    TABLE1 have 6,000,000 of records
    TABLE2 have 9,000,000 of records
    when I run this query the result take 30 secs
    If I change the Optimizer_mode for 'RULE'
    the result take 4 secs
    All statistics is ok
    Primary Key exists for TABLE1 and TABLE2 base-on Col1 and Col2
    And index on Table1.Col3,Table1.Col4
    somebody can help me ?

    Analyze tables compute statistics
    and analyze index compute statistics
    I join explain plan
    STATEMENT_ID TIMESTAMP REMARKS OPERATION OPTIONS OBJECT_NODE OBJECT_OWNER OBJECT_NAME OBJECT_INSTANCE OBJECT_TYPE OPTIMIZER SEARCH_COLUMNS ID PARENT_ID POSITION COST CARDINALITY BYTES
    OTHER_TAG PARTITION_START PARTITION_STOP PARTITION_ID OTHER DISTRIBUTION CPU_COST IO_COST TEMP_SPACE
    WithRule1 2004-01-19 16:28:43 SELECT STATEMENT RULE 0
    WithRule1 2004-01-19 16:28:43 SORT AGGREGATE 1 0 1
    WithRule1 2004-01-19 16:28:43 NESTED LOOPS 2 1 1
    WithRule1 2004-01-19 16:28:43 TABLE ACCESS BY INDEX ROWID MICRODEV T088_INSC 1 ANALYZED 3 2 1
    WithRule1 2004-01-19 16:28:43 INDEX RANGE SCAN MICRODEV IX4_T088_INSC NON-UNIQUE ANALYZED 2 4 3 1
    WithRule1 2004-01-19 16:28:43 TABLE ACCESS BY INDEX ROWID MICRODEV T090_CPOS_DEM 2 ANALYZED 5 2 2
    WithRule1 2004-01-19 16:28:43 INDEX UNIQUE SCAN MICRODEV PK_T090_CPOS_DEM UNIQUE ANALYZED 2 6 5 1
    7 rows selected.
    STATEMENT_ID TIMESTAMP REMARKS OPERATION OPTIONS OBJECT_NODE OBJECT_OWNER OBJECT_NAME OBJECT_INSTANCE OBJECT_TYPE OPTIMIZER SEARCH_COLUMNS ID PARENT_ID POSITION COST CARDINALITY BYTES
    OTHER_TAG PARTITION_START PARTITION_STOP PARTITION_ID OTHER DISTRIBUTION CPU_COST IO_COST TEMP_SPACE
    WithChoose1 2004-01-19 16:29:37 SELECT STATEMENT CHOOSE 0 21680 21680 1 40
    21680
    WithChoose1 2004-01-19 16:29:37 SORT AGGREGATE 1 0 1 1 40
    WithChoose1 2004-01-19 16:29:37 HASH JOIN 2 1 1 21680 59050 2362000
    21680 3875000
    WithChoose1 2004-01-19 16:29:37 TABLE ACCESS BY INDEX ROWID MICRODEV T088_INSC 1 ANALYZED 3 2 1 7031 96727 2708356
    7031
    WithChoose1 2004-01-19 16:29:37 INDEX RANGE SCAN MICRODEV IX4_T088_INSC NON-UNIQUE ANALYZED 2 4 3 1 232 96727
    232
    WithChoose1 2004-01-19 16:29:37 TABLE ACCESS FULL MICRODEV T090_CPOS_DEM 2 ANALYZED 5 2 2 11224 5662693 67952316
    11224
    6 rows selected.

  • Query Issue with Inner JOIN

    I need to create the following SQL query in Toplinks, but cannot figure out how to do it. I just want to get all Contacts that have their InitialEventID set to some integer, or have a mapping in the ContactEvents table set to that integer. The mapping between Contacts and ContactEvents is @OnetoMany.
    Select DISTINCT Contacts.* from Contacts JOIN ContactEvents ON (Contacts.ID = ContactEvents.ContactID) WHERE (ContactEvents.EventID = 34 OR Contacts.InitialEventID = 34);
    I'm trying the following, but it obviouly doesn't work.
    SELECT DISTINCT c FROM Contacts c INNER JOIN c.contactEventsCollection ce WHERE ce.eventID = 34
    What should I do?

    Other than the query missing the 'or' clause, why isn't the query working, and what SQL gets generated? You can turn TopLink logging to Fine or Finest to get the SQL logged. You might also want to use OUTER JOIN intead since I assume that Contacts with an InitialEventID=34 may or may not have any ContactEvents associated with it:
    SELECT DISTINCT c FROM Contacts c OUTER JOIN c.contactEventsCollection ce WHERE ( (ce.eventID = 34) OR (c.InitialEventID = 34) )
    Best Regards,
    Chris

  • Help with inner join PLEASE IGNORE

    Hi I was doing a select with a subquery but I need that the where clause check to values so I couldn't get it so I decided to create a INNER JOIN
    Before
    insert into BPMTEMP (select * from ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1 where id_solicitud and accion not in (select (id_solicitud, accion) from ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1) and rownum <=200);but the problem with the inner join is that it doesn't accept me the external database source
    insert into BPMTEMP (select ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1.*, ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1.*
    from ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1
    INNER JOIN ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1
    ON [email protected]_solicitud = [email protected]_solicitud
    ON [email protected] = [email protected]
    AND rownum <=200); it shows an:
    ORA-02084:
         database name is missing a component
    Cause:      supplied database name cannot contain a leading '.', trailing '.' or '@', or two '.' or '@' in a row.
    how can I solve this????
    thanks for your help
    Edited by: Diego Guillen on 29/12/2009 11:14 AM

    Hi
    Please remove the @dblink stuff in the column descrptions or use a table alias. This should help.
    drop database link lokal;
    create database link lokal
       CONNECT TO whateveruserineed IDENTIFIED BY whateverthing
       USING 'lokal11g';
    select HR.COUNTRIES.*  from HR.COUNTRIES@lokal;
    select x.* from HR.COUNTRIES@lokal x;And as Dan Morgans says, pls. post you ? in the right forum next time :-))
    Mette

  • Select or inner join

    hi all,
    i have to extract data from 3 different tables.
    is a single inner join better option or separate select statements ?
    thanks

    Hi,
    If there are common key fields in the three tables, then inner join is a better option else its better to use for all entries to fetch the data.
    If you want an example to join 3 tables, you can find it at this path in SAP
    ABAPDOCU(Transaction)>ABAP Database Access>Open SQL>Read data>Inner Join.
    you can find the following code*
    DATA: BEGIN OF wa,
            carrid TYPE spfli-carrid,
            connid TYPE spfli-connid,
            fldate TYPE sflight-fldate,
            bookid TYPE sbook-bookid,
          END OF wa,
          itab LIKE SORTED TABLE OF wa
                    WITH UNIQUE KEY carrid connid fldate bookid.
    SELECT  pcarrid pconnid ffldate bbookid
      INTO  CORRESPONDING FIELDS OF TABLE itab
      FROM  ( ( spfli AS p
                INNER JOIN sflight AS f ON pcarrid = fcarrid AND
                                           pconnid = fconnid    )
                INNER JOIN sbook   AS b ON bcarrid = fcarrid AND
                                           bconnid = fconnid AND
                                           bfldate = ffldate     )
      WHERE p~cityfrom = 'FRANKFURT' AND
            p~cityto   = 'NEW YORK'  AND
            fseatsmax > fseatsocc.
    LOOP AT itab INTO wa.
      AT NEW fldate.
        WRITE: / wa-carrid, wa-connid, wa-fldate.
      ENDAT.
      WRITE / wa-bookid.
    ENDLOOP.
    Reward if helpfull
    Regards,
    Adithya M

  • Select - SUM - inner join

    Hi,
        select sum( a~dmbtr )
              into o_debit
              from bsik as A inner join FAGLFLEXA as B
                on abukrs = bRBUKRS
               and agjahr = bRYEAR
               and abelnr = bdocnr
             where a~bukrs = x_bukrs
               and a~lifnr = p_lifnr
               and a~shkzg = 'S'
               and a~budat in s_budat
               and a~hkont gt '0000000000'
               and a~hkont le '9999999999'
               and b~prctr = p_prctr.
    Above query is not giving result in o_debit though data is available in both the table. Please guide me, if I have written something wrong.

    Hi, Raj.
    Test the following Sample It is working fine for me hope will work for you too, I did some little change.
    TYPES: BEGIN OF ty_test,
      dmbtr LIKE bsik-dmbtr,
      END OF ty_test.
    DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    SELECT SUM( a~dmbtr ) as dmbtr
    INTO CORRESPONDING FIELDS OF TABLE it_test
    FROM bsik AS a INNER JOIN faglflexa AS b ON ( a~bukrs = b~rbukrs AND a~gjahr = b~ryear AND a~belnr = b~docnr )
    WHERE a~bukrs = x_bukrs
    AND a~lifnr = p_lifnr
    AND a~shkzg = 'S'
    AND a~budat IN s_budat
    AND a~hkont GT '0000000000'
    AND a~hkont LE '9999999999'
    AND b~prctr = p_prctr.
    Please Reply if still any Issue,
    Best Regards,
    Faisal

  • Need help SELECT wiht  INNER JOIN

    Hi,
    I need the the entire record of the MVKE with the same vkorg as in the table YMMARKET. Why has the bellow Join syntex error. Thank you
      SELECT *
        FROM MVKE
        INNER JOIN YMMARKET_CODE ON mvkevkorg = ymmarket_codevkorg
        WHERE matnr = p_matnr.
      ENDSELECT.

    Hello,
    Do this:
    DATA:
      lt_mvke TYPE STANDARD TABLE OF MVKE.
    SELECT <field1> <field2>
    INTO TABLE lt_mvke
    FROM MVKE AS M INNER JOIN YMMARKET_CODE AS Y ON m~vkorg = y~vkorg
    WHERE matnr = p_matnr.
    When using inner join you need to specify the fields.
    I suggest you the following:
    SELECT * FROM MVKE INTO TABLE lt_mvke
      FOR ALL ENTRIES IN YMMARKET_CODE
      WHERE matnr = p_matnr
           AND vkorg = ymmarket_code-vkorg.
    Regards,

Maybe you are looking for

  • Change in start date of tax depreciation not for posting in mid of year

    Hi Experts, Tax depreciation area is not for posting. The fiscal year is from Jan to Dec. I want to calculate tax depreciation from May 2011 based on Net Book Value of tax depreciation as on 30.04.2011. But once I change the start date of tax depreci

  • Can NI-Device be multiple addresses on 1 interface?

    We develop instrument cards in CompactPCI that use NI-Device and a PXI-GPIB card for their GPIB interface. We'd like to be able to put multiple instrument cards in the same CPCI chassis with the one GPIB card, but give each instrument a different add

  • How do I get rid of the Genius playlist on my new ipod?

    Every post I've found on this topic says that turning Genius off in iTunes also turns off the playlist. However, I don't have Genius turned on in iTunes, so I can't turn it off. How do I get rid of the playlist?

  • .FLAC Audio suport in Premiere Pro CS6?

    I try http://valion.net/flacimporter64/ but doesn't work in CS6. It's one of most used lossless formats.

  • Save media file captured from client to server

    Hi all, I need to capture webcam at client side and save it to the server. I am thinking of two solution: 1) save file to client computer then upload to server. 2) streaming to server simultaneously while capturing. If I choose the second method, I s