Skip to Content
author's profile photo Former Member
Former Member

Can't read from one itab to another?

Hi.

I have two ITABS: ITAB_REF0011 and ITAB_REF0011A.

ITAB_REF0011 has 169 records. When I run the following statement, ITAB_REF0011A returns no records. Why is that so? Thanks.

*************************************************************

SORT ITAB_REF0011 BY LN_DAT6 .

READ TABLE ITAB_REF0011 WITH KEY

LN_DAT8 = ITAB_TRA-DT_DAT8 LN_TIM6 = ITAB_TRA-DT_TIM6

BINARY SEARCH TRANSPORTING NO FIELDS INTO TABLE ITAB_REF0011A.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 08:16 AM

    If you want record into that itab_ref0011a then don't use keyword

    "TRANSPORTING NO FIELDS"

    Message was edited by:

    Muthurajan Ramkumar

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 21, 2007 at 08:18 AM

    Hi Kian,

    I never heard of this syntax:

    TRANSPORTING NO FIELDS INTO TABLE ITAB_REF0011A

    1. You cant' read INTO TABLE - this is only for SELECT

    2. If you use TRANSPORTING NO FIELDS you don't need a work area as target because nothing is returned.

    You may

    loop at ITAB_REF0011 where 
      LN_DAT8 = ITAB_TRA-DT_DAT8 and 
      LN_TIM6 = ITAB_TRA-DT_TIM6.
    append ITAB_REF0011 to ITAB_REF0011A.
    endloop.
    
    If you think this is too slow, then
      - define  ITAB_REF0011 like sorted table of ... with [NON-] unique key DT_DAT8 DT_TIM6
      - use loop ... assigning <field-symbol>.
    
    Regards,
    
    Clemens
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 08:03 AM

    before read u sort the itab and key field.

    chk the sy-subrc = 0.

    0 is sucees rec found

    else 1234 error.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi. I am expecting 1 record in the second table (ITAB_REF0011A).

      Is there anything wrong with my syntax? In fact, I think this code will generate an error (because of the TABLE in the statement).

  • Posted on Nov 21, 2007 at 08:18 AM
    SORT ITAB_REF0011 BY LN_DAT6 LN_TIM6.  " add LN_TIM6.
    
    LOOP AT ITAB_TRA. " Add this line
    
    READ TABLE ITAB_REF0011 WITH KEY
    LN_DAT8 = ITAB_TRA-DT_DAT8 
    LN_TIM6 = ITAB_TRA-DT_TIM6
    BINARY SEARCH. 
    if sy-subrc eq 0.
    Append itab_ref0011 to ITAB_REF0011A.
    endif.
    
    ENDLOOP.
    
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 08:21 AM

    Hi kian,

    If both tables having the same structure.Better to use this syntax.That will copy one table contents to another.

    ITAB_REF0011[] = ITAB_REF0011A[].

    or

    MOVE ITAB_REF0011 TO ITAB_REF0011A.

    If u r satisfy with the answer give me the REWARD POINTS..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 08:30 AM

    Hi,

    'TRANSPORTING NO FIELDS INTO TABLE ITAB_REF0011A' is causing the problem for you. Better don't use 'TRANSPORTING NO FIELDS '.

    Regards,

    Simy Abraham.

    Message was edited by:

    Simi Abraham

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 09:15 AM

    Hi,

    <b>When you are using a binarysearch on an internal table

    You need to sort the table using the same keys you are reading or else you will not get the correct data

    Data will be mismatched.</b>

    Regards,

    Siva chalasani

    Reward points if usefull.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.