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: 

Read table

Former Member
0 Kudos

Hi Team,

I have a requirment where I need to read entries with *

For Exa :

My Internal table contains Rec1 with SORTL = AB1234 .

And table key contains value lv_sortl = 1234.

I need to retrive the Rec1 though it has AB1234. Normally we can do the similar thing on DB table

(i.e) In select Options for field SORTL if we give *1234, then a Record is displayed. Now I need to do the similar thing through Program.

Currently I am using the below which is helpless.

READ TABLE i_kna1 INTO wa_kna1 WITH KEY sortl = lv_sortl.

I have a solution I need to loop the Internal table and use String Operators(Contains any or Contains Pattern), but I cant do this because its a huge table and I have to loop it everytime inside a loop.

Is there any alternate way to do this ?

Thanks in advance.

use proper subject line for your posts

Edited by: Vijay Babu Dudla on Jan 20, 2009 8:18 AM

5 REPLIES 5

Former Member
0 Kudos

u can use...

loop at it_kna1 into wa_kna1 where sortl cp lvsortl.

"value..

endloop.

but i dunno how u can assign the correct one if KNA1 has records with sortl = AB1234 , sortl = BC1234 etc?

Former Member
0 Kudos

Hi Ravinder,

I dont think there is a way of using string comparision when we use READ statement.

I feel, LOOP should be ok. As we are looking for only one record, Once the record is found you can use EXIT statement to terminate the loop. In this way, performance is not affected.

Best Regards,

Ram.

Former Member
0 Kudos

hi

 
data : begin of itab occurs 0 ,
       sortl(6) type c,
       end of itab.

data : begin of jtab occurs 0 ,
sortl(6) type c,
end of jtab.

itab-sortl = 'AB1234'. APPEND ITAB.
JTAB-SORTL = '1234'.  APPEND JTAB.

case1. 
*LOOP AT ITAB.
*LOOP AT JTAB WHERE SORTL EQ ITAB-SORTL+2(4).
*
*IF SY-SUBRC EQ 0.
*WRITE 😕 'THROUGH'.
*EXIT.
*ENDIF.
*ENDLOOP.

LOOP AT ITAB.
READ TABLE JTAB WITH KEY SORTL = ITAB-SORTL+2(4). " read with the offset

IF SY-SUBRC EQ 0.
WRITE 😕 'THROUGH'.
ENDIF.
ENDLOOP.

if you can check the offset u want to compare then this can be done .

Br,

Vijay.

Former Member
0 Kudos

Hi Ravindar,

You can achieve this with the following read statement,

READ TABLE i_kna1 INTO wa_kna1 WITH KEY sortl = lv_sortl+2(4).

Hope this helps you.

Regards,

Manoj Kumar P

Edited by: Manoj Kumar on Jan 20, 2009 7:55 AM

Former Member
0 Kudos

Answered