Can't we use Binary SEARCH  for TYPE SORTED TABLE?(Performance Improvement)

Hi Expert!
                   I have declare a sorted type table with NON -UNIQUE, and want to use Binary search in read statement. But while  using bunary search in read statement I'm facing an error. The ERROR is
"Table LI_MARC is a SORTED TABLE or INDEX TABLE. The BINARY SEARCH
addition is only allowed for these tables if the key specified is an
initial part of the table key."
Please find detail
TYES: tt_marc  TYPE SORTED TABLE OF marc   WITH NON-UNIQUE KEY matnr,werks.
DATA: li_marc type tt_marc.
READ TABLE li_marc INTO marc WITH KEY matnr = i_mbew-matnr     
                                                                      werks = i_mbew-bwkey BINARY SEARCH . 
To my understanding , there is no need to mention Bianry Search  for sorted table TYPE. Please  let me know can  i use ?

Hello,
there is no need to mention Bianry Search for sorted table TYPE.
Yes, this is because for SORTED TABLEs binary search algorithm is used by default for READ TABLE. Although you can use BINARY SEARCH addition but it's use is redundant.
As for your case you've defined the KEY fields incorrectly There shouldn't be any "comma(s)" between the fields.
TYPES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr werks.
When you define it with commas
TYPES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr, werks.
the result is something like this:
TYPES: tt_marc TYPE SORTED TABLE OF marc WITH NON-UNIQUE KEY matnr.
TYPES: werks.
Hence you were getting the syntax error!
BR,
Suhas
PS: As for MARC you can use UNIQUE KEY addition because MATNR & WERKS are the key fields in the table.

Similar Messages

  • A little urgent when to use binary search.

    Hi evryone,
    Plz let me know under what kind of conditions can we use binary search addition cause if I use it for every read statement the database acees in se30 goes higher than normal.
    If i randomly select only a few big read table statements the database acees in se30 goes is slightly lesser.
    But I some how dont know where to use binary search and where not to with read statements.
    Expecting an early reply.
    Rgds,
    Anu

    hi,
    If you read entries from standard tables using a key other than the default key, you can use a binary search instead of the normal linear search. To do this, include the addition BINARY SEARCH in the corresponding READ statements.
    READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> = <fn> <result>
                                                           BINARY SEARCH.
    The standard table must be sorted in ascending order by the specified search key. The BINARY SEARCH addition means that you can access an entry in a standard table by its key as quickly as you would be able to in a sorted table.
    REPORT demo_int_tables_read_index_bin.
    DATA: BEGIN OF line,
            col1 TYPE i,
            col2 TYPE i,
          END OF line.
    DATA itab LIKE STANDARD TABLE OF line.
    DO 4 TIMES.
      line-col1 = sy-index.
      line-col2 = sy-index ** 2.
      APPEND line TO itab.
    ENDDO.
    SORT itab BY col2.
    READ TABLE itab WITH KEY col2 = 16 INTO line BINARY SEARCH.
    WRITE: 'SY-SUBRC =', sy-subrc.
    The output is:
    SY-SUBRC =    0
    The program fills a standard table with a list of square numbers and sorts them into ascending order by field COL2. The READ statement uses a binary search to look for and find the line in the table where COL2 has the
    reward if useful.
    Thanks,
    Madhukar

  • When to use binary search ... little urgent.

    Hi evryone,
    Plz let me know under what kind of conditions can we use binary search addition cause if I use it for every read statement the database acees in se30 goes higher than normal.
    If i randomly select only a few big read table statements the database acees in se30 goes is slightly lesser.
    But I some how dont know where to use binary search and where not to with read statements.
    Expecting an early reply.
    Rgds,
    Anu

    Hi,
    If  you read entries from standard tables using a key other than the default key, you can use a binary search instead of the normal linear search. To do this, include the addition BINARY SEARCH in the corresponding READ statements.
    READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> = <fn> BINARY SEARCH.
    The standard table must be sorted in ascending order by the specified search key. The BINARY SEARCH addition means that you can access an entry in a standard table by its key as quickly as you would be able to in a sorted table.
    BINARY SEARCH approaches the middle entry in the table, decides if it matches, or lexically greater than or equal to the key being searched. It accordingly skips either the top or bottom part of the internal table and searches the other half. It repeats this process till it finds the row.
    Using BINARY SEARCH with READ is the most efficient way to read standard internal tables which are sorted by the key used to search them
    BINARY SEARCH addition when reading a sorted table is not required, as it happens by default. It makes a good difference in performance if you are reading a large standard internal table without sorting and reading by BINARY SEARCH.
    Regards,
    Padmam.

  • How can I define a new Search Node type?

    Hi experts!
    I'm trying to modify PPOME transaction, but I can't create a new Search Node type. Can anybody give me the necessary steps I have to do? Other question, Is it possible to create a new Search Node for a Organizational unit? Or this only could be possible for new objects types?
    Thanks a lot,
    Regards,
    Rebeca

    Hi Rebeca,
    You need to create a Search node only if you create a new object type (e.g. ZP).
    For org unit, you don't need to create one (unless you wanna change search details)
    Otherwise, you can use existing search nodes for standard object types.
    What you can do is, you can add a search node to an existing scenario in order to make it visible in the object manager part (left-hand side of the screen).
    To create a new search node :
    Goto SPRO Personnel management - Organizational Management - Hierarchy Framework - Object manager - define your own search node -
    > Define search node : Add new entries here.
    To add a search node to a scenario (e.g. to make a new search node visible on the left-hand side of PPOME)
    Goto SPRO Personnel management - Organizational Management - Hierarchy Framework - Object manager - define your own search node -
    > Scenario Definition (Object manager) : Select the scenario (for PPOME it is OME000), double click the "Search nodes" and create new entries to add the search node here. Then double click the "Search tool", copy the lines of a similar search node and change search node field to the new one.
    Best regards,
    Dilek

  • Spotlight cannot search for type & creator codes?

    I want to find some old ClarisWorks documents that I know are on my computer somewhere. Simple, I thought: Just search for documents dated before 2000 with creator code BOBO. But looking through the list of search parameters in Spotlight, I don't find either type or creator code. I know Mac OS X no longer uses these metadata, but they can still be useful, as in cases like this. Am I missing something? Is there a way for Spotlight to search on type & creator codes?

    Thanks for the response. I solved my problem by just looking through folders of old files and checking dates of those with AppleWorks icons. Very 21st century. I knew there must be some reason I thought I could do such a search, so I fired up my old 'Pismo' PowerBook and indeed, the Finder search utility in 10.3.9 allows searching for Type and Creator codes. It also will search only on those codes, or on a date or other parameter; while with Spotlight I could find no way to search for, say, all files dated before 1/1/1999 -- it requires something entered in the top field, i.e. a word to search for either in the file's contents or its name. So I put in "the" and got a lot of results, but of course minus any file that doesn't contain "the". Not so smart.
    I've never much liked Spotlight, which is way overkill for 95+% of the searching I do; I almost never used it in 10.4 (used Easy Find); in 10.5 at least it's fast enough to not be a major annoyance, though the fact that I can't make "File Name" the default requires me to keep a Spotlight window open in the Finder all the time (or have to manually click on "File Name" every time I want to do a search). Sure it's nice to be able to search the contents of files -- when I need to, but that's almost never. Meanwhile, Spotlight remains far inferior in simple, day-to-day usability to 10.3's Find utility.
    So how do you find out how to do such a "Raw Query" search? "kMDItemKind" is not an immediately intuitive term, at least for ordinary mortals such as myself.

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

  • Why does Maverick mail no longer search properly? I used to search for a name and it would find it in All mailboxes. Now it sometimes works, but mostly not. Any solutions?

    Why does Maverick mail no longer search properly?
    I used to search for a name and it would find it in One or All mailboxes. Now it sometimes works, but mostly not. Any solutions?

    I would like to add that Comcast is my internet provider. Perhaps that is part of the issue although the Connection Doctor confirms the mail box is connecting to the internet. No other function processes when Connection Doctor program is used to find the source of the issue. I have read forum posts but am unable to find a way to get my Apple mail to be delivered to my computer. It worked fine up until I chose to transfer mail to the Cloud. My mail account is a .mac account.
    Still hoping someone out there can help me.
    thanks,
    anne

  • READ using Binary Search

    Hi,
    Is it necessary to use all the sorted keys in READ using BINARY SEARCH .
    For EX: Sort it_tab BY key1 key2
    While Reading i will use only key1 with BINARY SEARCH,Please tell me whether READ statement works?
    Thanks,
    Rathish

    Hello Ratish,
    There isnt any hard and fast rule that you will have to use all the fields on which you sort. The key fields which you may want to use in the READ statement depends on the logic with which you are reading the internal table. As Rob pointed out its better to use all the fields which could make a record unique in the READ statement else it would keep reading only the first occurence of the record.
    Vikranth

  • I can create material using inbound Idoc of type MATMAS01, but not MATMAS05

    I can create material using inbound Idoc of type MATMAS01 in WE19, but MATMAS05 failed. In fact I used same data ( different material number), and same inbound function, but got different result.
    What is different between MATMAS01 and MATMAS05? Is there some configuation need for MATMAS05?
    My system is ECC5.0. Thanks.

    Hi, nagaraj
    this is inbound IDoc, not outbound IDoc, so we can't assign Basic type in WE20, only can assign Message type.
    In WE82, there are 5 records about Messagetype MATMAS:
         Message type   Basic type     Release
          MATMAS         MATMAS01        30A
          MATMAS         MATMAS02        30D
          MATMAS         MATMAS03        40A
          MATMAS         MATMAS04        46C
          MATMAS         MATMAS05        470
       I think it should be ok.
    In WE57, there 2 records are exist:
       FM_name                 BasicType       MessageType
      IDOC_INPUT_MATMAS01       MATMAS01         MATMAS
      IDOC_INPUT_MATMAS01       MATMAS05         MATMAS
    so I think all configurations should be ok.
    Message was edited by:
            liu bin

  • HT204053 How do you change apple id for icloud if phone is already set up. Need to give each phone in my account their own apple id for icloud so that we dont receive each others messages but can still all use same id for purchases.

    How do you change apple id for icloud if phone is already set up. Need to give each phone in my account their own apple id for icloud so that we dont receive each others messages but can still all use same id for purchases.

    Settings-icloud-scroll to the bottom, select delete, if you want to keep the content select keep, otherwise it'll remove it. Then once it is done add the account information for the account you want on that phone.  Your apple ID in settings-store will remain the same and each device can still purchase/use content from that account.

  • My BB9810 refuse to load OS7.1 software on my phone after the download has completed. My phone has freezed/stucked since morning. Pls urgent help/assistant needed as I can not access/use my phone for over 24hrs now.

    My BB9810 refuse to load OS7.1 software on my phone after the download has completed. My phone has freezed/stucked since morning. Pls  urgent help/assistant needed as I can not access/use my phone for over 24hrs now.

    Hi there,
    Use the method described in the link below to get back up and running:
    http://supportforums.blackberry.com/t5/Device-software-for-BlackBerry/How-To-Reload-Your-Operating-S...
    I hope this info helps!
    If you want to thank someone for their comment, do so by clicking the Thumbs Up icon.
    If your issue is resolved, don't forget to click the Solution button on the resolution!

  • Why can't I use the search tool on a server

    Why can't I use the search tool on a server

    Thanks.  That seems unfortunate.
    Bruce Burton
    Kiku Obata & Company
    6161 Delmar Blvd., Suite 200, St. Louis, MO 63112
    Direct 314.505.8427  Fax 314.361.4716
    www.kikuobata.com

  • How can i activate use cellular data for facebook

    how can i activate use cellular data for facebook

    pepaycustodio wrote:
    how can i activate use cellular data for facebook
    Settings > Cellular > Cellular Data: ON

  • Using iOS 8.1, can I still use pop account for email instead of imap

    UUsing iOS 8.1 on iPhone 4. Can I still use pop account for my email instead of IMAP. Don't like all my email on mail server

    MMy biggest problem is both iPhone and iPad when I set up email account uses IMAP automatically. So I really have no choice. Since IMAP doesnot allow downloading email to device, I have to leave all restates on mail server. This really concerns me.

  • HT204053 Why can't I use my number for my iMessage?

    Why can't I use my number for iMessage?

    Welcome to the Apple Community.
    You should be able to, what exactly is the problem.

Maybe you are looking for

  • Payment history

    Dear expert, I have a requirement to add more field which is payment for reporting. Based on ME2N, is it possible to add field payment status? So, when po is paid, the new field should display payment document number and display also status "paid"? P

  • List View does not retain date formats from Excel

    i am using List View control to isplay data. When i scroll the horizontal bar inlist view, the date format changes to numbers. is there were to stop this happening. regards Chandra

  • Rebates in SAP Retail

    Hi, One of my clients wants to implement Rebates. Can you ket me know what are the various kinds of rebates that are supported by sap is retail. Some business processess / best process documents will be helpful Thanks Barry

  • Installing new flash player?

    Please can someone help me? I've been trying to install the new flash player 11.7 for days and it refuses to install. I have internet explorer 9 64-bit, windows 7. I've tried everything that everyone has said. I've turned off my firewall, enabled scr

  • Unlock Printing System Pref?

    How do I unlock the print and fax system pref so that non-admin users can add printers? I don't want to unlock them all - just the print/fax. We have a number of users with laptops who print in the office, but then need to print offsite as well. We c