Application Development and Automation 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 only

Alternate to READ statement

Former Member
0 Likes
2,383

Purpose :- To read multiple rows of internal table on a search criteria.

Read statement selects only single row.

Any other option to select multiple rows at a time?

Answers will be rewarded!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,026

Hi,

Make use of LOOP Statement.

Example.

LOOP AT ITAB WHERE MATNR = '11111'.

DO U MANIPULATIONS HERE

ENDLOOP.

Regards,

Balakumar.G

Reward Points if helpful.

Purpose :- To read multiple rows of internal table on a search criteria.

Read statement selects only single row.

Any other option to select multiple rows at a time?

Answers will be rewarded!

16 REPLIES 16
Read only

Former Member
0 Likes
2,026

use select *

SELECT * FROM dbtab ... INTO wa ...

SELECT * FROM dbtab ... INTO TABLE itab ...

SELECT * FROM dbtab ... APPENDING TABLE itab ...

Read only

Former Member
0 Likes
2,027

Hi,

Make use of LOOP Statement.

Example.

LOOP AT ITAB WHERE MATNR = '11111'.

DO U MANIPULATIONS HERE

ENDLOOP.

Regards,

Balakumar.G

Reward Points if helpful.

Read only

Former Member
0 Likes
2,026

use loop .. endloop instead of read ... there is no other

alternative ..

loop at itab where <condition>.

  • your coding ...

endloop.

Read only

Former Member
0 Likes
2,026

Use Loop at statement .

To know your specific requirements , use F1 in the ABAP Editor.

Loop at itab where (condition).

endloop.

Read only

Former Member
0 Likes
2,026

Hi,

Use "Loop at ... Where" inorder to process all the records of internal table where your condition is met.

Reward points if this helps,

Kiran

Read only

Former Member
0 Likes
2,026

Hi,

Use LOOP AT <itab>.... ENDLOOP

Reads multiple rows in a internal table

You can also restrict by using WHERE, FROM..TO

LOOP AT <itab> WHERE <condition>

LOOPA AT <itab> FROM 2 TO 3.

Thanks and Best Regards,

Ruthra

Read only

Former Member
0 Likes
2,026

Hi,

To select multiple rows at a time use

loop at where clause.

Reward.

Read only

Former Member
0 Likes
2,026

it is like this:-

in itab1 i have sno , name , address.

1 xyz abc

2 aaa bjhj

in itab2 i have sno , subject , marks

1 en 33

1 mm 55

2 en 44

No i will loop thru itab1 and want to retrieve all the marks of sno = 1. Is this poss without using 2 loop at 's.

Read only

0 Likes
2,026

Hi,

Inorder to retrive the marks u can use this code

Loop at itab1 into wa_itab1.

read table itab2 with key sno = wa_itab1-sno into wa_itab2

If sy-subrc =0.

move : wa_itab2-marks to wa_marks-marks.

append wa_marks to it_marks.

Now it_marks contains the marks of it_itab2

Read only

Former Member
0 Likes
2,026

Hi Friend,

Use

Loop at itab1 where < Specigy search pattern > in to itab2 up to n rows.

Endloop.

Regards,

Suresh.S

Edited by: Suresh Babu S on Mar 24, 2008 10:48 AM

Edited by: Suresh Babu S on Mar 25, 2008 8:22 AM

Read only

Former Member
0 Likes
2,026

no other way rather than internal table or else use read statement continously if you want to pick 2 or 3 rows

Read only

Former Member
0 Likes
2,026

use..loop at itab1 into wa1.

instead of read

reward points if useful

Read only

Former Member
0 Likes
2,026

Hi,

TYPES: BEGIN OF T_TYPE, 
        LINE(80), 
      END OF T_TYPE. 

DATA: T TYPE STANDARD TABLE OF T_TYPE WITH 
             NON-UNIQUE DEFAULT KEY, 
      WA_T TYPE T_TYPE. 

MOVE 'Alaska Texas       ' TO WA_T. 
APPEND WA_T TO T. 
MOVE 'California Arizona ' TO WA_T. 
APPEND WA_T TO T. 
SEARCH T FOR '*ONA' AND MARK.

Rgds

Vijay

Read only

Former Member
0 Likes
2,026

hope this is what u are looking for -

read table itab with key val1 = 'XXXX'

if sy-subrc EQ 0.

l_tabix = sy-tabix

loop at itab from l_tabix .

if itab-val1 NE 'XXXX'

exit.

endif.

< do processing on multiple records here >

endloop.

endif.

Read only

Former Member
0 Likes
2,026

do remember to pre-sort itab before u do this

Read only

Former Member
0 Likes
2,026

HI

Thaks for the replies. All f them were useful.But i am not sure how gud the performance will be when using 2 loop at 's.