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: 

Internal table issue.

Former Member
0 Kudos

Hi Experts,

i have an internal table eg t_final.

with fields

State

plant

qty

Now i sorted the table as -


>>>


sort t_final1 by  state ASCENDING
                           plant DESCENDING .

Now data in t_final is as follows---


state   plant    qty
20       1015    10  
20       1015     8
20       1001     5
25       1555    100  
25       1555    100
25       1550     88
23       1441     86

i need the 1st record every state and plant which should look as follows.


state   plant    qty
20       1015    10  
25       1555    100  
23       1441     86

above should be the data in the t_final.

How can i do this, please help.

Thanks and Regards,

Akash Rana

1 ACCEPTED SOLUTION

sastry_gunturi
Active Participant
0 Kudos

loop on your internal table and use

at new state

control event

9 REPLIES 9

GauthamV
Active Contributor
0 Kudos

Use this statement after your sort.

Delete adjacent duplicates from t_final1 comparing state.

Former Member
0 Kudos

Dear Friend,

i did the same but some duplicate records also get completely deleted so this is not resolving the issue.

Thanks

Akash Rana

sastry_gunturi
Active Participant
0 Kudos

loop on your internal table and use

at new state

control event

0 Kudos

Dear Kartik,

Still i have many other records of the same state....i just need the first record of every state.

Regards,

Akash Rana

0 Kudos

Loop the internal table you at new state command and move the first row to a separate internal table.... I believe this works.

0 Kudos

Dear Kartik,

I did exactly u wrote but my field stateis placed in between internal table its in 7th column,

So i am getting duplicate entries in the other internal table in which i am apending the wa at

"AT new "

also fields after state gets append as ************ according to the length.

Regards,

Akash Rana

0 Kudos

use on change of STATE. using at new etc events puts * in all other fields after the chosen field.

Edited by: Prakash Sethia on Sep 10, 2009 6:40 PM

0 Kudos

Hi,

Try this.

sort t_final1 by state ASCENDING

plant DESCENDING .

      • Define a variable ws_state similar to the data type of t_final1-state.

clear ws_state.

loop at t_final1 into wa_final1.

if ws_state = wa_final1-state.

delete t_final1.

continue.

else.

ws_state = wa_final1-state.

endif.

endloop.

Regards,

Subramanian

0 Kudos

Thanks Subramanian PL

i had already done similar to your resolution...my issue got resolved.

Thanks a lot.

Regards,

Akash Rana