11-21-2007 7:58 AM
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.
11-21-2007 8:16 AM
If you want record into that itab_ref0011a then don't use keyword
"TRANSPORTING NO FIELDS"
Message was edited by:
Muthurajan Ramkumar
11-21-2007 8:03 AM
before read u sort the itab and key field.
chk the sy-subrc = 0.
0 is sucees rec found
else 1234 error.
11-21-2007 8:07 AM
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).
11-21-2007 8:16 AM
If you want record into that itab_ref0011a then don't use keyword
"TRANSPORTING NO FIELDS"
Message was edited by:
Muthurajan Ramkumar
11-21-2007 8: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
11-21-2007 8: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.
11-21-2007 8:51 AM
hi all, sorry for my typo, there shouldn't be TRANSPORTING NO FIELDS.
Basically, what I wanted to do is to READ from a first internal table and populate a second internal table based on some criteria. I understand that we can use (READ ... INTO wa) or (READ... TRANSPORTING FIELDS) for reading into a work area. But is there a faster method other than using a loop? what would be the most efficient method of reading into internal table?
11-21-2007 9:07 AM
only
READ TABLE ITAB_REF0011 WITH KEY
LN_DAT8 = ITAB_TRA-DT_DAT8 LN_TIM6 = ITAB_TRA-DT_TIM6.
should be enough for your requirement.
11-21-2007 9:16 AM
11-21-2007 8: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..
11-21-2007 8: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
11-21-2007 9: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.