READ statement with binary search

Hi friends,
I know that while using the READ statement that we have to sort data and use BINARY SEARCH  for faster search.
I have a situation
following are internal table contents
belnr          agent    action
9000001   name1    BRW
9000001   name1    API
when i use READ statement with where condition (  ( belnr - 9000001 ) and  ( action = 'BRW' ) )  with binary search then the SY_SUBRC value is 4.
if i remove the binary search then its giving SY-SUBRC value 0.
Can anybody explain why BINARY SEARCH fails.
Points will be rewarded for correct answers.
Thanks and regards,
Murthy

try this i am not getting sy-subrc 4
TYPES:BEGIN OF TY_ITAB,
BELNR TYPE BELNR,
AGENT(30),
ACTION(5),
END OF TY_ITAB.
DATA:IT_TAB TYPE TABLE OF TY_ITAB,
     WA_TAB TYPE TY_ITAB.
WA_TAB-BELNR = 9000001.
WA_TAB-AGENT = 'name1'.
WA_TAB-ACTION = 'BRW'.
APPEND WA_TAB TO IT_TAB.
CLEAR WA_TAB.
WA_TAB-BELNR = 9000002.
WA_TAB-AGENT = 'name 2'.
WA_TAB-ACTION = 'API'.
APPEND WA_TAB TO IT_TAB.
loop at it_tab into wa_tab.
read table it_tab into wa_tab with key belnr = wa_tab-belnr  binary search .
write: sy-subrc, wa_tab-agent.
endloop.

Similar Messages

  • Reg : Read statement using Binary Search....

    I have an Internal Table as below
    Value           Description
    100               Product
    2008             Production Year
    05                 Production Month
    I am using Read statement with Binary Search for getting Production Month.
    Read table itab with key Description = 'Production Month' binary search.
    I am getting sy-subrc as 4 eventhough data is present in the table for Production Month.
    What may be the problem.

    Hi suganya,
    use
    sort table itab ascending by <production month>.    
    Read table itab with key description = <production month> binary search.
    Remember always, while using binary search always sort the internal table.
    Regards,
    Sakthi.

  • Read table and binary search

    Hi all,
    I have a simple query regarding read int_tab with binary search.
    Why reading  internal table with binary search fails if it is sorted in descending order table must be sorted in ascending order?
    I check fo the algorithm of binary search, it does not talk about sort order. As far as my understanding goes binary search only require sorted table but while reading table in SAP it has to be sorted in ascending order!!

    By default binary search assumes that the sort order is ASCENDING.
    If you sort the list in descending and then try to binary search your quires will fail. Look at an example:
    Let the descending order internal table as:
    Field1      Field2
    Sam        50000
    John       34786
    Boob      54321
    Alice       12345
    When you do binary search with key = 'Sam' then it will directly go to 2nd and 3rd records for comparision. The binary search algorithm compares 'Sam' with 'John' and it concludes that 'Sam' is greater than 'John' and it will continue to look downward into the internal table. And when it reaches the end of the internal table then the value of SY-TABIX = 5 and SY-SUBRC = 8 (Key is greater than the all).
    And if you do binary search with key = 'Alice' then the binary search algorithm compares 'Alice' with 'John' and it concludes that 'Alice' is lower than 'John' and it will continue to look upward into the internal table. And when it reaches above the first record in internal table then the value of SY-TABIX = 1 and SY-SUBRC = 4 (points to the next largest entry).
    The only correct result you will get is when you execute statement with key='John' (In this particular case) . SY-TABIX = 2 and SY-SUBRC = 0. I think you got this binary search algorithm.

  • Problem with Binary search statement

    Hi,
    I have problem with reading the internal with Binary search.
    I have two internal tables BSAS and BSIS. In BSAS I have 1,200,000 line items and BSIS 500,000 line items. I need to delete the line items if BSIS-BELNR NE BSAS-AUGBL.
    I am using the following code :
        LOOP AT gt_bsas .
          READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
                                      belnr = gt_bsas-augbl
                                      gjahr = gt_bsas-gjahr.
          IF sy-subrc NE 0.
            DELETE gt_bsas.
            CLEAR  gt_bsas.
          ELSE.
         endif.
    endloop.
    By this execution of the loop is taking long time. If I use the binary search it is fast but result is not correct.
    Please suggest me, how to resolve this issue.
    Thanks,
    Sri.

    Try this way:
    LOOP AT gt_bsas .
    <b>SORT GT_BSIS BY BUKRS BELNR GJAHR.</b>
    READ TABLE gt_bsis WITH KEY bukrs = gt_bsas-bukrs
    belnr = gt_bsas-augbl
    gjahr = gt_bsas-gjahr
    <b>BINARY SEARCH.</b>
    <b>IF sy-subrc eq 0.</b>
    ****Do Nothing.
    ELSE.
    <b>DELETE gt_bsas sy-tabix.</b>
    CLEAR gt_bsas.
    endif.
    endloop.
    1. Also make sure that the KEY mentioned in READ statement follows the same seqeunce of gt_bsis structure.
    Thanks,
    Santosh
    Message was edited by:
            SKJ

  • Weird situation with BINARY SEARCH in READ statwment??

    Hi Experts,
    I got weird situation with BINARY SEARCH !! bcoz, below is my code,
    data: begin of it_vbap occurs o,
            vbeln like vbap-vbap,
            posnr like vbap-posnr, ( i also tried like, posnr(6) type n)
    end of it_vbap.
    data: counter type i ( i also tried like, counter(6) type n)
    my it_vbap is filled like below,
    vbeln----
    posnr
    12345678-------000001
    12345678-------000002
    12345678-------000003
    12345678-------000004
    12345678-------000005
    12345678-------000006
    sort it_vbap by posnr. (*)
    clear counter
    loop it_vbap.
    counter = counter + 1.
    read table it_vbap with key posnr = counter
    binary search (after commenting the above SORT * marked statement, then,if I delete BINARY SEARCH, then its working!!)
    if sy-subrc = 0.
    here is my logic.
    endif.
    endloop.
    so, now, for
    1st loop the sy-subrc = 0.
    2nd loop the sy-subrc = 0.
    3rdloop the sy-subrc NE  0.
    4th loop the sy-subrc = 0.
    5th loop the sy-subrc NE 0.
    6th loop the sy-subrc NE 0.
    so, why, ebven though there r all entires in it_vbap, why am getting the sy-subrc NE 0??
    Is the reason that, there r less number of entries in it_vbap?? and am using BINARY SEARCH??
    thanq
    Edited by: SAP ABAPer on Dec 4, 2008 8:33 PM
    Edited by: SAP ABAPer on Dec 4, 2008 8:37 PM
    Edited by: SAP ABAPer on Dec 4, 2008 8:37 PM

    Hello
    The following coding works perfect (6x sy-subrc = 0) on ERP 6.0:
    *& Report  ZUS_SDN_ITAB_BINARY_SEARCH
    REPORT  zus_sdn_itab_binary_search.
    TABLES: vbap.
    DATA: BEGIN OF it_vbap OCCURS 0,
    vbeln LIKE vbap-vbeln,
    posnr LIKE vbap-posnr, "( i also tried like, posnr(6) type n)
    END OF it_vbap.
    DATA: counter TYPE posnr.
    START-OF-SELECTION.
      " Fill itab with data:
    *  12345678-------000001
    *  12345678-------000002
    *  12345678-------000003
    *  12345678-------000004
    *  12345678-------000005
    *  12345678-------000006
      REFRESH: it_vbap.
      CLEAR: vbap.
      DO 6 TIMES.
        it_vbap-vbeln = '12345678'.
        it_vbap-posnr = syst-index.
        APPEND it_vbap.
      ENDDO.
      SORT it_vbap[] BY posnr.  " for BINARY SEARCH
      BREAK-POINT.
      clear counter.
      loop at it_vbap.
      counter = counter + 1.
      READ TABLE it_vbap WITH KEY posnr = counter
      BINARY SEARCH.  " (after commenting the above sort * marked statement, then,if i delete binary search, then its working!!)
      IF sy-subrc = 0.
        "here is my logic.
      ENDIF.
    ENDLOOP.
    END-OF-SELECTION.
    By the way, if your requirement is to check whether the first item has POSNR = '000001', the second item has POSNR = '000002' and so on then you can simplify your coding like this:
    counter = 0.
    LOOP AT it_vbap.
      counter = syst-tabix.
      IF ( it_vbap-posnr = counter ).
        " put in here your logic
      ENDIF.
    ENDLOOP.
    Regards
      Uwe

  • Issue with read statement with one more key missing in mapping

    Hi All ,
    I have such data in two internals table :
    IT_bdc
    vbeln            posnr
    90000593     10
    90000576     10
    90000672     10
    90000672     20
    90000672     30
    it_konv
    kbetr          vbeln
    6250          90000576
    12160000          90000593
    500000          90000672
    600000          90000672
    700000          90000672
    My current program statement is :
    LOOP AT it_bdc.
    READ TABLE it_konv WITH KEY
          vbeln = it_bdocs-vbeln.
      currency =   it_konv-waers.
    endloop.
    as you can see the posnr is missing in it_konv how can i modify this read statement so
    that vbeln posnr from it_bdc should get correct kbetr from it_konv.
    Kindly help in this mapping.

    Hi
    sort it_konv by vbeln
    then
    loop at it_bdc.
    read table it_konv with key vbeln = it_bdc-vbeln binary search.
    if sy-subrc = 0.
    perform your logic/task.
    endif.
    endloop.
    also it depends what you want to do after reading it_konv.
    in my logic if there is a vbeln in it_konv which s present in it_bdc then sy-subrc will be 0
    and you can perform your logic.
    and if there will be no matching vbeln in it_konv then sy-subrc will not be 0.
    check the values in debugging.
    Thanks
    Lalit

  • Read Statement with key

    Hi,
    How can I modify this Read statement as Read with same
    keys is not allowed.
    DATA: BEGIN OF itab OCCURS 0,
          matnr LIKE marc-matnr,
          werks LIKE marc-werks,
          steuc LIKE marc-steuc,
           END OF itab.
    wgc_werk = 'BR10',
    wgc_werk1 ='BR20'.
        READ TABLE itab WITH KEY matnr = it_mvke-matnr
                                         werks = wgc_werk
                                         werks = wgc_werks1
                                         BINARY SEARCH.

    Hi,
    You are trying to use read statement inorder to fetch a single record isn't it? if you are trying to search for a record having either
    WERKS = 'BR10' or WERKS = 'BR20' then you need to modify your code.
    i.e. as below
    DATA: BEGIN OF itab OCCURS 0,
    matnr LIKE marc-matnr,
    werks LIKE marc-werks,
    steuc LIKE marc-steuc,
    END OF itab.
    wgc_werk = 'BR10'.
    wgc_werk1 ='BR20'.
    READ TABLE itab WITH KEY matnr = it_mvke-matnr
    werks = wgc_werk.
    if sy-subrc ne 0.
       READ TABLE itab WITH KEY matnr = it_mvke-matnr
                                                   werks = wgc_werk1.
       if sy-subrc eq 0.
          "your post reading process here
       endif.
    endif.
    BINARY SEARCH.
    Reward points if this helps,
    Kiran

  • Problem with binary search tree

    Hi all, just having troubles with a program im writing.
    My program is based on a binary search tree full of items which are passed in via an input file and then saved to an output file.
    I have written a sellItem method which gets passed in the item and quantity that has been sold which then needs to be changed in the binary tree.
    Here if my sell Item method:
        public void sellItem(Item item, int quantity){
            stockItem = item;
            mQuantity = quantity;
            if (tree.includes(stockItem)){
                int tempQuantity = stockItem.getQuantityInStock();
                tempQuantity -= mQuantity;
            else{
                throw new IllegalArgumentException("The Barcode " + mBarCode + " does NOT exist.");
        }and here is where i am calling it in a test class :
    number1.sellItem(item1, 40);Each item is in this format :
    ABCD, PENCIL, 1, 0.35, 200, 100, 200
    where 200 is the quantity.
    Therefore if i pass 40 into the method the binary search tree should then store the quantity as 160.
    below is a copy of my binary tree :
    public class BSTree extends Object {
        private class TreeNode extends Object{
            public Comparable data;
            public TreeNode left;
            public TreeNode right;
            public TreeNode() {
                this(null);
            public TreeNode(Comparable barCode){
                super();
                data = barCode;
                left = null;
                right = null;
        private TreeNode root; 
        private int nodeCount;
        public BSTree(){
            super();
            root = null;
            nodeCount = 0;
        public boolean isEmpty() {
          return root == null;
        public int size() {
          return nodeCount;
        private TreeNode attach(TreeNode newPointer, TreeNode pointer){
            if (pointer == null){
                nodeCount++;
                return newPointer;
            else {
                Comparable obj1 = (Comparable) newPointer.data;
                Comparable obj2 = (Comparable) pointer.data;
            if (obj1.compareTo(obj2) < 0) //Go left
                pointer.left = attach(newPointer, pointer.left);
            else //Go right
                pointer.right = attach(newPointer, pointer.right);
            return pointer;
        public void insert(Comparable item){
            //Create a new node and initialize
            TreeNode newPointer = new TreeNode(item);
            //Attach it to the tree
            root = attach(newPointer, root);
        public Comparable remove(Comparable key) {
            TreeNode pointer;
            TreeNode parent;
            //Find the node to be removed
            parent = null;
            pointer = root;
            while ((pointer != null) && !key.equals(pointer.data)) {
                parent = pointer;
                if (key.compareTo(pointer.data) <0)
                    pointer = pointer.left;
                else
                    pointer = pointer.right;
            if (pointer == null)
                return null;
            //Orphans
            TreeNode leftSubtree = pointer.left;
            TreeNode rightSubtree = pointer.right;
            if (parent == null)
                root = null;
            else if (key.compareTo(parent.data) < 0)
                parent.left = null;
            else
                parent.right = null;
            //Reattaching any orphans in the left subtree
            if (leftSubtree != null) {
                root = attach(leftSubtree, root);
                nodeCount--;
            //Reattaching any orphans in the right subtree
            if (rightSubtree != null) {
                root = attach(rightSubtree, root);
                nodeCount--;
            nodeCount--;
            return pointer.data;
        private TreeNode search(TreeNode pointer, Comparable key) {
            if (pointer == null)
                return null;
            else if (pointer.data.compareTo(key) == 0)
                return pointer;
            else if (key.compareTo(pointer.data) < 0)
                return search(pointer.left, key);
            else
                return search(pointer.right, key);
        public boolean includes(Comparable key) {
            return (search(root, key) != null);
        public Comparable retrieve(Comparable key) {
            TreeNode pointer;
            pointer = search(root, key);
            if (pointer == null)
                return null;
            else
                return pointer.data;
        public Comparable[] getAllInOrder() {
            Comparable[] list = new Comparable[nodeCount];
            inOrderVisit(root,list,0);
            return list;
        private int inOrderVisit(TreeNode pointer, Comparable[] list, int count) {
            if (pointer != null) {
                count = inOrderVisit(pointer.left, list, count);
                list[count++] = pointer.data;
                count = inOrderVisit(pointer.right, list, count);
            return count;
        public String toString() {
            StringBuffer result = new StringBuffer(100);
            inOrderString(root, result);
            return result.toString();
        private void inOrderString(TreeNode pointer, StringBuffer result) {
            if (pointer != null) {
                inOrderString(pointer.left, result);
                result.append(pointer.data.toString() + "\n");
                inOrderString(pointer.right, result);
    }Thanks for everyones help. Keep in mind i'm very new to java.

    Hi all, just having troubles with a program im writing.
    My program is based on a binary search tree full of items which are passed in via an input file and then saved to an output file.
    I have written a sellItem method which gets passed in the item and quantity that has been sold which then needs to be changed in the binary tree.
    Here if my sell Item method:
        public void sellItem(Item item, int quantity){
            stockItem = item;
            mQuantity = quantity;
            if (tree.includes(stockItem)){
                int tempQuantity = stockItem.getQuantityInStock();
                tempQuantity -= mQuantity;
            else{
                throw new IllegalArgumentException("The Barcode " + mBarCode + " does NOT exist.");
        }and here is where i am calling it in a test class :
    number1.sellItem(item1, 40);Each item is in this format :
    ABCD, PENCIL, 1, 0.35, 200, 100, 200
    where 200 is the quantity.
    Therefore if i pass 40 into the method the binary search tree should then store the quantity as 160.
    below is a copy of my binary tree :
    public class BSTree extends Object {
        private class TreeNode extends Object{
            public Comparable data;
            public TreeNode left;
            public TreeNode right;
            public TreeNode() {
                this(null);
            public TreeNode(Comparable barCode){
                super();
                data = barCode;
                left = null;
                right = null;
        private TreeNode root; 
        private int nodeCount;
        public BSTree(){
            super();
            root = null;
            nodeCount = 0;
        public boolean isEmpty() {
          return root == null;
        public int size() {
          return nodeCount;
        private TreeNode attach(TreeNode newPointer, TreeNode pointer){
            if (pointer == null){
                nodeCount++;
                return newPointer;
            else {
                Comparable obj1 = (Comparable) newPointer.data;
                Comparable obj2 = (Comparable) pointer.data;
            if (obj1.compareTo(obj2) < 0) //Go left
                pointer.left = attach(newPointer, pointer.left);
            else //Go right
                pointer.right = attach(newPointer, pointer.right);
            return pointer;
        public void insert(Comparable item){
            //Create a new node and initialize
            TreeNode newPointer = new TreeNode(item);
            //Attach it to the tree
            root = attach(newPointer, root);
        public Comparable remove(Comparable key) {
            TreeNode pointer;
            TreeNode parent;
            //Find the node to be removed
            parent = null;
            pointer = root;
            while ((pointer != null) && !key.equals(pointer.data)) {
                parent = pointer;
                if (key.compareTo(pointer.data) <0)
                    pointer = pointer.left;
                else
                    pointer = pointer.right;
            if (pointer == null)
                return null;
            //Orphans
            TreeNode leftSubtree = pointer.left;
            TreeNode rightSubtree = pointer.right;
            if (parent == null)
                root = null;
            else if (key.compareTo(parent.data) < 0)
                parent.left = null;
            else
                parent.right = null;
            //Reattaching any orphans in the left subtree
            if (leftSubtree != null) {
                root = attach(leftSubtree, root);
                nodeCount--;
            //Reattaching any orphans in the right subtree
            if (rightSubtree != null) {
                root = attach(rightSubtree, root);
                nodeCount--;
            nodeCount--;
            return pointer.data;
        private TreeNode search(TreeNode pointer, Comparable key) {
            if (pointer == null)
                return null;
            else if (pointer.data.compareTo(key) == 0)
                return pointer;
            else if (key.compareTo(pointer.data) < 0)
                return search(pointer.left, key);
            else
                return search(pointer.right, key);
        public boolean includes(Comparable key) {
            return (search(root, key) != null);
        public Comparable retrieve(Comparable key) {
            TreeNode pointer;
            pointer = search(root, key);
            if (pointer == null)
                return null;
            else
                return pointer.data;
        public Comparable[] getAllInOrder() {
            Comparable[] list = new Comparable[nodeCount];
            inOrderVisit(root,list,0);
            return list;
        private int inOrderVisit(TreeNode pointer, Comparable[] list, int count) {
            if (pointer != null) {
                count = inOrderVisit(pointer.left, list, count);
                list[count++] = pointer.data;
                count = inOrderVisit(pointer.right, list, count);
            return count;
        public String toString() {
            StringBuffer result = new StringBuffer(100);
            inOrderString(root, result);
            return result.toString();
        private void inOrderString(TreeNode pointer, StringBuffer result) {
            if (pointer != null) {
                inOrderString(pointer.left, result);
                result.append(pointer.data.toString() + "\n");
                inOrderString(pointer.right, result);
    }Thanks for everyones help. Keep in mind i'm very new to java.

  • Problem with Binary Search.

    Hi Gurus.
    I am using binary search to read data from internal table with approx more than 3lacs records. Also my table is sorted by BUKRS BELNR. But the problem is that i am getting records from lower half of table only and first half of table is ignoring, so i am not able to get all records. If i use nornal search, i am geting 7856 records and if i use binary search, i am geting only 1786 records....Can anyone help me why this is happening????

    Hi PV
    Actually my table contain line items. I am reading header data from bkpf for a single day. and for that document nos i am fetching line items. But if i use join or for all entries, i will get time exceed errror. so i get Period of that single day and taking data for that period from BSIS and then reading BKPF.. and only taking that line items for which document no in BKPF...
    my code is like
    SELECT-OPTIONS: cpudt FOR sy-datum DEFAULT '20030102'.
    SELECT bukrs belnr gjahr monat FROM bkpf
    INTO CORRESPONDING FIELDS OF TABLE ibkpf
    WHERE ( cpudt IN cpudt OR aedat IN cpudt ).
    ibkpf1[] = ibkpf[].
    SORT ibkpf1 BY monat.
    DELETE ADJACENT DUPLICATES FROM ibkpf1 COMPARING monat.
    IF ibkpf1[] IS NOT INITIAL.
      SELECT * FROM bsis INTO TABLE ibsis
          FOR ALL ENTRIES IN ibkpf1 WHERE gjahr = ibkpf1-gjahr
                                     AND monat = ibkpf1-monat.
      SORT ibsis BY bukrs belnr.
      LOOP AT ibsis.
        READ TABLE ibkpf WITH KEY bukrs = ibsis-bukrs
                                  belnr = ibsis-belnr
                                  BINARY SEARCH.
        IF sy-subrc NE 0.
          DELETE ibsis.
        ENDIF.
      ENDLOOP.
    ENDIF.

  • READ...BINARY SEARCH for more than 1 row.

    Hi,
    i have an internal table that contains several same entries. now i want to search the table with READ ... BINARY SEARCH ( or in another efficient way ) and get all those entries and not just one/the first one.
    how could i do that ? thanks in advance!

    hi leider,
    plz c the below sample code.
    loop at i_head into workarea.
    READ TABLE i_zvfx_gts008_itm INTO wa_zvfx_gts008_itm
                                     WITH KEY
                                     bukrs     = wa_zvfx_gts008_head-bukrs
                                  zzinvoice = wa_zvfx_gts008_head-zzinvoice
                                     BINARY SEARCH.
        IF sy-subrc EQ 0.
          LOOP AT i_zvfx_gts008_itm INTO wa_zvfx_gts008_itm FROM sy-tabix.
            IF ( wa_zvfx_gts008_itm-bukrs NE wa_zvfx_gts008_head-bukrs ) OR
          ( wa_zvfx_gts008_itm-zzinvoice NE wa_zvfx_gts008_head-zzinvoice ).
              EXIT.
            ENDIF.
    endloop.
    this is something like avoiding loop at where condition.
    plz reward points if found helpful.

  • Read statement with repeated key field

    Hi Experts ,
    We  are in the process of UCCHECK in an upgrade program and come across an issue with read statement using repeated key fields which is not allowed in a unicode compatable environment.
                READ TABLE it_vbpa WITH KEY
                                          vbeln = l_vbeln
                                          parvw = '0'
                                          parvw = 'ZN'.
    I checked this in 4.6c environment and observed that the Read statement uses the last key value for reading and doesnt consider other values even if the last value is not present in the table  .
    I want to know if I can use only that last value for read statement ? If so, what was the use of the repeated key fields in a read statement?
    Thanks and Regards
    Sanu

    Hi,
    Your main aim in a upgrade would be to successfully replicate the 4.6x functionalities in the ECC 6 version with the unicode checks. So it would be a safe option to only consider the last key condition. I dont have access to a 4.6C environment. May be it was a mistake corrected by SAP in the new version.
    Vikranth

  • Read statement with key syntax

    Hi all,
    In read statement, is there a possibility to use 'contains string (CS)' instead of '=' in with key?
    I have a requirement to fetch from an internal table, the record whose field1 value contains a particular string.
    Thanks,
    David.

    HI
    it won't accept CS in read table clause. syntax error will be displayed.
    for more clarity just execute the falloing code.
    DATA: BEGIN OF ITAB OCCURS 0,
            MATNR LIKE MARA-MATNR,
            ERSDA LIKE MARA-ERSDA,
            ERNAM LIKE MARA-ERNAM,
          END OF ITAB.
       SELECT MATNR
              ERSDA
              ERNAM
              FROM MARA
              INTO TABLE ITAB
              WHERE ERNAM = 'BOHNSTEDT'.
       IF SY-SUBRC EQ 0.
         SORT ITAB BY MATNR ASCENDING.
         READ TABLE ITAB WITH KEY MATNR CS '3'.
         IF SY-SUBRC EQ 0.
          WRITE: ITAB.
         ENDIF.
       ENDIF.

  • Read Statement with Single key with multiple values

    Dear Friends,
    In ECC 4.6c, I wrote statement like this.
    Read table message with key type = 'E' or 'S'.
    if sy-subrc = 0.
    Populated the message log to output internal table.
    endif.
    But when i transported to QA which is ECC 6.0, it is giving error.
    Can any one help me in modifying this qurey.
    Plse read my question thoroughly and reply me back.
    Regards,
    Santosh Kumar M

    Hi,
    You can't use OR condition with READ table. it is always AND condition.
    Here 2 ways for ur problem.
    If u want to have just one message in the log then use multiple reads.
    READ TABLE message WITH KEY type = 'E'.
    If sy-subrc IS INITIAL.
    populate log.
    ELSE.
    READ TABLE message WITH KEY type = 'S'.
    If sy-subrc IS INITIAL.
    populate log.
    ENDIF.
    ENDIF.
    If u want all messages then u have to loop through and populate the log as sugested by Vijay but
    Without exit in loop.(Since u need all the messages)
    LOOP AT message into wa WHERE type = 'E' or type = 'S'.
    populate log.
    ENDLOOP.
    Thanks,
    Vinod.

  • READ statement with dynamic key

    Can i READ a dynamic table with a dynamic key combination?
    READ TABLE <dyn_sel_table>
      INTO       <dyn_sel_wa>
      WITH KEY   ? .

    yes i guess u can do it
    READ TABLE <dyn_sel_table>
    <b>ASSIGNING</b> <dyn_sel_wa>
    WITH KEY <field1> eq ...

  • Read statement with duplicate key fields

    Hello,
    I have an internal table(EKBE) with 8 fields
    ebeln ebelp vgabe gjahr belnr budat wrbtr refkey
    populating the first 7 fields from EKBE table with VGABE = 2 and PO#, concatenating the WRBTR and GJAHR to get the Refkey and passing this to the 8th field.
    Using this refkey, getting the document numbers from BKPF.
    I am looping another internal table into a work area and reading the above internal table by passing the ebeln field and I am doing some calculations ,etc.
    A custom table is getting updated from the above work area.
    The issue is-
    The internal table EKBE can have the same PO numbers with the same line item numbers but with different ref key's.
    So, when I am reading the int. tab, it is reading only one record, since I have no other key's to read except EBELN. So for one PO# it is reading only 1 ref key, I cannot use the line item# as a key, as the line item#'s never match, even if they match they could be same PO# with same line item# and different ref key.
    Any inputs highly appreciated.
    Regards,
    Kiran

    Loop on EKBE Internal table as well to fetch all entries of PO. Use Parallel cursor to optmize performance.
    http://wiki.sdn.sap.com/wiki/display/Snippets/ABAPCodeforParallelCursor-Loop+Processing

Maybe you are looking for

  • Error while configuring report server

    Hi, I configuring a 10gr1 report server ( midtier). In the configuration file , when I give the repository username and password.. <!--jobStatusRepository class="oracle.reports.server.JobRepositoryDB"> <property name="repositoryConn" value="repo_db_u

  • How do you get a rescue email without knowing your security questions

    Hey, So I know this sounds pretty stupid at first, but let me explain a bit; I made my apple Id on my I Pod Touch, and it asked me to make security questions (in which I made two, this is where the "fun" begins), however it didn't ask me to make a re

  • Best bitrate video and sound 320x? N78 h.264

    Hi there, I was searching for posts about the most efficient bitrate for videos encoded for the N-series, with a 320x240 screen. I found a few, but thought I could write one my self. I am a mac user since way back and a SE user until today. I now hav

  • Incorporating a Captivate movie

    How do I put a captivate movie into the help files? thanks

  • Log and Transfer Causes FCP to Freeze!

    Quite an annoying problem. Running FCP 6.0.6 I go to log & transfer new footage. I can select a folder. I can even see the footage and play it back in the preview window, but when I press "Add Selection to Queue" or "Add Clip to Queue" (both do this)