Hello experts read table statement is not working properly

Hello Experts.
my code is like this.
sort it_matnr by matnr.
loop at itab_result.
read table it_matnr with key matnr = itab_result-matnr  binary search.
endloop.
there are nearly 2000 records in it_matnr . The records which satisfy the above condition is there here in this internal table. But it is unable to read the record which matches the condition. One thing is that , there are more than one record with the same material. ie mblnr is different but material is the same. In it_matnr table i have only 1 field ie matnr ,so i need to compare only with the matnr.I also tried by sorting it_result by matnr but of no use. Then finally I used loop at where matnr = it_result-matnr , it is working fine. But due to performance reasons we should not use this. so please tell me what to do and correct the code.

1. Make sure that the table IT_MATNR is not getting updated inside the loop. Because it will then destroy the sorting.
2. Secondly, if there are multiple records in IT_MATNR for the same material then it will search for the first record encountered in binary algo. So it is advisable that you may provide further filter criteria if possible. check if ITAB_RESULT & IT_MATNR have any other matching field that can be put in filter criteria.
3.Thirdly, check if your requirement can be achieved by STABLE SORT.
<b>SORT <itab> ... STABLE BY <f1>[ASCENDING/DESCENDING].</b>
It will allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort.
4. Lastly, you can use parallel cursor technique of multiple loops which is given below:
LOOP AT itab_result.
  READ TABLE it_matnr
    WITH KEY matnr = itab_result-matnr
    BINARY SEARCH.
Process record
  LOOP AT it_matnr FROM sy-tabix.
    IF it_matnr <> itab_result-matnr.
      EXIT.
    ENDIF.
Process record based on yuor condition
  ENDLOOP.
ENDLOOP.

Similar Messages

  • Hello My ipads Power button is not working properly when I press it once it shows option to turn off instead of locking and some other display problems like it suddenly lockes down or display disappears ...Please help. Thank You

    Hello My ipads Power button is not working properly when I press it once it shows option to turn off instead of locking and some other display problems like it suddenly lockes down or display disappears ...Please help. Thank You

    Thanks for that information!
    I'm sure I will be calling AppleCare, but the problem is, they charge for the phone calls don't they? Because I don't have money to be spending to be on the phone with a support service.
    In other things, it seemed like the only time my MacBook was working was when I had Snow Leopard without the 10.6.8 update download that was supposed to be done to prepare for OS X Lion.
    When I look at the information of my HD it says that I have 10.6.8 but that was the install that it claimed to have failed and caused me to restart resulting in all of the repeated problems.
    Also, because my computer is currently down, and I've lost all files how would that effect the use of my iPhone? Because if it doesn't get fixed by the time OS 5 is released, how would I be able to upgrade?!

  • Table date filter not working properly

    Hi OTN,
    I have noticed that table date filter not always working properly.
    When I copy actual value from column outputText to column filter and hit Enter - I see an empty table.
    http://imageshack.us/photo/my-images/818/filter.png/
    I suspect the problem to lie among date formats.
    But I tried to delete convertDateTime from outputText or add it under filter inputDate. Nothing helped.
    <af:column sortProperty="Hisdate" sortable="true"
                                     headerText="#{bindings.InformationView1.hints.Hisdate.label}"
                                     id="c8" visible="false" filterable="true"
                                     width="83">
                            <af:outputText value="#{row.Hisdate}" id="ot5">
                              <af:convertDateTime pattern="#{bindings.InformationView1.hints.Hisdate.format}"/> // or without both lines
                            </af:outputText>
                            <f:facet name="filter">
                              <af:inputDate id="id15"
                                            value="#{vs.filterCriteria.Hisdate}"
                                            columns="8">
                                <af:convertDateTime pattern="#{bindings.InformationView1.hints.Hisdate.format}"/> // or without both lines
                              </af:inputDate>
                            </f:facet>
                          </af:column>Nothing special about the attribute. A database table field of type DATE. In database this (see picture) row has exactly "06.06.2006".
    Could you please point me out where to start seeking?
    Thanks.
    JDev 11.1.1.4

    Well, OK. I think I'd better have 2 attributes: truncated date for filter and full date with time for edit.
    What is an attribute type for datetime?
    select trunc(t.HISDATE) AS HISDATE -- date attribute type
        ,to_char(t.HISDATE, 'dd.mm.yyyy hh24:mi') AS HISDATETIME -- timestamp/date attribute type?Something like this?

  • Read-only bind mounts not working properly

    Hello,
    I discovered a strange behavior regarding mount --bind on my system. In the past I could create read-only bind mounts using first a mount --bind /source /dest and after that mount -o remount,ro /dest. But since some kernel update (not sure which) this procedure results in the complete filesystem of the source being remounted read-only, not only the /dest mountpoint. I also saw that bind-mounts are not shown as such in the outbput of mount:
    the mountpoint was created using
    mount --bind /mnt/data/Backup/vserver/Daten /mnt/data/homes/vserver/Daten
    and results in the following output of mount:
    /dev/mapper/data on /mnt/data/homes/vserver/Daten type ext4 (rw,noatime,nodiratime,user_xattr,acl,barrier=1,stripe=64,data=ordered)
    so its reported as if i mounted the parent fs (/dev/mapper/data on /mnt/data) to the directory.
    Does anyone know what caused this behavior, and how to get read-only bind-mounts back to a working condition?
    Thanks in advance,
    seiichiro0185

    R00KIE wrote:
    You could use the "alternative" way of doing it, which is exemplified in the manual page: '
    mount --bind olddir newdir
    mount -o remount,ro,bind olddir newdir
    Here I can reproduce your problem but the "alternative" way seems to work fine.
    That's not the alternative way, that's the only way. Though, you don't need to specify both the source and dest on the remount -- just the dest.
    Last edited by falconindy (2012-01-31 13:32:12)

  • Insert statement is not working properly

    I've problem in inserting values in database.I'm able to retrieve data from a table, but I'm not able to store any values in a table.I've got no runtime error.In code, executeUpdate() statement is also returning 1(which shows successful execution).
    PROGRAM CODE:
    import java.io.*;
    import java.sql.*;
    public class test1
         public static void main(String args[])
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con=DriverManager.getConnection("jdbc:odbc:office");
                   Statement st=con.createStatement();
                   String query="insert into nam values('[email protected]')";          
                   int i=st.executeUpdate(query);
    System.out.println(i);
              catch(Exception e)
                   System.out.println(e);
    Eagerly Expecting a solution
    Thanks & Regards
    Venki

    Will not help, if he didn't change AutoCommit to false.
    An idea: Do you use Access?
    Then it might be this one again:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=147704

  • Hello, I have IPhone 4. its not working properly,

    Hello
    My IPhone 4 its blocking a lot of times during day, the problem is when I access to any application works, but when I want to back to the main menu I press a lot times the bottom but its blocking and take a lot time to back to the main menu.
    I tried to reboot it, reinstall the OS, the version is 4.3
    Can you please help me?
    do you have any idea?
    thanks
    Mario

    version should be 4.3.5,try the basic trouble shooting steps
    go to settings>general>reset>rest all settings phone will turn off and turn on by itself
    once the phone is press and hold the home and power button at the same time wait for the apple sign then release the buttons phone will turn off and on

  • Insert statement is not working for z table.

    Hi experts,
    My insert statement is not working.
    I have used follwing code to update z table .
    INSERT ztable FROM TABLE gt_table.
    here i have checked gt_table and its filled up with all the records properly.
    now the problem is in this table i have 15 fields and it inserts 14  fields of it but
    the last field is never inserted though in gt_table i can see value for last fields also.
    I have added this field in ztable recently . so i also used se14 to adjust table but still i am facing same problem.
    please help me out.
    thanks,
    Neo

    > > Table maintainance will have nothing to do with
    > this
    > > issue.
    >
    > It does sometimes when you are trying to see the
    > values from SM30 instead of SE16. The value may be
    > there, but it may just not seen in SM30 because the
    > table maintenance hasn't registered the addition of
    > new field.
    >
    > Another place to look at is the activation log to see
    > if there are any warnings issued there.
    You shouldn't use SM30 to view table entries. You use this transaction to maintain the table entries. Pure and Simple.

  • Delete Statement is not working correctly

    Hello,
    The following delete statement is not working correctly.
    If I press delete it will delete everything in the category table
    I don't know whats wrong with it.
    ----delete row from category if there is not infrastructure to support------
    IF :P12_DFCY_SEQNO4 IS NOT NULL AND :P12_DFCY_CATG_C = '7' THEN
    DELETE FROM DFCY_CATG
    WHERE NOT EXISTS(SELECT I.DFCY_SEQNO
    FROM DFCY_CATG C, DFCY_CATG_INFRSTRCTR I
    WHERE C.DFCY_SEQNO = I.DFCY_SEQNO
    AND :P12_DFCY_SEQNO4 = I.DFCY_SEQNO);
    end if;
    Thanks
    Mary

    Hi,
    IF :P12_DFCY_SEQNO4 IS NOT NULL AND :P12_DFCY_CATG_C = '7' THEN
    DELETE FROM DFCY_CATG
    WHERE NOT EXISTS(SELECT I.DFCY_SEQNO
    FROM DFCY_CATG C, DFCY_CATG_INFRSTRCTR I
    WHERE C.DFCY_SEQNO = I.DFCY_SEQNO
    AND :P12_DFCY_SEQNO4 = I.DFCY_SEQNO);
    end if;So, if P12_DFCY_SEQNO4 does not exist, then I would expect all records to be deleted because the NOT EXISTS() function would just return TRUE for every record on the table. Somewhere in the statement, I would expect to see something that links between the table being deleted from and the NOT EXISTS() data or, perhaps, using the P12_DFCY_CATG_C value as a filter?
    Andy

  • Multiple panels not working properly

    I've added an additional read less at the bottom of each tab panel on the page.
    http://summiticemelt.com/productstestmar4.php
    1. The page opens with the #2  & 3 tabs open, even though they are set to false.
    2. The read less function does not work properly with tabs 2 & 3.
    I'm new to Spry and .js and pieced this together based on what I could find in the forums.

    There are a few problems that I have noticed so far.
    Line #1 <!doctype html5> is not recognised, hence the page will revert back to HTML 4.01 Transitoinal. It should read <!doctype html>
    Line #51 (links to) style rules should be placed in the <head> element, not in the <body> element
    Lines #124, #159 and #188 all link to the same JS file. Delete two of them.
    Lines #126, #161 and #207 contain a constructor for the same widget. The former two should be deleted.
    Lines #190 and #208 contain a constructor for the same widget. The former should be deleted
    Although JS can be placed anywhere in a document, I tend to place all JS at the bottom, just above the ending body tag (</body>) unless the JS is required for rendering purposes in which case it should be placed where it is required. This way, you can keep check of what you have linked to and which constructors you have created thus eliminating the problems mentioned above.
    Also you might like to have a look at a collapsible panel group http://labs.adobe.com/technologies/spry/samples/collapsiblepanel/CollapsiblePanelGroupSamp le.html. This will simplify the code somewhat.
    Gramps

  • CASE Statement is not working Derived table

    Hi All,
    in the bello SQL Statement case statement is not working in derived table. I am new to creation of derived table if any body knows plz kinldy help me out on this.
    SELECT x.market, x.droprate as med1
    FROM
    (select upper(market_name) as market, fulldate as date_value,
         (sum([Dy_LOT_DROPS_N][Dy_OB_HO_DROPS][Dy_NonRF_Drop]))/
              nullif(sum(CASE WHEN (month(BBHDLY.FullDate)}>= 6 and { year(BBHDLY.FullDate)} = 2011) or {fn year(IDENSLABBHDLY.FullDate)} > 2011
    THEN  BBHDLY.Dy_Calls - BBHDLY.Dy_HO_CHAN_ALLOC ELSE BBHDLY.Dy_Calls END),0)*100 as droprate
    from BBHDLY sla
    inner join Dim mkt
         on sla.bts_name = mkt.bts_name and sla.SectorID = mkt.Sector_Id
                   where fulldate >= GETDATE()-46
                   group by market_name, fulldate) x,
    (select market_name as market, fulldate as date_value,
    (sum([Dy_LOT_DROPS_N][Dy_OB_HO_DROPS][Dy_NonRF_Drop]))/
              nullif(sum(CASE WHEN ({fn month(BBHDLY.FullDate)}>= 6 and {fn year(BBHDLY.FullDate)} = 2011) or {fn year(BBHDLY.FullDate)} >
    2011 THEN  BBHDLY.Dy_Calls - BBHDLY.Dy_HO_CHAN_ALLOC ELSE BBHDLY.Dy_Calls END),0)*100 as droprate
    from BBHDLY sla
    inner join Dim mkt
         on sla.bts_name = mkt.bts_name and sla.SectorID = mkt.Sector_Id
                   where fulldate >=GETDATE()-46
                   group by market_name, fulldate) y
    where x.market = y.market
    GROUP BY x.droprate, x.market
    HAVING
       SUM(CASE WHEN y.droprate <= x.droprate
          THEN 1 ELSE 0 END)>=(COUNT(*)+1)/2 AND
       SUM(CASE WHEN y.droprate >= x.droprate
          THEN 1 ELSE 0 END)>=(COUNT(*)/2)+1
    Thanks

    It looks like SQL Server or Sybase given that you're using getdate().
    As such, Vinesh's comment to use decode is wrong - decode is  Oracle syntax.
    Looking at your statement again, I've noticed the following:
    you have no { to match the first } - not sure why you're using them anyway.
    you haven't given x.market a name - use x.market as market instead
    use coalesce instead of nullif if you're on SQL Server.

  • How to get the number of hits ("returned rows") in read table statement

    Hi Experts
    I have the statement shown below, which seems not to work as I would like it to. My problem is that I would like to do two different things depending on weather or not a read table statement results in 0 hits or 1 (or more) hits.
        READ TABLE g_ship_item
            WITH KEY
         l_ztknum = DATA_PACKAGE-/bic/ztknum
         BINARY SEARCH.
          IF sy-subrc is initial.
          no hits found
            DATA_PACKAGE-/BIC/ZSTAGEERR = 1.
          ELSE.
          hits where found and we will do something else...
            DATA_PACKAGE-/BIC/ZSTAGEERR = 0.
    Hope someone can help me out of my problem...
    Thanks in advance, regards
    Torben

    Hi,
    As you are using READ statement with Binary search, check whether the internal table g_ship_item is sorted with field /bic/ztknum or not. If it is not sorted then the result of this READ statement is not correct.
    Below is the correct code.
    sort  g_ship_item by /bic/ztknum.
    READ table g_ship_item with key g_ship_item = xxx.
    Thanks,
    Satya

  • Delete statement is not working.

    Hi,
    find the code. Here the delete statement is not working and i am getting sy-subrc = 4. although ,
    xe1edp10-idnkd = 34596 and dint_edidd -sdata = 34596.
    please help me ...
    loop at dekek_x.
    loop at dint_edidd where segnam = 'E1EDP10'.
    if dekek_x-stpin = 1 .
    CLEAR xe1edp10.
      MOVE dint_edidd-sdata TO xe1edp10.
    delete dint_edidd where sdata = xe1edp10-idnkd.
    endif.
    endloop.

    1st thing..
    i tried this :
    tables: edidd, e1edp10.
    edidd-sdata = '315934 EA 017'.
    WRITE edidd-sdata.
    move edidd-sdata to e1edp10.
    IF edidd-sdata = e1edp10-idnkd.
    WRITE: e1edp10-idnkd.
    else.
      WRITE: 'nothing'.
    ENDIF.
    output
    >315934 EA 017
    >315934 EA 017
    2nd thing,.
    your loop inside loop doesnt make any sense as they are not related any where.
    3rd thing:
    the fields are not type compatible.. this might be the reason for wrong delete statement..
    and 1 more clarification:
    TABLES: edidd, e1edp10.
    DATA :it TYPE TABLE OF edidd WITH HEADER LINE.
    edidd-sdata = '315934 EA 017'.
    WRITE edidd-sdata.
    APPEND edidd TO it.
    edidd-sdata = '315934 EA 018'.
    APPEND edidd TO it.
    LOOP AT it." where segnam = 'E1EDP10'.
      CLEAR e1edp10.
      MOVE it-sdata TO e1edp10.
      DELETE it WHERE sdata = e1edp10-idnkd.
    ENDLOOP.
    in this also delete is working perfectly fine... you run and check..

  • Table range is not working!!

    Hello all,
    I am using the JHeadstart 10.1.3 production (build 91) and JDeveloper 10.1.3
    I have a main group and 2 detail groups (nested) and regions on the main group. I tried to limit the number of rows by the "table rangë", by selecting it and putting the number of rows and its not showing on the page. I am getting the entire rows.
    any comments about it
    thanks
    san

    San,
    Hmm, very strange. Is this the only page where table range is not working? Can you try creating a new project from scratch and see whether it works correctly there?
    Steven Davelaar,
    JHeadstart Team.

  • Need help regarding Dynamic Read Table statement

    Hello
    I know that the syntax for dymanic read table statement is
    READ TABLE  <ITAB> WITH KEY (KEY1) = VALUE1  (KEY2) = VALUE2 .....(KEYN) = VALUEN
    Here is my problem..
    I am dynamically creating an internal table based on parameter table entered by user.
    The key for this table can be determined only at runtime.
    The table entered might have by one field as key field or 10 key fields..
    How can I use the dynamic read in this situation ?
    Thanks for your help in advance,
    Santosh
    Edited by: Santosh Kulkarni on Jan 3, 2010 6:58 AM
    Edited by: Santosh Kulkarni on Jan 3, 2010 7:01 AM

    Hello Santosh,
    please check out the following solution. The program demonstrates how to use the dynamic read statement with three key field conditions. Additional key fields can be added in the same way.
    REPORT z_dynamic_read.
    DATA: gt_itab TYPE REF TO data,
          ge_key_field1 TYPE char30,
          ge_key_field2 TYPE char30,
          ge_key_field3 TYPE char30,
          go_descr_ref TYPE REF TO cl_abap_tabledescr.
    FIELD-SYMBOLS: <gt_itab> TYPE STANDARD TABLE,
                   <gs_key_comp> TYPE abap_keydescr,
                   <gs_result> TYPE ANY.
    PARAMETERS: pa_table TYPE tabname16 DEFAULT 'SPFLI',
                pa_cond1 TYPE string DEFAULT sy-mandt,
                pa_cond2 TYPE string DEFAULT 'LH',
                pa_cond3 TYPE string DEFAULT '0123'.
    START-OF-SELECTION.
    * Create and populate internal table
      CREATE DATA gt_itab TYPE STANDARD TABLE OF (pa_table).
      ASSIGN gt_itab->* TO <gt_itab>.
      SELECT * FROM (pa_table) INTO TABLE <gt_itab>.
    * Get the key components into the fields ge_key_field1, ...
      go_descr_ref ?= cl_abap_typedescr=>describe_by_data_ref( gt_itab ).
      LOOP AT go_descr_ref->key ASSIGNING <gs_key_comp>.
        CASE sy-tabix.
          WHEN 1.
            ge_key_field1 = <gs_key_comp>-name.
          WHEN 2.
            ge_key_field2 = <gs_key_comp>-name.
          WHEN 3.
            ge_key_field3 = <gs_key_comp>-name.
        ENDCASE.
      ENDLOOP.
    * Finally, perform the search
      READ TABLE <gt_itab> ASSIGNING <gs_result>
              WITH KEY (ge_key_field1) = pa_cond1
                       (ge_key_field2) = pa_cond2
                       (ge_key_field3) = pa_cond3.
      IF sy-subrc = 0.
        WRITE / 'Record found.'.
      ELSE.
        WRITE / 'No record found.'.
      ENDIF.
    One note: When an internal table is created dynamically like in my program above, the table key is not the key defined in the DDIC structure -- instead, the default key for the standard table is used (i.e. all non-numeric fields).
    Hope this helps,
    David

  • Insert statement will not work if select statement has less number of colum

    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
    Either only specify explicit column in TEMP to get data,
    or provide value for "extra" column in TEMP

Maybe you are looking for

  • Issue with PTO (Paid Time Off) quota generation

    Hi All, We have an issue with quota generation of PTO for our employees. The issue goes like this: We have a Paid time off for employees 5weeks( 200 hrs) for employees who have worked less than 5 years. we have  paid time off for employees 6 weeks (

  • Update Manager (Mac) Hangs

    I have an iMac running OS 10.6.8. I had to reinstall my Acrobat 7.0 Pro, and there are several recommended updates. They all seem to download OK, but when installing, the installation bar gets to about 90% and installation hangs. I have run the insta

  • Is it possible to access my lightroom catalog on my iMac from my macbook air ?

    I was just given a yr old macbook air and want to access my lightroom catalog on my I mac ? possible or do I just use the mobile and set up a share folder ? thanks in advance for any info

  • Continual Crashes with CR 11

    I'm experiencing continual crashes with Crystal Reports 11. Seemingly random in nature -- sometimes when I perform a refresh, sometimes when I close out a report, sometimes "just whenever". Environment: Virtualized XP Professional SP3 [VM Workstation

  • Block third party cookies, does not block?? waddup??

    please block anything at all that comes from, cdn.sendori.com, or searchassist.com. have these companies bought off all web browser people, (including Firefox) so they can display ads? their totally annoying disruption of web viewing is not going to