Need clarification regarding select query

Hi,
I need a little clarification regrding a Select senario
I want to select data from table which have been minupulated between a certian date like between 1-DEC-10 to 31-DEC-10 and note that table does not have any time/date column. I've applied the following query to do this.
select * from TABLE_NAME where sysdate between to_date('01-DEC-10') AND to_date('31-DEC-10');
Would it work fine because I've tried it against a table and it returned me nothing however DML occur between time period.
Regards,
Abbasi

Abbasi wrote:
Hi,
I need a little clarification regrding a Select senario
I want to select data from table which have been minupulated between a certian date like between 1-DEC-10 to 31-DEC-10 and note that table does not have any time/date column. I've applied the following query to do this.
select * from TABLE_NAME where sysdate between to_date('01-DEC-10') AND to_date('31-DEC-10');
Would it work fine because I've tried it against a table and it returned me nothing however DML occur between time period.
Regards,
AbbasiAFAIK without log mining and auditing this is not possible.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm

Similar Messages

  • Need clarification on select query Urgent!!!!!

    Hi ,
    i want clarification about this query , because i want improve performence to report in ST05 it is showing 1,40,250 time so i need to do some thing on this please any body help me out.
    SELECT  matnr  werks  dispo
                 FROM   marc
                 INTO   TABLE  it_marc
                        WHERE  matnr  IN  s_matnr  AND
                               werks  IN  s_werks  AND
                               dispo  EQ  p_dispo.
        DESCRIBE TABLE it_marc  LINES w_lines.
        IF  w_lines  IS INITIAL.
          MESSAGE e518(zv) WITH p_dispo.
        ENDIF.
      ENDIF.
    thanks,
    murali.

    SELECT matnr
      FROM mara
      INTO TABLE it_mara
      WHERE matnr IN s_matnr.
    IF sy-subrc eq 0.
      SELECT matnr werks dispo
        FROM marc
        INTO TABLE it_marc
        FOR ALL ENTRIES IN it_mara
        WHERE matnr = it_mara-matnr
          AND werks IN s_werks
          AND dispo EQ p_dispo.
      DESCRIBE TABLE it_marc LINES w_lines.
      IF w_lines IS INITIAL.
        MESSAGE e518(zv) WITH p_dispo.
      ENDIF.
    ENDIF.
    I am sorry, but I comment also bad recommendations, if I find any. And the above example such
    a bad recommendation.
    SELECT matnr
      FROM mara
      INTO TABLE it_mara
      WHERE matnr IN s_matnr.
    The first select selects much more than you really need, while there is only a select single necessary.
      DESCRIBE TABLE it_marc LINES w_lines.
      IF w_lines IS INITIAL.
    It is also not necessary to count 1000 of lines, if you want to know whether there was at least one records, a check
    of a sy-subrc is much better. This should also be done in the original coding.
    As said above, check what is in s_matnr and s_werks and what is suppossed to come back.
    Siegfried

  • I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    Hi Arun ,
    Can you explain little bit more ??
    what is account doc no? 
    what are the transactions should be displayed in your output??
    -Rajesh N

  • Regarding SELECT query

    Dear experts,
    Is there a way for the following SELECT query to be improved?
    The problem that I'm seeing here is that the same table (l_item_tab) is being queried twice in the SELECT query (due to the "table joins", a and b). How can I improve the data retrieval here? And I also can't change the SELECT query to be out of the loop - ledger is a select-option and multiple values are possible.
    * Get Ledger
      SELECT * FROM t881 INTO TABLE lt_t881
        WHERE rldnr IN s_rldnr.
      LOOP AT lt_t881.
    *   Get FI-SL user-defined item table based on ledger
        PERFORM get_sl_item_tab USING lt_t881-rldnr CHANGING l_item_tab.
      " L_ITEM_TAB is populated here
    *   Get SL line items
        SELECT * APPENDING CORRESPONDING FIELDS OF TABLE gt_glu1
        FROM (l_item_tab) AS a
        WHERE
            rldnr         IN s_rldnr             " Ledger
        AND rbukrs        IN s_bukrs             " Company code
        AND ryyrkeg_wwsub IN s_wwsub             " Subsystem
        AND racct         IN s_racct             " Account no
        AND ryymac        IN s_yymac             " Management area
        AND rtcur         IN s_rtcur             " Trx currency
        AND docnr         IN s_docnr             " Doc. number
        AND docty         IN s_docty             " Doc. type
        AND docct         EQ c_docct_l           " Doc. category (L = Local)
        AND ryear         IN s_ryear             " Fiscal year
        AND budat         IN s_budat             " Posting date
        AND yystodt       IN s_stodt             " Reversal date
        AND yystgrd       IN s_stgrd             " Reversal reason
        AND yyintref      IN s_intref            " Interface ID
        AND NOT exists
          ( SELECT * FROM (l_item_tab) AS b
             WHERE
                 b~rldnr    = a~rldnr     AND
                 b~docnr    = a~docnr     AND
                 b~rbukrs   = a~rbukrs    AND
           ( ( ( b~docct    = c_docct_y
              OR b~docct    = c_docct_x ) AND
                 b~refryear = a~ryear )   OR
             ( ( b~docct    = c_docct_u
              OR b~docct    = c_docct_t ) AND
                 b~ryear    = a~ryear ) )
      ENDLOOP.
    Edited by: Rob Burbank on Jun 23, 2010 12:33 PM

    >
    Siegfried Boes wrote:
    > > Will certainly try this out too..
    > maybe you should think twice .... The usage of a subselect is that the result set is not transferred to the application server it is only needed
    > during the selection.
    >
    > You should anser the following questions:
    > + who wrote the code? you or? I get the impression that you don't know what is intended.
    > + SQL Trace, what are the numbers for repeated executions, (go to summary by SQL statement), duration, execution, records
    > + how many different tables are accessed, l_item_tab is dynamic
    > + what knid of tables are accessed?
    >
    > Siegfried
    Hi Siegfried,
    - The codes are currently existing ones and they were not written by me too. I just do know that the first / main SELECT statement in the query is for retrieving FI special ledger line item data records, while the second / sub SELECT statement is to ensure that the line item data records are not already reversed, and not a reversal.
    - In the summarized SQL trace of a sample test run: executions = 1, identical executions = 0, duration = 700247324 (almost 100% of the total processing durations), records = 0 (there should be more records returned in an actual production run)
    - Only one table, ZZGLV4A (custom) is accessed based on the selection screen variant. ZZGLV4A is an FI special ledger line item table and its data volume: 455 mil. data records. Note: The codes are written for a report that runs in the background, and the selection screen variant is used for the executions too. The table accessed (l_item_tab is ZZGLV4A in this case) depends on the ledger inputted here - only one ledger is specified for the current selection screen variant.
    - Table accessed - FI special ledger line item data.
    I tried tuning the query a little further by just properly specifying the WHERE fields - only a minimal improvement is observed, an average of about 6% of runtime improvement only (tested via SE30 in the development box for ZZGLV4A but its table volume is 4 mil. data records here only). This obviously works only for the table ZZGLV4A for now, I'm afraid.
    Any other ideas on how such subqueries can be improved generally (maybe secondary indexes)? The subquery is certainly re-hitting the same table at least twice.
    Thanks for the inputs once again!

  • Regarding select query Issue

    Hi ABAPERS,
          I had written one written one 'select single' query to retrieve the data from PRPS table.
    but what the data was selecting for OBJNR (Object number)field based on PSPNR(WBS element) .
    That OBJNR values in the report is totally different from the database table OBJNR  values.How its possible
    I am not getting.So can anyone please help me regarding this...
    Thanks and Regards
    Deepa

    Hi deepa,
    Pass the values to the select query where clause as you can see the values in SE16 display.(This is external format)
    If a table field as conversion routine, then SAP dosplay some thing on screen and store some thing else in data base.
    To check conversion exit go to domain of that field. Here you can see the routine used.
    For example you can check domain MATNR. Externally it display with leading zeros. But internally it stores with out zeros.
    Thanks,
    Vinod.

  • Regarding "select query" on performance basis..

    Hi Experts,
    I am creating an ALV report,so that i have to collect all data in 1 internal table.
    I have to collect data from 3 standard tables i.e.T157E,MSEG,MKPF.
    For all entries of T157E, i have to fetch data from MSEG.
    But in where condition i have to give POSTING DATE n this field is in MKPF.
    Also Database performance analysis is around 98%.
    How can i give better performance, please help..
    Below is my coding...
    (second select query is taking too much time,how can i rectify)
    SELECT BWART
                 GRUND
        FROM T157D
        INTO CORRESPONDING FIELDS OF TABLE IT_MOV_TYPE.
    SELECT MATNR
             MJAHR
             MBLNR
             BWART
             WERKS
             LGORT
             CHARG
             GRUND
             MENGE
             MEINS
        FROM MSEG
        INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
        FOR ALL ENTRIES IN IT_MOV_TYPE
       WHERE GRUND = IT_MOV_TYPE-GRUND
         AND BWART = IT_MOV_TYPE-BWART
         AND WERKS = PLANT
         AND LGORT IN ST_L.
      SORT IT_MSEG BY MBLNR.
      LOOP AT IT_MSEG.
        AT NEW MBLNR.
          SELECT SINGLE BUDAT
                   FROM MKPF
                   INTO V_BUDAT
                  WHERE MBLNR = IT_MSEG-MBLNR
                    AND MJAHR = IT_MSEG-MJAHR.
          SELECT SINGLE MAKTX
                   FROM MAKT
                   INTO V_MAKTX
                  WHERE MATNR = IT_MSEG-MATNR.
          SELECT SINGLE GRTXT
                   FROM T157E
                   INTO V_GRTXT
                  WHERE GRUND = IT_MSEG-GRUND.
        ENDAT.
        IT_MSEG-BUDAT = V_BUDAT.
        IT_MSEG-MAKTX = V_MAKTX.
        IT_MSEG-GRTXT = V_GRTXT.
        MODIFY IT_MSEG.
      ENDLOOP.
    Regards,
    Ankur

    Before you use
    FOR ALL ENTRIES IN
    Do the following :
    1. Sort the Internal table used in the 'FOR ALL ENTRIES IN' clause.
    2. Make sure they do not contain duplicates.
    3. Last and most importantly include a primary key field(Unique entry) in the select list. The reason, the system gets unique field records based on the where condition. It summarizes the data based on the Data type and field list in the target internal table.
    One should be sure the internal table, used in the FOR ALL ENTRIES clause is not empty. If the table is empty, ALL ENTRIES will be selected. (Actually, all WHERE clauses are neglected). Of course, you should also be sure you select on INDEX fields. Otherwise the use of FOR ALL ENTRIES increases the runtime instead of improving it.

  • Needs Clarification Regarding Segments and Datafiles

    Hi,
    I want clarification regarding Segments, Datafiles and extents.
    As we know that A segment is made of one or more extents and extents are composed of one or more datablocks in the HD.
    Since all data are store in Datafiles which are composed of extents and datablocks. I want to know weather a table(Segment) can span to multiple datafiles or in a sigle datafile.
    Regards,
    D.Abbasi

    And an easy way to check it by yourself :
    SQL> create tablespace abbasi_tbs
      2  datafile 'E:\ORADATA\DEMO111P\abbasi_01.dbf' size 1m autoextend off,
      3           'E:\ORADATA\DEMO111P\abbasi_02.dbf' size 1m autoextend off;
    Tablespace created.
    SQL> create table abbasi_tbl (id number)
      2  tablespace abbasi_tbs;
    Table created.
    SQL> insert into abbasi_tbl
      2  select rownum as rn
      3  from   dual
      4  connect by level <=10000;
    10000 rows created.
    SQL> commit;
    Commit complete.
    SQL> select distinct file_id
      2  from   dba_extents
      3  where  segment_name ='ABBASI_TBL';
       FILE_ID
             6
             7
    or...
    SQL> select distinct DBMS_ROWID.ROWID_RELATIVE_FNO(rowid)
      2  from   abbasi_tbl;
    DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)
                                       6
                                       7
    SQL> select file_name from dba_data_files where file_id in (6,7);
    FILE_NAME
    E:\ORADATA\DEMO111P\ABBASI_01.DBF
    E:\ORADATA\DEMO111P\ABBASI_02.DBF
    SQL>Nicolas.
    added the ROWID function usage
    Edited by: N. Gasparotto on Jun 21, 2009 11:02 AM

  • Needs Clarification Regarding Listener.ora file

    I want a clarification regarding listener.ora file I've Listener.ora file and its content look like as:
    # listener.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\listener.ora
    # Generated by Oracle configuration tools.
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = Oracle8)
    (SID_NAME = ORCL)
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.10)(PORT = 1521))
    I can understand every entry in this file accept the following
    *(SID_DESC =*
    *(SID_NAME = PLSExtProc)*
    *(ORACLE_HOME = C:\oracle\product\10.2.0\db_1)*
    *(PROGRAM = extproc)*
    *(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))*
    Although rest of entries refer to network services(Database name) and host address and protocol etc.
    what these above refere to.
    Please clarify me in this.
    Regards,
    D.Abbasi

    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
    (PROGRAM = extproc)
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    that about External Procedure, If you don't use "External Procedure" you can remove it, by the way you should avoid default configure.
    http://download.oracle.com/docs/cd/B19306_01/network.102/b14212/advcfg.htm#sthref1331
    http://download.oracle.com/docs/cd/B19306_01/network.102/b14212/advcfg.htm#NETAG0132
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_extern_proc.htm#sthref1658
    Sample create External Procedure:
    http://surachartopun.com/2008/07/create-and-run-sample-external.html

  • Need clarification regarding the test cable-diagnostics tdr command

    Hello,
    I've read about the test cable-diagnostics tdr command but I need clarification on the examples listed below to make sure that I am providing the right answer to my co-workers.
    Example 1:
    CXXX7SW17#show cable-diagnostic tdr int g0/20
    TDR test last run on: July 16 10:23:00
    Interface Speed Local pair Pair length        Remote pair  Pair status
    Gi0/20    auto  Pair A     N/A                        N/A                Normal
                           Pair B     72   +/- 10 meters  N/A                Open
                           Pair C     75   +/- 10 meters  N/A                Short/Crosstalk 
                           Pair D     74   +/- 10 meters  N/A                Short/Crosstalk
    Does this example mean that there's a cable length issue in the line which is causing the device that it's connected to not to work properly?
    Example 2:
    CXXX2SW140#show cable-diagnostics tdr int g0/21
    TDR test last run on: July 16 09:16:22
    Interface Speed Local pair Pair length        Remote pair Pair status
    Gi0/21    100M  Pair A     N/A                      Pair A           Normal
                              Pair B     N/A                      Pair B           Normal
                              Pair C     N/A                     Pair C           Normal
                              Pair D     N/A                     Pair D           Normal
    Does this example state that the cable line is okay for use?
    Example 3:
    CXXX1SW19#show cable-diagnostics tdr int g0/22
    TDR test last run on: July 16 06:36:53
    Interface Speed Local pair Pair length            Remote pair Pair status
    Gi0/22    auto    Pair A       1    +/- 10 meters  N/A               Open
                              Pair B     39   +/- 10 meters   N/A               Open
                              Pair C     72   +/- 10 meters   N/A               Open
                              Pair D     1    +/- 10 meters    N/A               Open
    Does this example mean that there isn't a device connected on the other end? No pin-contact?
    Thank you very much for any help you could provide.
    S

    I found this article here at supportforums that seemed like the best explanation I've read so far for TDR info.
    Hope that helps.

  • Need Clarification where SQL query is parsed either in Server or in Drivers

    hi all,
    i'm using OracleXEUniversal database and using Type4(thin) drivers to get communicate from Java.
    the queries what i'm giving programmatically, where it will get parse.
    either Server will parse, execute them and send back the results
    or thin drivers will parse query and the parsed query will send to Server and execute there and return the results.
    which one is correct.
    if it parsing at Server side only, what is the need of Cleint software.
    plz, clarify this doubt.
    regards
    pavan

    Parsing will be done in server side. Need of client software is to see the result.

  • Need help regarding sql query

    hii All
    I need help for pl/sql function.
    I build a function for monthly attendance all employees.
    but now i want to show all Sundays with 'S' and others respectively 'P' and 'A'.
    Currently Sunday also shows 'A'
    So please help
    SQL queries ... like
    SELECT DISTINCT AL.USERNAME,
    CASE WHEN DAY1 =1 THEN 'P' ELSE 'A' END DAY1,
    CASE WHEN DAY2 =1 THEN 'P' ELSE 'A' END DAY2,
    CASE WHEN DAY3 =1 THEN 'P' ELSE 'A' END DAY3,
    CASE WHEN DAY31 =1 THEN 'P' ELSE 'A' END DAY31
    FROM
    SELECT DISTINCT USERNAME, SUM(CASE WHEN
    fromdt=TRUNC(L.LOGIN_DATE) THEN
    1
    ELSE
    0
    END) DAY1
    ,SUM(CASE WHEN
    fromdt +1=TRUNC(L.LOGIN_DATE) THEN
    1
    ELSE
    0
    END) DAY2,
    SUM(CASE WHEN
    fromdt+30=TRUNC(L.LOGIN_DATE) THEN
    1
    ELSE
    0
    END) DAY31
    FROM ( SELECT DISTINCT TRUNC(LOGIN_DATE)LOGIN_DATE ,USERNAME FROM FCDM_AUDIT_TRAIL_NEW WHERE
    TRUNC(LOGIN_DATE) BETWEEN fromdt AND todt
    -- to_date( login_date, 'dd-mom-yyyy') between to_date( fromdt, 'dd-mom-yyyy') and to_date( todt, 'dd-mom-yyyy')
    ) L
    GROUP BY USERNAME
    ) AL;
    how can i show matched Sundays and show with 'SUN' or 'S'
    Regards
    vij..

    Try this way:
    SELECT USERNAME,
           MAX(CASE WHEN to_char(fromdt,'d')='1' and fromdt=TRUNC(L.LOGIN_DATE) THEN 'S'
                    WHEN to_char(fromdt,'d')!='1' and fromdt=TRUNC(L.LOGIN_DATE) THEN 'P'
                    ELSE 'A') DAY1,
           MAX(CASE WHEN to_char(fromdt+1,'d')='1' and fromdt+1=TRUNC(L.LOGIN_DATE) THEN 'S'
                    WHEN to_char(fromdt+1,'d')!='1' and fromdt+1=TRUNC(L.LOGIN_DATE) THEN 'P'
                    ELSE 'A') DAY2,
           MAX(CASE WHEN to_char(fromdt+30,'d')='1' and fromdt+30=TRUNC(L.LOGIN_DATE) THEN 'S'
                    WHEN to_char(fromdt+30,'d')!='1' and fromdt+30=TRUNC(L.LOGIN_DATE) THEN 'P'
                    ELSE 'A') DAY31
    FROM
    (SELECT DISTINCT TRUNC(LOGIN_DATE) LOGIN_DATE,
            USERNAME
       FROM FCDM_AUDIT_TRAIL_NEW
      WHERE TRUNC(LOGIN_DATE) BETWEEN fromdt AND todt
    ) L
    Group by USERNAME
    ;Max
    http://oracleitalia.wordpress.com

  • Needs Clarification Regarding Tablespace

    Hello,
    I'm using Oracle 10g DB and I want to know weather to creating database from DBCA automatically create a tablespace for that database or we have to create manually.
    if it create automatically then how can we retrive information about that database.
    Looking for Reply
    Regards,
    D.Abbasi

    When you create database using DBCA you can choose tempalte, in the template there tablespaces defined, the tablespaces that will be created depends on the tamplate you choose, and if you installed sample schema's.
    Every database created need to have several system tablespaces.
    You can retrive all of database tablespaces using :
    select name from v$tablepsace;
    Oded
    [www.dbsnaps.com]
    [www.orbiumsoftware.com]

  • Need help in Select Query

    Hello,
    I am using oracle 9i and windows XP:
    Please help me to making a query to get output as mentioned below:
    create table myt(col1 varchar2(10));
    insert into myt values('TABLE1');
    insert into myt values('TABLE2');
    insert into myt values('TABLE3');
    COMMIT;
    create table table1(name varchar2(10),amount number);
    create table table2(name varchar2(10),amount number);
    create table table3(name varchar2(10),amount number);
    insert into table1 values('James',1000);
    insert into table1 values('David',1500);
    insert into table1 values('James',2000);
    insert into table1 values('David',1735);
    insert into table2 values('Menon',500);
    insert into table2 values('Martin',700);
    COMMIT;
    Required Output:
    Table Name
    Table1
        James: 3000
        David: 3235
        Sum:   6235
    Table2
        Menon:  500
        Martin: 700
        Sum:   1200
             -------Regards

    In your solution i added some modifications and got the output:
    declare
    cr_lf varchar2(2) := chr(13) || chr(10);
    the_cursor sys_refcursor;
    the_sql varchar2(4000) := 'select * from ' || cr_lf || '(' || cr_lf;
    a_table varchar2(10);
    ln varchar2(10);
    a_name varchar2(10);
    an_amount number:=0;
    tan_amt number:=0;
    i number;
    j varchar2(4000);
    begin
    for the_row in (select col1 from myt) loop
    the_sql := the_sql || 'select ''' || the_row.col1 || ''',name,sum(amount) from ' || the_row.col1 || ' group by name ' || cr_lf;
    the_sql := the_sql || 'union all' || cr_lf;
    end loop;
    the_sql := substr(the_sql,1,length(the_sql) - 11) || ')' || cr_lf;
    i := 1;
    j := instr(the_sql,cr_lf,i);
    while i > 0 loop
    exit when j = 0;
    dbms_output.put_line(substr(the_sql,i,j - i));
    i := j + 2;
    j := instr(the_sql,cr_lf,i);
    end loop;
    dbms_output.put_line(substr(the_sql,i));
    --dbms_output.put_line(the_sql);
    open the_cursor for the_sql;
    dbms_output.put_line('--------------------------------------------------------------------------');
    dbms_output.put_line(rpad('TABLE',20) || ' ' || rpad('NAME',20) || ' ' || rpad('AMOUNT',20));
    dbms_output.put_line('--------------------------------------------------------------------------');
    loop
    ln:= a_table;
    fetch the_cursor into a_table,a_name,an_amount;
    exit when the_cursor%notfound;
    if ln<>a_table then
    dbms_output.put_line('--------------------------------------------------------------------------');
    dbms_output.put_line(rpad('SUM',40) || lpad(to_char(tan_amt),10));
    dbms_output.put_line('--------------------------------------------------------------------------');
    tan_amt:=0;
    end if;
    tan_amt:= tan_amt+an_amount;
    dbms_output.put_line(rpad(a_table,20) || ' ' || rpad(a_name,20) || ' ' || rpad(an_amount,20));
    end loop;
    dbms_output.put_line('--------------------------------------------------------------------------');
    --dbms_output.put_line(rpad('SUM',45) || to_char(tan_amt));
    dbms_output.put_line(rpad('SUM',40) || lpad(to_char(tan_amt),10));
    dbms_output.put_line('--------------------------------------------------------------------------');
    close the_cursor;
    end;
    select * from
    select 'TABLE1',name,sum(amount) from TABLE1 group by name
    union all
    select 'TABLE2',name,sum(amount) from TABLE2 group by name
    union all
    select 'TABLE3',name,sum(amount) from TABLE3 group by name
    TABLE                  NAME                  AMOUNT
    TABLE1                 David                  6470
    TABLE1                 James                  6000
    SUM                                          12470
    TABLE2                 Martin                 1400
    TABLE2                 Menon                  1000
    SUM                                           2400
    --------------------------------------------------------------------------So many thanks for providing solution to me.
    Regards

  • Regarding select query with code

    Hi Experts ,
    i m taking two transparent table "VBAK , VBAP" WITH CLUSTER TABLE "KONV"
    In this Table we create inner join between VBAK ,ABAP  to itab and make  itab2 with some field of KONV.
    ===========================================================
    *& Report  Z_VBAP_REPORT                                               *
    REPORT  Z_VBAP_REPORT    .
    TABLES:VBAP,VBAK,KONV.
    DATA KNUMV LIKE VBAK-KNUMV.
    DATA:BEGIN OF ITAB OCCURS 0,
         VBELN LIKE VBAK-VBELN,
         POSNR LIKE VBAP-POSNR,
         MATNR LIKE VBAP-MATNR,
         NETPR LIKE VBAP-NETPR,
         BNAME LIKE VBAK-BNAME,
         ERDAT LIKE VBAK-ERDAT,
         KBETR LIKE KONV-KBETR,
         KNTYP LIKE KONV-KNTYP,
         KNUMV LIKE VBAK-KNUMV,
         END OF ITAB.
    DATA ITAB2 LIKE ITAB OCCURS 0 WITH HEADER LINE.
    PARAMETER SALE_DOC LIKE VBAK-VBELN.
    SELECT-OPTIONS D_DATE FOR VBAK-ERDAT.
    SELECT BVBELN APOSNR AMATNR ANETPR BBNAME BERDAT INTO
    CORRESPONDING FIELDS OF TABLE ITAB FROM VBAP AS A INNER JOIN VBAK
    AS B ON ( BVBELN = AVBELN ) WHERE B~ERDAT IN D_DATE AND
    A~VBELN =  SALE_DOC.
    SELECT  KBETR KNTYP  FROM KONV INTO CORRESPONDING FIELDS OF TABLE ITAB2
    WHERE KNUMV = KNUMV .
    EXPORT ITAB TO MEMORY ID 'ASHISH'.
    EXPORT ITAB2 TO MEMORY ID 'ASHISH1'.
    SUBMIT Z_ABAP2 VIA SELECTION-SCREEN AND RETURN.
    ///////Code for report Z_ABAP2
    *& Report  Z_ABAP2                                                     *
    REPORT  Z_ABAP2   .
    TABLES:VBAP,VBAK,KONV.
    DATA:BEGIN OF ITAB OCCURS 0,
         VBELN LIKE VBAK-VBELN,
         POSNR LIKE VBAP-POSNR,
         MATNR LIKE VBAP-MATNR,
         NETPR LIKE VBAP-NETPR,
         BNAME LIKE VBAK-BNAME,
         ERDAT LIKE VBAK-ERDAT,
         KBETR LIKE KONV-KBETR,
         KNTYP LIKE KONV-KNTYP,
         KNUMV LIKE VBAK-KNUMV,
         END OF ITAB.
    DATA ITAB2 LIKE ITAB OCCURS 0 WITH HEADER LINE.
    LOOP AT ITAB.
    WRITE : / ITAB-VBELN,
               ITAB-POSNR, 25
               ITAB-MATNR,
               ITAB-NETPR,
               ITAB-BNAME,
               ITAB-ERDAT,
               ITAB-KBETR,
               ITAB-KNTYP.
    ENDLOOP.
    LOOP AT ITAB2.
    WRITE :/   ITAB2-KBETR,
               ITAB2-KNTYP.
               ENDLOOP.
    INITIALIZATION .
      IMPORT ITAB FROM MEMORY ID 'ASHISH'.
      IMPORT ITAB2 FROM MEMORY ID 'ASHISH1'.
    =========================================================
    thanks & regards ,
    Ashish

    Hi
    after the first select use for all entries of this ITAB and fetch data from KONV as below, declare I_FINAL and move the ITAB and ITAB2 data into it and display its output
    SELECT BVBELN APOSNR AMATNR ANETPR BBNAME BERDAT <b>B~KNUMV</b> INTO
    CORRESPONDING FIELDS OF TABLE ITAB FROM VBAP AS A INNER JOIN VBAK
    AS B ON ( BVBELN = AVBELN ) WHERE B~ERDAT IN D_DATE AND
    A~VBELN = SALE_DOC.
    <b>IF NOT ITAB[] IS INITIAL.
    SELECT KNUMV KPOSN KBETR KNTYP FROM KONV INTO CORRESPONDING FIELDS OF TABLE ITAB2 for all entries in ITAB
    WHERE KNUMV = ITAB-KNUMV and KPOSN = ITAB-POSNR .</b>
    Loop at itab.
      move-corresponding itab to i_final.
      read table itab2 with key knumv = itab-knumv and kposn = itab-posnr.
      if sy-subrc  = 0.
        move-corresponding itab2 to i_final.
      endif.
    append i_final.
    clear i_final.
    endloop.
    Loop at i_final.
       write: / I_final (write all the fields)
    endloop.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Issue regarding Select Query

    Hello experts,
    I want a join on table ekpo & mbew(for valuation class).
    But its not working.
    if valclass is initial.
    select  aebeln aebelp atxz01 amatnr abukrs awerks a~menge
    a~mtart
    b~bklas
    from  ekpo  as a inner join  mbew as b on bmatnr eq amatnr
    into corresponding fields of table ekpo_mbew
    where  ( a~matnr eq mat_num ) and
    ( a~bukrs eq compcode ) and
    ( a~werks eq plant ) and
    ( a~mtart eq mat_type ) and
    b~bklas  in ('3001','3045' ,'3006','3055','3065') and
    ( amatnr eq bmatnr ).
    else.
    select  aebeln aebelp atxz01 amatnr abukrs awerks a~menge
    a~mtart
    b~bklas
    from  ekpo  as a inner join  mbew as b on bmatnr eq amatnr
    into corresponding fields of table ekpo_mbew
    where  ( a~matnr eq mat_num ) and
    ( a~bukrs eq compcode ) and
    ( a~werks eq plant ) and
    ( a~mtart eq mat_type ) and
    ( b~bklas  in valclass ) and
    ( amatnr eq bmatnr ).
    endif.
    Plz tell where I m wrng.
    Ravi.

    Hi,
         Try the below code,
    SELECT aebeln aebelp atxz01 amatnr abukrs awerks a~menge
    a~mtart
    b~bklas
    FROM ekpo AS a INNER JOIN mbew AS b ON bmatnr EQ amatnr INTO CORRESPONDING FIELDS OF TABLE ekpo_mbew
    WHERE  a~matnr EQ mat_num AND
                   a~bukrs EQ compcode AND
                   a~werks EQ plant AND
    a~mtart EQ mat_type AND
    b~bklas IN ('3001','3045' ,'3006','3055','3065').
    ELSE.
    SELECT aebeln aebelp atxz01 amatnr abukrs awerks a~menge
    a~mtart
    b~bklas
    FROM ekpo AS a INNER JOIN mbew AS b
    ON bmatnr EQ amatnr
    INTO CORRESPONDING FIELDS OF TABLE ekpo_mbew
    WHERE  a~matnr EQ mat_num AND
    a~bukrs EQ compcode  AND
    a~werks EQ plant AND
    a~mtart eq mat_type AND
    b~bklas IN valclass .
    Note :- ( amatnr eq bmatnr ) this is not necessary as the INNER JOIN is on that condition itself.
    Regards
    Bala Krishna

Maybe you are looking for