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

Read statment issue

Former Member
0 Likes
842

Hi all,

can anyone tel lme how to read the record

itab.

f1 f2 f3

1 1 a

1 2 a

1 4 a

1 5 a

2 7 b

2 5 b

3 1 c

3 2 c

loop at itab2 into wa2.

read table itab into wa1 with key f1 = wa-f1

f3 = wa-f3.

i want the max f2 one say if f1 = 1, f3 = a i want 1 5 a

and if f1 =2 AND F3 = B I WANT THIS RECORD IN WA1 2 7 b

endloop.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
820

before looping insert the code.

sort itab2 by f1 f2 descending f3.

6 REPLIES 6
Read only

Former Member
0 Likes
821

before looping insert the code.

sort itab2 by f1 f2 descending f3.

Read only

0 Likes
820

Thank you all

Read only

Former Member
0 Likes
820

sorry

sort itab by f1 f2 descending f3.

Read only

Clemenss
Active Contributor
0 Likes
820

Hi preeti,

sort itab.
loop at itab into wa1.
  at end of f2.
  append wa1 to itab2.
  endat.
endloop.

Regards,

Clemens

Read only

Former Member
0 Likes
820

Hi,

Sort the itab by f1, f3 and f2.

then use, AT END OF statement.

AT END OF F1-- move that record into another internal table .

Read only

Former Member
0 Likes
820

Hi Preeti,

Use SORT statement before LOOP...ENDLOOP.

<b>SORT ITAB BY F1 F2 DESCENDING F3.</b>

loop at itab2 into wa.

read table itab into wa1 with key f1 = wa-f1

f3 = wa-f3.

<b>IF SY-SUBRC = 0.

WRITE:/ WA1-F1 , WA1-F3.

ENDIF.</b>

endloop.

Thanks,

Vinay