Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't read from one itab to another?

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

"TRANSPORTING NO FIELDS"

Message was edited by:

Muthurajan Ramkumar

11 REPLIES 11

Former Member
0 Kudos

before read u sort the itab and key field.

chk the sy-subrc = 0.

0 is sucees rec found

else 1234 error.

0 Kudos

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

Former Member
0 Kudos

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

"TRANSPORTING NO FIELDS"

Message was edited by:

Muthurajan Ramkumar

Clemenss
Active Contributor
0 Kudos

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

former_member223537
Active Contributor
0 Kudos

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.

0 Kudos

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?

0 Kudos

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.

0 Kudos

see my post for most efficient solution.

Regards,

Clemens

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.