Replacemnt for read table with key binary search

as read table with
READ TABLE gt_INT_CURR_VALUE into gs_int_curr_value
           WITH KEY gs_FS_EINA_KEY  BINARY SEARCH.
the statement read tabel with key is absolute in ecc 6 so how to replace it .

Hi subratt,
internal tables with header lines are obsolete and in oo context (CLASS / METHOD code) forbidden.
OK, you'd better use SORTED TABLE and FIELD-SYMBOLS to gt optimal code::
READ TABLE gt_INT_CURR_VALUE into gs_int_curr_value
WITH KEY gs_FS_EINA_KEY BINARY SEARCH.
may be replaced with
DATA:
  gt_INT_CURR_VALUE_SORTED LIKE SORTED TABLE OF  gs_int_curr_value
    WITH [NON-]UNIQUE KEY <fields of  gs_FS_EINA_KEY>.
FIELD-SYMBOLS:
  <nt_curr_value> LIKE gs_int_curr_value.
gt_INT_CURR_VALUE_SORTED = gt_INT_CURR_VALUE.
  READ TABLE gt_INT_CURR_VALUE_SORTED ASSIGNING <nt_curr_value>
    WITH TABLE KEY <key1> = gs_FS_EINA_KEY-<key1> ..  <keyn> = gs_FS_EINA_KEY-<keyn>.
Regards,
Clemens

Similar Messages

  • Read table with key doubt

    Hi guys!
    Please, what can i do when i use the
    Read table xxxx WITH KEY tab_key = value ASSIGNING <fs>
    statement and there is more than one entry with the specified selection criteria? How can i return the values to an internal table?
    I need to get all the entries and i don't have the full table key.
    thanks!

    Hi Fabio,
    An efficient way to do this is to have your table sorted by a specific key.  Let's say I have a table with the feild material number.
    You can do this:
    data: lv_index like sy-tabix.
    sort itab by material_number.
    ready table itab with key material_number = yournumber
    binary search.
    if sy-subrc eq 0.
      move sy-tabix to lv_index. " this holds the index of your first material record
    now we loop at the table start at that index
      loop at itab index lv_index.
    perform your processing
    if we come accross a different material number - exit the loop.
      if itab-material_number ne yournumber.
        exit.
      endif.
    endloop.
    endif.
    This way you only processes the records you are looking for.
    thanks.
    JB

  • Read Table with key field - question

    Hi,
    Can you use the same key field more than once?
    For example:
      READ TABLE I_TVKWZ INTO I_TVKWZ_2 WITH KEY WERKS = '1004'
                                                                                    Werks = '1002'.
    I get an error when trying this.
    Is there an alternative?
    Thanks,
    John

    Hi John,
    try this:
    DATA: begin of itab occurs 0,
            werks like mseg-werks,
            i     type i,
          end   of itab.
    itab-werks = '1000'. itab-i = itab-i + 1. append itab.
    itab-werks = '1000'. itab-i = itab-i + 1. append itab.
    itab-werks = '2000'. itab-i = itab-i + 1. append itab.
    itab-werks = '3000'. itab-i = itab-i + 1. append itab.
    itab-werks = '5000'. itab-i = itab-i + 1. append itab.
    itab-werks = '5000'. itab-i = itab-i + 1. append itab.
    itab-werks = '7000'. itab-i = itab-i + 1. append itab.
    itab-werks = '7000'. itab-i = itab-i + 1. append itab.
    itab-werks = '9000'. itab-i = itab-i + 1. append itab.
    itab-werks = '9000'. itab-i = itab-i + 1. append itab.
    itab-werks = '9000'. itab-i = itab-i + 1. append itab.
    loop at itab where werks = '1000' or werks = '9000'.
    write: / itab-werks, itab-i.
    endloop.
    Regards, Dieter

  • Read Table with Key in a Deep Structure

    Hello,
    I'd like to read a table while comparing a value in a deep structure.  So in the following code the key ID is a deep structure within cs_purchase_order_message-purchase_order-item-value.
    For some reason code check returns no errors with the following code, but I get a short dump with a syntax error on id-value when I execute the code.
    read table cs_purchase_order_message-purchase_order-item assigning <fs_xml_item> with key id-value = <fs_item>-number_int.
    How do I use "with key" when the value is in a deep structure?
    Thanks,
    Matt

    Refer to example link below:
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/read-deep-structure-736023.
    Regards,
    Venkat.

  • Field symbols and READ TABLE with system code 4

    Hi,
    I have a hashed table and I am using field symbols to point to it to retrieve the field content. I then use it in the READ TABLE statement in the following way:
    Loop at x_data assign <fs>.
    ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c1>.
    ASSIGN COMPONENT 'xxx' OF STRUCTURE <fs> TO <c2>.
    READ TABLE ZZZZ assign <fs> with table key a1 = <c1>
                                               a2 = <c2>.
    If sy-subrc = 0.
    endif.
    I ran the debugger and I keep getting a 4. I am not able to get the value from a1 and a2 to see what it is and why it is causing a 4 sy-subrc. I know the value from the hashed table and the values c1 and c2 are the same, so the sy-subrc should be 0.
    How would I read a hashed table using field symbols? I know that usig a standard table, I have to sort the table on the key fields() before I actually can do the READ TABLE using the binary search.
    Please advise. Thanks
    RT

    Hai Rob
    Go  through the following Code
    Field-Symbols are place holders for existing fields.
    A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.
    Field-Symbols are like Pointers in Programming language ‘ C ‘.
    Syntax check is not effective.
    Syntax :
    Data : v1(4) value ‘abcd’.
    Field-symbols <fs>.
    Assign v1 to <fs>.
    Write:/ <fs>.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
    FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
    DO 4 TIMES.
    LINE-COL1 = SY-INDEX.
    LINE-COL2 = SY-INDEX ** 2.
    APPEND LINE TO ITAB.
    ENDDO.
    READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
    <FS>-COL2 = 100.
    READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
    DELETE ITAB INDEX 3.
    IF <FS> IS ASSIGNED.
    WRITE '<FS> is assigned!'.
    ENDIF.
    LOOP AT ITAB ASSIGNING <FS>.
    WRITE: / <FS>-COL1, <FS>-COL2.
    ENDLOOP.
    The output is:
    1 1
    2 100
    4 16
    Thanks & regards
    Sreenivasulu P

  • Read the internal table with key

    Hi friends,
    decleration of internal table is :
    TYPES : BEGIN OF ty_qmel,
              qmart TYPE qmel-qmart,
              qmnum TYPE qmel-qmnum,
              qmtxt TYPE qmel-qmtxt,
              strmn TYPE qmel-strmn,
              ltrmn TYPE qmel-ltrmn,
              objnr TYPE qmel-objnr,
              qmdat TYPE qmel-qmdat,
            END OF ty_qmel.
    i have written the query as follows .
    SELECT  qmart qmnum qmtxt strmn ltrmn FROM qmel
       INTO CORRESPONDING FIELDS OF TABLE i_qmel
       FOR ALL ENTRIES IN i_qmel
       WHERE qmart EQ i_qmel-qmart.
    I am getting the data into 1_qmel.
    Let me know how to read this table with key...?
    Thanks in advance...

    Hi,
    Refer this code.
    *&      Form  SUB_COLLECT_DATA
          text
    FORM sub_collect_data.
    *--Local variables
      DATA : lv_count(3) TYPE c.
      IF NOT it_fpltc[] IS INITIAL.
        LOOP AT it_fpltc INTO wa_fpltc.
          lv_count = wa_fpltc-fpltr+3(3).
          wa_final-ccnum = wa_fpltc-ccnum.
          wa_final-rfzei = lv_count.
          CLEAR : wa_vbrk.
          READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_final-vbeln = wa_vbrk-vbeln.
            wa_final-bukrs = wa_vbrk-bukrs.
          ENDIF.
          APPEND wa_final TO it_final.
          CLEAR : wa_vbrk,
                  wa_fpltc,
                  lv_count.
        ENDLOOP.
    Regards,
    PRashant

  • Question about reading generic tables with keys

    Hello
    I'm wondering if it's possible to read a generic table with key statement:
    FIELD-SYMBOLS:
        <lv_key>         TYPE zconf_key,
        <lt_data_bi>     TYPE INDEX TABLE,
        <lt_data_ai>     TYPE INDEX TABLE,
        <ls_data_bi>     TYPE any,
        <ls_data_ai>     TYPE any.
    * create data types
      CREATE DATA lt_data_bi TYPE (ls_node-data_table_type).
      ASSIGN lt_data_bi->* TO <lt_data_bi>.
      CREATE DATA lt_data_ai TYPE (ls_node-data_table_type).
      ASSIGN lt_data_ai->* TO <lt_data_ai>.
    * do check
      LOOP AT <lt_data_ai> ASSIGNING <ls_data_ai>.
        ASSIGN COMPONENT 'KEY' OF STRUCTURE <ls_data_ai> TO <lv_key>.
        READ TABLE <lt_data_bi> WITH KEY key = <lv_key>
        ASSIGNING <ls_data_bi> BINARY SEARCH.
    I receive the message: "The specified type has no structure and therefore no component called KEY" in the read statement above.
    Does anyone has an idea what I can do here?
    Regards,
      Mathias

    Mathias Glockner wrote:
    >     READ TABLE <lt_data_bi> WITH KEY key = <lv_key>
    In your structure ls_data_bi there is no field called KEY . please check whether you have field KEY in structure
    a®s

  • Read internal table with key not equal to

    Hi,
    How can I read internal table with key not equal to some other field.
    Basically in read statement we can read only fields equal to others fields.

    Hi,
    Test the following Code you can Use Loop at for this But not Read Table
    DATA: BEGIN OF it_test OCCURS 10,
      f1(4),
      f2 TYPE i,
      f3(2),
      END OF it_test.
    DATA: it_test2 LIKE STANDARD TABLE OF it_test WITH HEADER LINE.
    it_test-f1 = '1000'.
    it_test-f2 = 10.
    it_test-f3 = 'B'.
    APPEND it_test TO it_test.
    it_test-f1 = '2000'.
    it_test-f2 = 10.
    it_test-f3 = 'A'.
    APPEND it_test TO it_test.
    it_test-f1 = '1000'.
    it_test-f2 = 10.
    it_test-f3 = 'B'.
    APPEND it_test TO it_test.
    it_test-f1 = '1000'.
    it_test-f2 = 10.
    it_test-f3 = 'A'.
    APPEND it_test TO it_test.
    it_test-f1 = '1000'.
    it_test-f2 = 40.
    it_test-f3 = 'A'.
    APPEND it_test TO it_test.
    LOOP AT it_test INTO it_test WHERE f3 NE 'A'.
      WRITE: / it_test-f1, it_test-f2, it_test-f3.
    ENDLOOP.
    Kind Regards,
    Faisal

  • What index is suitable for a table with no unique columns and no primary key

    alpha
    beta 
    gamma
    col1
    col2
    col3
    100
    1
    -1
    a
    b
    c
    100
    1
    -2
    d
    e
    f
    101
    1
    -2
    t
    t
    y
    102
    2
    1
    j
    k
    l
    Sample data above  and below is the dataype for each one of them
    alpha datatype- string 
    beta datatype-integer
    gamma datatype-integer
    col1,col2,col3 are all string datatypes. 
    Note:columns are not unique and we would be using alpha,beta,gamma to uniquely identify a record .Now as you see my sample data this is in a table which doesnt have index .I would like to have a index created covering these columns (alpha,beta,gamma) .I
    beleive that creating clustered index having covering columns will be better.
    What would you recommend the index type should be here in this case.Say data volume is 1 milion records and we always use the alpha,beta,gamma columns when we filiter or query records 
    what index is suitable for a table with no unique columns and primary key?
    col1
    col2
    col3
    Mudassar

    Many thanks for your explanation .
    When I tried querying using the below query on my heap table the sql server suggested to create NON CLUSTERED INDEX INCLUDING columns    ,[beta],[gamma] ,[col1] 
     ,[col2]     ,[col3]
    SELECT [alpha]
          ,[beta]
          ,[gamma]
          ,[col1]
          ,[col2]
          ,[col3]
      FROM [TEST].[dbo].[Test]
    where   [alpha]='10100'
    My question is why it didn't suggest Clustered INDEX and chose NON clustered index ?
    Mudassar

  • Counting rows for db tables with 500 million+ entries

    Hi
    SE16 transaction timesout in foreground when showing number of entries for db tables with 500million+ entries. In background this takes too long.
    I am writing a custom report to get number of records of a table and using OPEN CURSOR concept to determine number of records.
    Is there any other efficient way to read number of records from such huge tables.
            OPEN CURSOR l_cursor FOR
            SELECT COUNT(*)
               FROM (u_str_param-p_tabn) WHERE (l_tab_cond).  " u_str_param-p_tabn is the table name in input and l_tab_cond is a
              DO.                                                                              " dynamic where condition
                FETCH NEXT CURSOR l_cursor INTO l_new_count.
               PACKAGE SIZE p_pack.
                IF sy-subrc NE 0.
                  EXIT.
                ELSE.
                  l_tot_cnt = l_tot_cnt + l_new_count. " l_tot_cnt will contain number of records at end of loops
                  CLEAR l_new_count.
                ENDIF.
              ENDDO.
              CLOSE CURSOR l_cursor.

    Hello,
    For sure it is a huge number of entries!!!
    Is any key-fields?
    Use a variable to keep a counter of the key-fields , for example row_table and also a low and high variable .
    Try to use a do-loop and in this loop use:
    do .
    low_row  = row_table.
    low_high = row_table + 200.000.:increse the select every 200.000 entries
    Do  "select statement into table"  based on the key-fields 
    For example : if the key-field is the docnr,
    Do a "select into table itab where docnr >low_row
                                            and docnr < low_high"
    Count the lines of itab and keep them in a variable.
    free the itab.
    enddo
    Good luck.
    Antonis

  • Conflict resolution for a table with LOB column ...

    Hi,
    I was hoping for some guidance or advice on how to handle conflict resolution for a table with a LOB column.
    Basically, I had intended to handle the conflict resolution using the MAXIMUM prebuilt update conflict handler. I also store
    the 'update' transaction time in the same table and was planning to use this as the resolution column to resolve the conflict.
    I see however these prebuilt conflict handlers do not support LOB columns. I assume therefore I need to code a customer handler
    to do this for me. I'm not sure exactly what my custom handler needs to do though! Any guidance or links to similar examples would
    be very much appreciated.

    Hi,
    I have been unable to make any progress on this issue. I have made use of prebuilt update handlers with no problems
    before but I just don't know how to resolve these conflicts for LOB columns using custom handlers. I have some questions
    which I hope make sense and are relevant:
    1.Does an apply process detect update conflicts on LOB columns?
    2.If I need to create a custom update/error handler to resolve this, should I create a prebuilt update handler for non-LOB columns
    in the table and then a separate one for the LOB columns OR is it best just to code a single custom handler for ALL columns?
    3.In my custom handler, I assume I will need to use the resolution column to decide whether or not to resolve the conflict in favour of the LCR
    but how do I compare the new value in the LCR with that in the destination database? I mean how do I access the current value in the destination
    database from the custom handler?
    4.Finally, if I need to resolve in favour of the LCR, do I need to call something specific for LOB related columns compared to non-LOB columns?
    Any help with these would be very much appreciated or even if someone can direct me to documentation or other links that would be good too.
    Thanks again.

  • How to use Read table with out key fields

    Hi Experts,
    I need to retrieve the 2 internal tables data into single table.
    I have 3 common fields between the 2 tables but I don't have the Key fields. Then how to use the read table in this.
    Thanks in Advance.
    Edited by: satish4abap on Mar 10, 2010 9:39 AM

    Hi Satish,
    Key fields are nothing but the common fields with which you can pick the data from the second internal table.
    If you can paste your Internal table fields then we will be able to assit you better.
    However, in genral scenarios you can use it as below :
    In this scenario, we are putting data from 3 internal table to another single internal table.
    LOOP AT T_PRGEN INTO WA_PRGEN.
           WA_FINAL-GUID_PR       = WA_PRGEN-GUID_PR.
           WA_FINAL-ATTR20A       = WA_PRGEN-ATTR20A.
           WA_FINAL-ATTR05A       = WA_PRGEN-ATTR05A.
           WA_FINAL-ATTR05B       = WA_PRGEN-ATTR05B.
           WA_FINAL-ATTR05C       = WA_PRGEN-ATTR05C. " + DG1K902190
           WA_FINAL-ATTR10A       = WA_PRGEN-ATTR10A.
        READ TABLE T_V_TCAV201 INTO WA_V_TCAV201 WITH KEY ATTRV20 = WA_PRGEN-ATTR20A BINARY SEARCH.
        IF SY-SUBRC = 0.
          WA_FINAL-TEXT1   = WA_V_TCAV201-TEXT1.    "SUBID-TEXT1
        ENDIF.
        READ TABLE T_PNTPR INTO WA_PNTPR WITH KEY GUID_PR = WA_PRGEN-GUID_PR BINARY SEARCH.
        IF SY-SUBRC = 0.
           WA_FINAL-PRVSY  = WA_PNTPR-PRVSY.   "PROD NO
           WA_FINAL-GRVSY  = WA_PNTPR-GRVSY.   "LOGICAL SYS GROUP
        ENDIF.
      append wa_final to t_final.
    endloop.

  • Maintenance View for custom table with foreign key relationship

    Hi Folks,
         I have created a custom table with foreign key relationship with other check tables. I want to create a maintenance view / tablemaintenance generator. What all things I need to take care for the foreign keys related fields while creating the maintenance view / tablemaintenance generator.
    Regards,
      santosh

    Hi,
    You do not have to do anything explicitely for the foreign key relationships in the table maintainance generator.
    Create the table maintainance generator via SE11 and it will take care of all teh foreign key checks by itself.
    Regards,
    Ankur Parab

  • 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

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

Maybe you are looking for

  • My complaint and poor customer service from BT

    I am posting a reduced version of the complaint i sent to BT, partly because i would like to know if anyone else has had the same problem and partly in the hope that someone here will see it and be able to help me with the problems i am having. Here

  • I've tried everything someone give me an answer that actually works

    "usb device not recognized try reconnecting the device if windows still does not recognize it replace the device" Ipods are not cheap and i've barely had this thing a few months its the brand new ipod touch gen4 and it worked just a few hours ago i'v

  • Reg : Dynamic Drown list in ALV Report

    Hi Guru's, Please help on showing Dynamic drop down list in ALV Report. My requirement is to show sales partner function in ALV report for each and every line.Every line item may have different partner function. Regards P.Senthil Kumar

  • Displaying Images In Dreamweaver

    when I view an page in either SPLIT or DESIGN view using Dreamweaver 8 it does not display the actual images or embedded video instead it shows the outline of the image as a grey box. I know it can be done but cannot find the option to display. How c

  • PDFmaker in windows

    Hi, I got a new MacBook Pro and installed my copy of Microsoft Word 2004 on it (I'd previously been using this on my intel-based iMac). Now, every time I change a document and then quit out of Word, I get the usual "do you want to save this document"