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: 

To access different lines in an in internal table

Former Member
0 Kudos
151

Hi People,

How can I access different lines of an internal table where there is not set index which I have to access? I have to write only the last occurence of each kunnr getting stored in the internal table. Can somebody help?

Thanks,

AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
83

Hi,

you can try using control break statements in a loop endloop statement.

at new - will get fired at every new value of say kunnr.

at end of - will get fired at end of a set of common value say kunnr.

at first - will occur only at the starting of loop for the first time.

at last - will get fired at the last loop occurence.

Regards,

Jagath.

7 REPLIES 7

Former Member
0 Kudos
84

Hi,

you can try using control break statements in a loop endloop statement.

at new - will get fired at every new value of say kunnr.

at end of - will get fired at end of a set of common value say kunnr.

at first - will occur only at the starting of loop for the first time.

at last - will get fired at the last loop occurence.

Regards,

Jagath.

0 Kudos
83

If you internal table si sort by kunnr, you can try this :


loop at itab.

at end of kunnr.
move itab-....
endat.

endloop.

Hope this helps,

Erwan.

0 Kudos
83

Hi,

What about:

data: count type i.

count = lines( itab ).

read table itab index count into ...

or if you can sort it

sort itab by kunnr descending.

read table itab index 1 into ...

Eddy

0 Kudos
83

Hi Eddy,

The logic u gave is wrong.If there are two kunnr available in the internal table.Then it will take the last value of the highest kunnr no.

I think at <b>end of kunnr</b> will be correct.

With Regards,

Ranganathan

0 Kudos
83

Oeps, I misunderstood the question. Sorry for that.

Former Member
0 Kudos
83

Hi AM,

You have got multiple solutions, each one of those are based on some assumptions.

1. At end - this solution will work if kunnr is the first field in your internal table (Sorted).

2. Edde's solution will work if all the values for kunnr in the internal table are same.

If not of this applies then you need write a piece of logic between LOOP and ENDLOOP, but the right solution will depend on the exact nature of your problem. More you explain your problem better are the chances of getting a solution.

Regards,

Sanjeev

0 Kudos
83

Thanks everybody.

These different answers solved my problem.

regards,

AM