READ TABLE pointer ...

Hi there. How can I assign an itab to pointer to have possibility to make operations on pointer (not itab)?
[ I ]
DATA: itab LIKE dbtab OCCURS 0 .
field-symbols: <ritab> type any table .
field-symbols: <rline> type any .
ASSIGN itab TO <ritab> .
it's ok but now ... when I want to ...
READ TABLE <ritab> INTO <rline> INDEX G_arow .
... I receive You cannot use explicit or implicit index operations on tables with
types "HASHED TABLE" or "ANY TABLE". "<RITAB>" has the type "ANY TABLE".
[ II ]
DATA: itab LIKE dbtab OCCURS 0 .
field-symbols: <pointer> type standard table .
field-symbols: <rline> type any .
ASSIGN (itab) TO <pointer> .
the ASSIGN statement returns sy-subrc = 4

Hi,
change your declaration of
field-symbols: <pointer> type any table .
to
field-symbols: <pointer> type standard table .
Darren

Similar Messages

  • 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

  • Reading Tables in MS WORD using LabView & ActiveX

    I would like to be able to read tables contained in an MS WORD document using LabView and ActiveX. (I've been successful in doing this with Excel files.  ( I am not using the report generation toolkit.)  After searching numerous posts with similar questions about LV & ActiveX  I've not found any solution to my specific app.  In LabView I'm successful doing an "Automation Open", followed by a Property Node, to an Invoke Node ("Documents" Open) and then a Property Node with "TABLES" selected. That's where I get stuck. Now that I have a reference (?) to "Tables" I can't seem to figure out what I need to connect and follow that with in order to now read the Tables in my document.  I guess that's due to my lack of understanding as to what exactly this "Table" property node output actually is.  Can someone tell me what this reference output is referring to and how I can get to the Tables within the document from it?  I've tried connecting both a property node and invoke node to no avail.  Can someone point me in the right direction?
    Thanks. Ed

    Dear Ed,
    Figuring out "what I need to connect and follow that with" relates to the organization of the MS Word Object Model.  Please refer to the Word Object Model Reference MSDN >> MSDN Library >> Office Development >> 2007 Microsoft Office System >> Word 2007 >> Word 2007 Developer Reference >> Word Object Model Reference.  You can think of the Object Model as a software hierarchy.  You must start at the top of the hierarchy and work your way down to the item of interest.  You must descend the hierarchy one level at a time; you cannot skip levels.
    At each level of the hierarchy, you have access to the methods and properties of that "level".
    Click on the Tables Collection link from the Word Object Model Reference page.  Notice how Tables is at the top of the hierarchy.  When you have a LabVIEW reference to a Tables object (technically speaking a collection), you then have access to the methods and properties supported by this "level".  Click on the Tables Object Members link.  Here you will see that the Tables collection supports two methods, Add and Item, and also supports five properties, Application, Count, Creator, NestingLevel, and Parent.
    Notice how Mike gets the Count property of the Tables object.  He then uses the Item method to return a reference to an individual table.  The key thing to take away from this is how Mike uses the Item output node to gain access to the methods and properties of the Table object (not the Tables collection).  Mike has descended the hierarchy from Tables to Table.  He descends the hierarchy again with the Cell method and Range property of the Table and Cell object respectively.  Lastly, the Text property of the Range object, "Returns or sets the text in the specified range or selection."
    Effective LabVIEW programming with this type of ActiveX control requires a fair understanding of how Microsoft organized its software libraries.  The Object Model Reference is a good place to start visualizing how these libraries are organized.  Thank you for using the forums Ed, and thanks for your post, Mike.

  • How to change "read table ......" sentense to OO method ?

    READ TABLE lt_origin_table  into lt_target_table
                 WITH KEY user_id= lt_target_table-user_id.
    This sentense is allowed in function module but can not be written in an OO method , so what can i do ?
    Now I use 2 loops ,
    Loop at lt_origin_table ....
       loop at lt_target_table
       endloop.
    endloop.
    The result is OK , but the performance is not good enough , can any one help me ?
    Regards .

    <b>Example  :</b>   Selection of a particular line in the internal table sflight_tab and assigning it to a field symbol <sflight>. After the line has been successfully assigned, the content of a component of the line is changed in the internal table.
    PARAMETERS: p_carrid TYPE sflight-carrid,
                p_connid TYPE sflight-connid,
                p_fldate TYPE sflight-fldate.
    DATA sflight_tab TYPE SORTED TABLE OF sflight
                     WITH UNIQUE KEY carrid connid fldate.
    FIELD-SYMBOLS <sflight> TYPE sflight.
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab
           WHERE carrid = p_carrid AND
                 connid = p_connid.
    IF sy-subrc = 0.
      READ TABLE sflight_tab
           WITH TABLE KEY carrid = p_carrid
                          connid = p_connid
                          fldate = p_fldate
           ASSIGNING <sflight>.
      IF sy-subrc = 0 AND
         <sflight> IS ASSIGNED.
         <sflight>-price = <sflight>-price * '0.9'.
      ENDIF.
    ENDIF.
    reward  points if it is usefull ....
    Girish

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

  • How to read table fields form a table  having length of 7 characters

    HI all,
    could you please tell me how to read table fields from a table having length 7 characters, i have requirement that in my ztable i have 30 fields out of which 20 fields are location fields, i want to select 20 fields which have 7 characters length.
    please could any body suggest me on this issue.
    thanks,
    sre.

    hi,
    try like this
    create a data variable of type i as
    data: len type i.
    create internal table for 20 fields as
    data:begin of itab,
               fld 1 type .......
            end of itab.
    data:itab type itab1 occurs 0 with header line.
    loop at itab2. // original internal table which all fields.
    read table itab2 with index sy-tabix.
    len = strlen (itab2-fld).
    if len eq 7.
          move itab2 itab1.
          append itab1.
    endif.
    endloop.
    if helpful reward some points.
    with regards,
    Suresh.A

  • Read Table ITAB with key Dynamic Value = Value

    Here is sample Intenral table
    Columnname-C01 / C02 / C03
    Value-123 / 456 /789
    I would like to search value of the internal table according to dynamic value given by the code.
    i.e.
    read table ITAB with key <Dynamic Value> index 1.

    Hi Rupesh,
    Just try the following piece of code:
    TYPES: BEGIN OF str,
            A TYPE C,
            B TYPE I,
            C(2) TYPE C,
           END OF STR.
    DATA itab TYPE TABLE OF str WITH HEADER LINE.
    itab-A = 'X'.
    itab-B = '100'.
    itab-C = 'YZ'.
    APPEND itab.
    PERFORM c_itab_read USING 'A' 'X'.
    PERFORM c_itab_read USING 'B' '100'.
    PERFORM c_itab_read USING 'C' 'YZ'.
    FORM c_itab_read USING key TYPE ANY val TYPE ANY.
      READ TABLE itab WITH KEY (KEY) = val.
      IF SY-SUBRC IS INITIAL.
        WRITE: 'Hurray!'.
      ENDIF.
    ENDFORM.
    Hope this helps.
    Reqard points if query answered.
    Cheers,
    ~i1

  • Read table error

    .<b>
    Hello every body ,
    In my report ,Before populating the fieldcatalog i am first fetching the details of g/l account into my internal table .There are two line items with same posting date .Now wen i use read table to populate my final table looping through the internal table i am getting only one LIne item record .But wen i give my specific line item number in the sel-screen i am getting all the details.if i don't give it tat is to fetch all the data ,then i am able to get only one line item details that is coming first in the order but the second one is not getting displayed.</b>
    Wat could be the reason .
    is it bcoz of only using the read statement?

    My  friend  :
    before  looping   for read table   concept  
    you have to  sort the both tables  and the internal table  fields  should  in the same  order what ever fields are common in the bot internal table ,.
    then  the  line  item table should be the   loop and the header table should be the read table .
    " example .
    sort  bseg by burks belnr  .
    sort  bkpf by  burks belnr   .
    loop at bseg .
    read table bkpf with key  bukrs = bseg-bukrs   belnr  =  bseg-belnr .
    you  query   for modify /inserting into  new internal table  .....etc
    endloop .
    but what you are doing is   BKPF is   looped and BSEG is  used in the read concept    so  it will take  only one line item  ..and the remainining line item will be  skiped .
    and remember to  sort also ..
    reward  points if it is usefulll.....
    Girish

  • About Read table

    Can any body explain about Read table and when it can use.

    Hi,
    When u want to read a record based on some condition then u can use READ.
    LOOP AT itab.
    READ TABLE itab WITH KEY matnr = itab-matnr.
    IF sy-subrc = 0.
    ENDIF.
    ENDLOOP.
    U can read only a single record.
    U can also use
    READ TABLE itab INDEX 1.
    Reward points if this is helpful.

  • Hii guyzz i want to know about read table

    guyzz,
               i have to delete a value from the table eg: despatch date but after i delete the the date i want the date in the remaining field (the fields i doesnt delete the date ) to add into hte space in deleted(now it contins 00000) and it all should be done in read table area
    i wont need the program only logic will do guyzz
    thanks in advance... and points will given to those who help me with this...

    Apple - Apple Watch

  • Sy-tabix in relation to LOOP AT and READ TABLE

    Hi All,
    As per SAP documentation,
    1) While looping through an internal table (LOOP AT), sy-tabix contains the index number of current row(for standard and sorted tables)
    2)When successfully reading from an internal table(READ TABLE), sy-tabix is set to the index of the result row.
    But what happens when READ TABLE is used while looping through another internal table?
    i.e. Loop at TAB1...
    write sy-tabix.
    READ TABLE TAB2...
    write sy-tabix.
    endloop.
    If we are looping through 1st row of TAB1 and the result of read statement is found in 3rd row of TAB2, I expected that sy-tabix before READ would be 1 and after the READ be 3.
    But, I found that sy-tabix remains unchanged at 1. Can someone expalin why?
    Thanks,
    Jagan

    Hi
    If after reading the table TAB2 the system variable SY-TABIX has still the previous value, that menas the READ TABLE fails or it was read the first record of TAB2.
    After READ TABLE TAB2 try to check the SY-SUBRC:
    LOOP AT TAB1.
       WRITE: / 'TAB1 index:', SY-TABIX.
       READ TABLE TAB2 .........
       IF SY-SUBRC = 0.
         WRITE: 'TAB2 index:', SY-TABIX.
    Try this:
    DATA: BEGIN OF ITAB OCCURS 0,
            FIELD1,
          END   OF ITAB.
    DATA: BEGIN OF ITAB2 OCCURS 0,
            FIELD1,
          END   OF ITAB2.
    DATA: INDEX TYPE I.
    DO 10 TIMES.
      APPEND ITAB.
    ENDDO.
    DO 10 TIMES.
      APPEND ITAB2.
    ENDDO.
    LOOP AT ITAB.
      WRITE: / 'ITAB:', SY-TABIX.
      INDEX = SY-TABIX + 2.
      READ TABLE ITAB2 INDEX INDEX.
      IF SY-SUBRC = 0.
        WRITE:  'ITAB2:', SY-TABIX.
      ENDIF.
    ENDLOOP.
    Max

  • Conflict: READ TABLE itab2 INDEX 1 vs  Modify itab1 from index sy-tabix

    The below simple code is for each itab1 line, create a new itab2 by using select statement, and then grab the max value of field f in itab2 and fill it into a corresponding field in itab1.
    However the statement:
    READ TABLE itab2 into gs_itab1 INDEX 1.
    causes the conflict with our another statement in the end of itab1 loop:
    Modify itab1 from gs_itab1 index sy-tabix.
    that the below Modify statement always modify itab1 at 1st row and also causes an unlimited loop that the program is hung up. Our code looks as the following:
    Loop AT itab1 into gs_itab1.
             use Select statement to fill in itab2...
             SORT itab2 BY f DESCENDING. "f is a field of itab2
             READ TABLE itab2 into gs_itab1 INDEX 1.
             Modify itab1 from gs_itab1 index sy-tabix.
    EndLoop.
    However the last two lines of statements in the itab1 loop causes the program hang!
    Any solution?
    Thanks in advance!

    Hi,
    I got confused while going thru the code...
    according to code
    first u loop itab1 and get tht in gs_itab1 and then a select query to get data from some table and store in itab2.
    Here are u using any where condition, if yes u may probably check aganst gs_itab1 rite? if yes
    first suggestion...why cant u put the select statement above the loop and get all the values to an internal table and then read the internal table in the loop stmt. Yes i can see u r sorting it based on some 'f'..just a suggestion
    Now here can u follow this code...
    Loop AT itab1 ASSIGNING <fs_itab1>,
             use Select statement to fill in itab2...
             SORT itab2 BY f DESCENDING. "f is a field of itab2
             READ TABLE itab2 into <fs_itab1> index 1.
    EndLoop.
    Please let me know if its not ok
    <REMOVED BY MODERATOR>
    Regards,
    ABAPer007
    Edited by: Alvaro Tejada Galindo on Apr 11, 2008 12:26 PM

  • 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

  • Read Table Vs Loop at

    Dear All,
    Please let me know which one of the two should I use to improve the performance, for tables containing a lot of data ?
    Regards,
    Thanks in anticipation.
    Alok.

    Hi,
        Follow below steps.
        In se30 transaction you can look for
        Tip&TRicks button on application toolbar
        apart from below conventions
       Follow below steps
    1) Remove corresponding from select satement
    2) Remove * from select
    3) Select field in sequence as defined in database
    4) Avoid unnecessary selects
    i.e check for internal table not initial
    5) Use all entries and sort table by key fields
    6) Remove selects ferom loop and use binary search
    7) Try to use secondary index when you don't have
    full key.
    8) Modify internal table use transporting option
    9) Avoid nested loop . Use read table and loop at itab
    from sy-tabix statement.
    10) free intrenal table memory wnen table is not
    required for further processing.
    11)
    Follow below logic.
    FORM SUB_SELECTION_AUFKTAB.
    if not it_plant[] is initial.
    it_plant1[] = it_plant[].
    sort it_plant1 by werks.
    delete adjacent duplicates from it_plant1 comparing werks
    SELECT AUFNR KTEXT USER4 OBJNR INTO CORRESPONDING FIELDS OF TABLE I_AUFKTAB
    FROM AUFK
    FOR ALL ENTRIES IN it_plant1
    WHERE AUFNR IN S_AUFNR AND
    KTEXT IN S_KTEXT AND
    WERKS IN S_WERKS AND
    AUART IN S_AUART AND
    USER4 IN S_USER4 AND
    werks eq it_plant1-werks.
    free it_plant1.
    Endif.
    ENDFORM. "SUB_SELECTION_AUFKTAB
    Regards
    Amole

  • Invalid Cursor when I want to modify itab with READ TABLE ?

    Following code causes a core dump and says invalid cursor.
    What should I do if I want to change gt_itab .?
    REPORT  ZEV_READ_TABLE.
    data: begin of gt_itab occurs 0,
           key like vbrk-vbeln,
           name(10) type C,
           amount type i,
          end of gt_itab .
    start-of-SELECTION.
          gt_itab-key = 1.
          gt_itab-name = 'erkan'.
          gt_itab-amount = 10.
          append gt_itab.
          gt_itab-key = 2.
          gt_itab-name = 'dilem'.
          gt_itab-amount = 20.
          append gt_itab.
          LOOP AT gt_itab.
            write:/ gt_itab-key,
                    gt_itab-name,
                    gt_itab-amount.
          ENDLOOP.
          Read table gt_itab with key Key = 1.
           if sy-subrc = 0.
              gt_itab-amount = 100.
              modify gt_itab.
           endif.
    Kind Regards.
    Erkan VAROL

    Change the code this way & try
    modify gt_itab index sy-tabix.

Maybe you are looking for