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

Similar Messages

  • 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

  • Need help with inner join and distinct rows

    Hey Guys,
    i have
    1) BaseEnv Table 
    2) Link Table
    3) BaseData Table
    Link table has three columns Id,BaseEnvId,BaseDataId 
    the BaseEnvID is unique in the table where as BaseDataId can be repeated i.e multile rows of BaseEnv Table can point to same BaseData  table row
    Now i want to do  BaseEnvTable inner join Link Table inner join BaseData Table and select 5 columsn ; Name,SyncName,Version,PPO,DOM  from the BaseData table.. the problem is that after i do the inner join I get duplciate records..
    i want to eliminate the duplicate records , can any one help me here

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Now we have to guess and type, guess and type, etc. because of your bad manners. 
    CREATE TABLE Base_Env
    (base_env_id CHAR(10) NOT NULL PRIMARY KEY,
    Think about the name Base_Data; do you have lots of tables without data? Silly, unh? 
    CREATE TABLE Base_Data
    (base_data_id CHAR(10) NOT NULL PRIMARY KEY,
    Your Links table is wrong in concept and implementation. The term “link” refers to a pointer chain structure used in network databases and makes no sense in RDBMS. There is no generic, magic, universal “id” in RDBMS! People that do this are called “id-iots”
    in SQL slang. 
    We can model a particular relationship in a table by referencing the keys in other tables. But we need to know if the relationship is 1:1, 1:m, or n:m. This is the membership of the relationship. Your narrative implies this: 
    CREATE TABLE Links
    (base_env_id CHAR(10) NOT NULL UNIQUE
       REFERENCES Base_Env (base_env_id),
     base_data_id CHAR(10) NOT NULL
       REFERENCES Base_Data (base_data_id));
    >> The base_env_id is unique in the table where as base_data_id can be repeated I.e multiple rows of Base_Env Table can point [sic] to same Base_Data table row. <<
    Again, RDBMS has no pointers! We have referenced an referencing tables. This is a fundamental concept. 
    That narrative you posted has no ON clauses! And the narrative is also wrong. There is no generic “name”, etc. What tables were used in your non-query? Replace the ?? in this skeleton: 
    SELECT ??.something_name, ??.sync_name, ??.something_version, 
           ??.ppo, ??.dom
    FROM Base_Env AS E, Links AS L, Base_Data AS D
    WHERE ?????????;
    >> I want to eliminate the duplicate records [sic], can any one help me here?<<
    Where is the sample data? Where is the results? Please read a book on RDBMS so you can post correct SQL and try again. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Help With Inner Join

    Hi,
    Can some one explain me this issue
    SELECT COUNT(*) FROM "ECCDATA"."CUST1"  O/P = 800
    SELECT COUNT(*) FROM "ECCDATA"."CUST1"  WHERE MANDT = '800' O/P = 800
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  O/P = 13779
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  WHERE MANDT = '800'    O/p = 13751
    SELECT COUNT(*) FROM ( SELECT T1."A1", T2."MANDT" FROM "ECCDATA"."CUST1" AS T1
    INNER JOIN  "ECCDATA"."A2" AS T2
    ON T1."A1" = T2."A1" AND
       T2."MANDT" = '800' )      O/P = 13783
    SELECT COUNT(*) FROM ( SELECT T1."A1", T2."MANDT" FROM "ECCDATA"."CUST1" AS T1
    INNER JOIN  "ECCDATA"."A2" AS T2
    ON T1."A1" = T2."A1" AND
       T1."MANDT" = T2."MANDT")      O/P = 13779
    Thanks

    Hi Hari,
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  O/P = 13779
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  WHERE MANDT = '800'    O/p = 13751
    The table "ECCDATA"."CUST2" must be having client specific data other than of 800 client. Try the below query and check it.
    SELECT DISTINCT MANDT from "ECCDATA"."CUST2";
    May be you check the same for other tables too.
    Sreehari

  • Help with Inner join problem

    The following query works fine as long as there is a value in the subID field, which is at the end of the inner join statement. If the subID is blank then no data is output, even though it is there. Try as I may, I can not get the right solution in the where statement to get the data to show without the subID. What am I missing?
    <cfquery name="getInfo" datasource="#application.database#">
    select page_id, pageName, pages.content, pages.cat_id, pages.seo_title,pages.seo_desc,pages.seo_words,pages.h1_title,pages.pic,pages.brochure,pa ges.video,catagories.catagory,subcat.subID,subcat.sub_category
    from (pages INNER JOIN catagories ON pages.cat_id = catagories.cat_id) INNER JOIN subcat ON pages.subID = subcat.subID
    where pages.page_id = #page_id#
    </cfquery>

    Rick,
    Looks like you need a LEFT OUTER join to the "subcat" table, so that all records for "pages" and "catagories" are returned even if no matching "subcat" records exist.  INNER joins will only return selected records when the tables on both sides of the join statement have matching values, while a LEFT OUTER (sometimes also known simply as a LEFT join) join will return *all* selected records from the table(s) on the left side of the join statement regardless of whether there are matching records from the table on the right side of the join statement.  When there are no matching records from the table on the right side of the join statement, any columns in your SELECT clause that are from the table on the right side of the join statement will contain NULLs.
    HTH,
    -Carl V.

  • Help: Modifying inner join

    Hello Folks,
    I have an Access Query and am rewriting the whole query in Oracle to run a report.The thing is Am a beginner in oracle and am scratching my head on how to modify this inner join. please help me in rewriting this inner join in oracle. thanks a million
       ((Debtor INNER JOIN MAX_TRANS_DATE AS MAX_TRANS_DATE_1 ON Debtor .
            EVENT_ID = MAX_TRANS_DATE_1.EVENT_ID) INNER JOIN
            TMP$ALL_RECOVERY_TYPE
            ON(Debtor . EVENT_CASE_ID = TMP$ALL_RECOVERY_TYPE . EVENT_CASE_ID) AND
            (Debtor . EVENT_ID = TMP$ALL_RECOVERY_TYPE . EVENT_ID))
    INNER JOIN CUBS TRANSACTIONS
        ON (Debtor . EVENT_ID = CUBS TRANSACTIONS . EVENT_ID)
       AND (Debtor . EVENT_CASE_ID = CUBS TRANSACTIONS . EVENT_CASE_ID)

    Thanks for getting back. But still am unable to get the correct data. I will try to break it down.
    Microsoft Access Table MAX_TRANS_DATE menitoned above in the inner join was originally coming from table called TRANSACTIONS i.e.( MAX_TRANS_DATE = SELECT [Transactions].[EVENT_ID], Max([Transactions].[TRANSDATE]) AS MaxOfTRANSDATE
    FROM Debtor INNER JOIN Transactions ON [Debtor].[EVENT_ID]=[Transactions].[EVENT_ID]
    GROUP BY [Transactions].[EVENT_ID];
    Here the problem is am recreating the access database query in oracle database and we dont have MAX_TRANS_DATE in the Oracle database but we do have TRANSACTIONS table.
    So i just used TRANSACTIONS in the inner join instead of MAX_TRANS_DATE.
    But the result is wrong.The Field Transdate from TRANSACTIONS is pulling dates as 10/5/2006 instead of 02/01/2010. I suspect something is wrong with the joins.Please help me. I can provide the old access query and the new oracle query that i have created.
    Thanks
    Edited by: user11961230 on Mar 5, 2010 11:49 AM

  • 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 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

  • What is left join /right join / out join/ inner join/please give example!

    what is left join /right join / out join/ inner join/please give example!
    thanks

    Maybe these examples will give you an idea...
    SQL> select * from t1;
            ID
             1
             2
             3
             4
    SQL> select * from t2;
            ID
             3
             4
             5
             6
    -- LEFT OUTER JOIN
    SQL> select t1.id, t2.id
      2  from t1 LEFT OUTER JOIN t2 ON (t1.id = t2.id);
            ID         ID
             3          3
             4          4
             1
             2
    -- RIGHT OUTER JOIN
    SQL> select t1.id, t2.id
      2  from t1 RIGHT OUTER JOIN t2 ON (t1.id = t2.id);
            ID         ID
             3          3
             4          4
                        6
                        5
    -- LEFT JOIN (SAME AS LEFT OUTER JOIN)
    SQL> ed
    Wrote file afiedt.buf
      1  select t1.id, t2.id
      2* from t1 LEFT JOIN t2 ON (t1.id = t2.id)
    SQL> /
            ID         ID
             3          3
             4          4
             1
             2
    -- RIGHT JOIN (SAME AS RIGHT OUTER JOIN)
    SQL> ed
    Wrote file afiedt.buf
      1  select t1.id, t2.id
      2* from t1 RIGHT JOIN t2 ON (t1.id = t2.id)
    SQL> /
            ID         ID
             3          3
             4          4
                        6
                        5
    -- INNER JOIN (REGULAR JOIN)
    SQL> ed
    Wrote file afiedt.buf
      1  select t1.id, t2.id
      2* from t1 INNER JOIN t2 ON (t1.id = t2.id)
    SQL> /
            ID         ID
             3          3
             4          4
    -- FULL OUTER JOIN
    SQL> ed
    Wrote file afiedt.buf
      1  select t1.id, t2.id
      2* from t1 FULL OUTER JOIN t2 ON (t1.id = t2.id)
    SQL> /
            ID         ID
             3          3
             4          4
             1
             2
                        6
                        5
    6 rows selected.
    SQL>

  • Help with access control please

    So I'm trying to set up my brother's PSP to the wirless network through MAC address timed access. What I want to do is make it so that he can only access it through certain times in the day. I'm having troubles with actually getting it to work. Everytime I set it up, the PSP only show's up as a DHCP client and not a Wireless client. I tried the option panel with the add wireless clients through the first try access. Could I get some help with this issue please? Thanks!

    Just to calm your fears... There is no conspiracy. If someone had an answer or a suggestion they would post it.

  • Help on Inner Join Query

    Hi ABAPers,
    I was trying to develop a report for which query is something like this.
    *& Report  ZT_SERIAL
    REPORT  ZT_SERIAL.
    TABLES : SER01,SER03,OBJK,LIKP,LIPS. " LIKP - SD invoice header table, LIPS - SD invoice details table
    TYPE-POOLS: SLIS.
    DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    MANDATORY WHILE DECLARING ALV ***
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
    DATA: V_EVENTS TYPE SLIS_T_EVENT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
    DATA : BEGIN OF ITAB OCCURS 0,
           OBKNR LIKE OBJK-OBKNR,     "OBJECT LIST
           OBZAE LIKE OBJK-OBZAE,     "OBJECT COUNTER
           KUNDE LIKE SER01-KUNDE,    "CUSTOMER NO
           MATNR LIKE OBJK-MATNR,     "PART NO
           SERNR LIKE OBJK-SERNR,     "SERIAL NO
           MBLNR LIKE SER03-MBLNR,    "GRN/MATERIAL DOC NO
           LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
           DATUM LIKE SER01-DATUM,    "OUTBOUND DELV DATE
           TASER LIKE OBJK-TASER,     "HEADER TABLE
           ANZSN LIKE SER01-ANZSN,    "NO OF SERIAL NOS
           VGBEL LIKE LIPS-VGBEL,     "SALES ORDER NO
           END OF ITAB.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
                      S_VGBEL FOR LIPS-VGBEL,
                      S_MATNR FOR OBJK-MATNR,
                      S_SERNR FOR OBJK-SERNR,
                      S_MBLNR FOR SER03-MBLNR,
                      S_LIFNR FOR SER01-LIEF_NR,
                      S_DATUM FOR SER01-DATUM.
    SELECTION-SCREEN : END OF BLOCK B1.
    PERFORM TRACKING.
    PERFORM FLDCAT.
    PERFORM BUILD_LAYOUT.
    ***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        I_GRID_TITLE       = I_TITLE_SL_NO_TRACK
        IS_LAYOUT          = LAYOUT
        IT_FIELDCAT        = P_FIELDTAB[]
        I_SAVE             = 'A'
        IT_EVENTS          = V_EVENTS
      TABLES
        T_OUTTAB           = ITAB.
    ***END OF CALL FUNCTION
    FORM TRACKING.
    SELECT OBJKOBKNR OBJKOBZAE OBJKMATNR OBJKSERNR OBJK~TASER
           SER01KUNDE SER01LIEF_NR SER01DATUM SER01ANZSN
           SER03~MBLNR
           LIPS~VGBEL
           INTO TABLE ITAB FROM OBJK
           INNER JOIN SER01 ON OBJKOBKNR = SER01OBKNR
           INNER JOIN SER03 ON OBJKOBKNR = SER03OBKNR
           INNER JOIN LIPS ON SER01LIEF_NR = LIPSVBELN
           WHERE
           OBJKTASER = 'SER01' OR OBJKTASER = 'SER03'.
           OBJK~MATNR IN S_MATNR AND
           OBJK~SERNR IN S_SERNR AND
           SER01~KUNDE IN S_KUNDE AND
           SER01~LIEF_NR IN S_LIFNR AND
           SER01~DATUM IN S_DATUM AND
           SER03~MBLNR IN S_MBLNR AND
           LIPS~VGBEL IN S_VGBEL.
    ENDFORM.
    *&      Form  fldcat
          text
    FORM FLDCAT.
      PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
      PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
      PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
      PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
      PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
      PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
      PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
    ENDFORM.                    "fldcat
    *&      Form  fldcat1
          text
         -->FNAM       text
         -->FTEXT      text
    FORM FLDCAT1 USING FNAM FTEXT.
        DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
              L_FIELDCAT-FIELDNAME  = FNAM.
              L_FIELDCAT-SELTEXT_M = FTEXT.
      IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
        L_FIELDCAT-KEY = 'X'.
      ENDIF.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    CLEAR fldcat1.
    ENDFORM.                                                    "fldcat1
    *&      Form  build_layout
          text
    FORM BUILD_LAYOUT .
      LAYOUT-NO_INPUT          = 'X'.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      LAYOUT-ZEBRA = 'X'.
      LAYOUT-TOTALS_TEXT       = 'Totals'(256).
    layout-coltab_fieldname = 'CELL_COLOUR'.
    *clear layout.
    ENDFORM.                   
    But when I run this query,the program gets terminated.Can you please help me in rectifying the query and generate the output?
    Thanks in advance
    Bhavin

    Hi
    I have corrected the code please copy and past it and then try.
    Report ZT_SERIAL.
    TABLES : SER01,SER03,OBJK,LIKP,LIPS.
    " LIKP - SD invoice header table, LIPS - SD invoice details table
    TYPE-POOLS: SLIS.
    DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
         + MANDATORY WHILE DECLARING ALV ***
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
    DATA: V_EVENTS TYPE SLIS_T_EVENT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
    DATA : BEGIN OF ITAB OCCURS 0,
    OBKNR LIKE OBJK-OBKNR, "OBJECT LIST
    OBZAE LIKE OBJK-OBZAE, "OBJECT COUNTER
    KUNDE LIKE SER01-KUNDE, "CUSTOMER NO
    MATNR LIKE OBJK-MATNR, "PART NO
    SERNR LIKE OBJK-SERNR, "SERIAL NO
    MBLNR LIKE SER03-MBLNR, "GRN/MATERIAL DOC NO
    LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
    DATUM LIKE SER01-DATUM, "OUTBOUND DELV DATE
    TASER LIKE OBJK-TASER, "HEADER TABLE
    ANZSN LIKE SER01-ANZSN, "NO OF SERIAL NOS
    VGBEL LIKE LIPS-VGBEL, "SALES ORDER NO
    END OF ITAB.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
    S_VGBEL FOR LIPS-VGBEL,
    S_MATNR FOR OBJK-MATNR,
    S_SERNR FOR OBJK-SERNR,
    S_MBLNR FOR SER03-MBLNR,
    S_LIFNR FOR SER01-LIEF_NR,
    S_DATUM FOR SER01-DATUM.
    SELECTION-SCREEN : END OF BLOCK B1.
    PERFORM TRACKING.
    PERFORM FLDCAT.
    PERFORM BUILD_LAYOUT.
    ***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_GRID_TITLE = I_TITLE_SL_NO_TRACK
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = P_FIELDTAB[]
    I_SAVE = 'A'
    IT_EVENTS = V_EVENTS
    TABLES
    T_OUTTAB = ITAB.
    ***END OF CALL FUNCTION
    FORM TRACKING.
    *SELECT OBJK~OBKNR
          OBJK~OBZAE
          OBJK~MATNR
          OBJK~SERNR
          OBJK~TASER
          SER01~KUNDE
          SER01~LIEF_NR
          SER01~DATUM
          SER01~ANZSN
          SER03~MBLNR
          LIPS~VGBEL
      INTO TABLE ITAB FROM OBJK
      INNER JOIN  SER01 ON OBJKOBKNR = SER01OBKNR
      INNER JOIN  SER03 ON OBJKOBKNR = SER03OBKNR
      INNER JOIN  LIPS ON SER01LIEF_NR = LIPSVBELN
      WHERE
    *( OBJKTASER = 'SER01' OR OBJKTASER = 'SER03' ) and
    *OBJK-MATNR IN S_MATNR AND
    *OBJK~SERNR IN S_SERNR AND
    *SER01~KUNDE IN S_KUNDE AND
    *SER01~LIEF_NR IN S_LIFNR AND
    *SER01~DATUM IN S_DATUM AND
    *SER03~MBLNR IN S_MBLNR AND
    *LIPS~VGBEL IN S_VGBEL.
    SELECT a~OBKNR         "OBJK
           a~OBZAE
           a~MATNR
           a~SERNR
           a~TASER
           b~KUNDE         "SER01
           b~LIEF_NR
           b~DATUM
           b~ANZSN
           c~MBLNR        "SER03
           D~VGBEL        "LIPS
       INTO TABLE ITAB FROM  ( OBJK as a
       INNER JOIN  SER01 as b ON aOBKNR = bOBKNR
       INNER JOIN  SER03 as c ON aOBKNR = cOBKNR
       INNER JOIN  LIPS as  d ON bLIEF_NR = dVBELN )
       WHERE
    ( aTASER = 'SER01' OR aTASER = 'SER03' ) and
    a~MATNR IN S_MATNR AND
    a~SERNR IN S_SERNR AND
    b~KUNDE IN S_KUNDE AND
    b~LIEF_NR IN S_LIFNR AND
    b~DATUM IN S_DATUM AND
    c~MBLNR IN S_MBLNR AND
    d~VGBEL IN S_VGBEL.
    ENDFORM.
    *& Form fldcat
       * text
    FORM FLDCAT.
    PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
    PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
    PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
    PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
    PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
    PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
    PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
    ENDFORM. "fldcat
    *& Form fldcat1
        text
        -->FNAM text
        -->FTEXT text
    FORM FLDCAT1 USING FNAM FTEXT.
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    L_FIELDCAT-FIELDNAME = FNAM.
    L_FIELDCAT-SELTEXT_M = FTEXT.
    IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
    L_FIELDCAT-KEY = 'X'.
    ENDIF.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    APPEND L_FIELDCAT TO P_FIELDTAB.
       * CLEAR fldcat1.
    ENDFORM. "fldcat1
    *& Form build_layout
       * text
    FORM BUILD_LAYOUT .
    LAYOUT-NO_INPUT = 'X'.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-ZEBRA = 'X'.
    LAYOUT-TOTALS_TEXT = 'Totals'(256).
       * layout-coltab_fieldname = 'CELL_COLOUR'.
    *clear layout.
    ENDFORM.
    Regards,
    Venkat

  • 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....

Maybe you are looking for

  • Error- "Tax code B0 country IN does not exist in procedure TAXINN"

    Hi to All, I'm working on a Import PO. While doing MIRO for planned delivery cost, I'm getting an error "Tax code B0 country IN does not exist in procedure TAXINN" I've assigned the Tax code to company code, but still I'm not able to solve this probl

  • How to change the desription of a standard SAP field in the Search Help

    Hi All, In Table T023T there is a field WGBEZ60(Long text describing the material group) and the data element of the field is WGBEZ60. Requirement is to change the description of the field WGBEZ60.The desription of the  field is - Description 2 for t

  • (unwanted) White borders when printing on Epson 3880 in LR5 (not in LR4)

    We have a customers who has been printing using LR4 for quite some time. Since she upgraded to LR5, she has issues that regularly, she get quite large white borders around the edges (seem like the printer is printing to a smaller page size, the photo

  • Manage files with uneven number of columns

    Hi- I am having a scenario where i have to load various files from a folder into a table. But few files having uneven number of columns. In that case I have to move those files into a different location. All these files are getting loaded through an

  • Set image in Table Header

    Hi, Is it possible to set a image in table header? I am using EP 6 NWDS 2.0.9 Regards, Vaibhav