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

Intranl table loop logic...

Former Member
0 Likes
437

Hello Gurus,

I have a internal table filles with data from a custom table. There are two key fields and one non-key field in custom table.

Now I am looping on the internal table. I want certain logic to get executed even if first key or second key field is

different from respective previous first and second key field.

I am using following logic but it does not work.

sort itab by k1 k2.

Loop at itab.
at new k1.
at new k2.
perform logic.
endat.
endat.
endloop.

Please help.

Regards,

Jainam.

Edited by: Jainam Shah on Sep 14, 2009 9:17 PM

Edited by: Jainam Shah on Sep 14, 2009 9:18 PM

Edited by: Jainam Shah on Sep 14, 2009 9:18 PM

Edited by: Jainam Shah on Sep 14, 2009 9:19 PM

Edited by: Jainam Shah on Sep 14, 2009 9:19 PM

Edited by: Jainam Shah on Sep 14, 2009 9:20 PM

1 ACCEPTED SOLUTION
Read only

faisalatsap
Active Contributor
0 Likes
398

Hi, Shah

Do the following way,


" K1 must be the First Field in the Internal Table and K2 Must be 2nd
Loop at itab.
at new k1.
" perform logic for K1
endat.
at new k2.
" perform logic for K2
endat.
endloop.

Hope will help you to solve out your problem,

Best Regards,

Faisal

2 REPLIES 2
Read only

faisalatsap
Active Contributor
0 Likes
399

Hi, Shah

Do the following way,


" K1 must be the First Field in the Internal Table and K2 Must be 2nd
Loop at itab.
at new k1.
" perform logic for K1
endat.
at new k2.
" perform logic for K2
endat.
endloop.

Hope will help you to solve out your problem,

Best Regards,

Faisal

Read only

Sandra_Rossi
Active Contributor
0 Likes
398

When you chose AT NEW k2, there is a breakdown when k1 or k2 changes.

Loop at itab.
at new k2.
 perform logic.
endat.
endloop.