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

Internal Tables Looping

Former Member
0 Likes
1,003

Hi,

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

.

.

endloop.

In above code how to find number of records selected fulfilling condition.

This I want to check within a loop and not after the endloop.

Thanks,

Pratibha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
976

Hi,

First

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

w_count = w_count + 1.

endloop.

Then again

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

*HERE CHECK W_COUNT AND DO THE REQUIRED MANIPULATION.

.

.

endloop.

Thanks and Regards,

Bharat Kumar Reddy.V

7 REPLIES 7
Read only

Former Member
0 Likes
976
loop at itab2 where lifnr = DLIFNR
and WRBTR = Dwrbtr.
<b>if sy-subrc eq 0.
count = count + 1.
endif.</b>.
.

<b>at last.
  write : / count.
endat.</b>endloop.
Read only

0 Likes
976

Thanks Sekhar for reply.

But just after loop statement I want to know the number of records selected if greater than two I want to transfer records to another internal table.

Thanks,

Pratibha

Read only

0 Likes
976

Hi,

That obviously you can get. For every loop pass chek the count and if the count is greater than 2 then pass them to other table.

Thanks and Regards,

Bharat Kumar Reddy.V

Read only

0 Likes
976

hi,

the change ur code like this.

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

count = count + 1.

if count > 2.

append itab3 from itab2.

endif.

endloop.

rgds

anver

Read only

Former Member
0 Likes
977

Hi,

First

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

w_count = w_count + 1.

endloop.

Then again

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

*HERE CHECK W_COUNT AND DO THE REQUIRED MANIPULATION.

.

.

endloop.

Thanks and Regards,

Bharat Kumar Reddy.V

Read only

anversha_s
Active Contributor
0 Likes
976

hi,

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

count = count + 1.

AT LAST

write count.

.

endloop.

rgds

anver

Read only

Former Member
0 Likes
976

Hi,

Count = 0.

Sort itab2 by lifnr WRBTR.

loop at itab2 where lifnr = DLIFNR

and WRBTR = Dwrbtr.

count = count + 1 .

if count GT 2.

Move to itab3 the contents.

endif.

endloop.