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

Selection from an internal table

Former Member
0 Likes
608

Dear Experts,

I need your help.

I have an internal table like the one mentioned below :

GUID TITLE STatus Review cycle reviewstep date

AAA doc1 started 2 1 10.05.2009

AAA doc1 started 1 1 08.05.2009

AAA doc1 released 1 2 09.05.2009

BBB doc2 started 1 1 14.05.2009

BBB doc2 released 1 2 15.05.2009

CCC doc3 started 1 1 16.05.2009

My output should be

title Status review cycle reviewstep date

doc1 started 2 1 10.05.2009

doc2 released 1 2 15.05.2009

doc 3 started 1 1 16.05.2009

As you say my aim is to fetch the maximum value of the review cycle in the output .

If its a direct fetch from database i can use select max but this is an internal table.

Please help.

Thanks in advance.

Swarna

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
576

Hi,

Try using the below concept.

Say the data you have in your internal table is IT_FINAL


SORT it_final BY guid title ASCENDING review cycle DESCENDING.

DELETE ADJACENT DUPLICATE FROM it_final COMPARING guid title.

Hope this helps you.

Regards,

Tarun

5 REPLIES 5
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
577

Hi,

Try using the below concept.

Say the data you have in your internal table is IT_FINAL


SORT it_final BY guid title ASCENDING review cycle DESCENDING.

DELETE ADJACENT DUPLICATE FROM it_final COMPARING guid title.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
576

1. Sort GUID TITLE ascending STatus Review cycle reviewstep date descending

2. Delete adjacenet duplicates from internal table,

Then you will get desired output.

Thanks,

Raj

Read only

Former Member
0 Likes
576

guess this below shown are your data in internal table IT.

AAA doc1 started 2 1 10.05.2009

AAA doc1 started 1 1 08.05.2009

AAA doc1 released 1 2 09.05.2009

BBB doc2 started 1 1 14.05.2009

BBB doc2 released 1 2 15.05.2009

CCC doc3 started 1 1 16.05.2009

so you can use the following code for getting max review cycle.

SORT IT BY REVIEW CYCLE DESCENDING.

READ TABLE IT INTO WA INDEX 1.

SO THE FIRST RECORD WILL BE WITH MAXIMUM DATA.

Read only

Former Member
0 Likes
576

hello mate

apply the following logic

Step 1 : Sort the internal table by field name descending order

sort itab by fieldname descending

Step 2 : To Fetch the MaX value at first

Describe tables itab lines lin. for minimum

Step 3 . Read table itab index 1.

You will be getting the maximum first

regards

anand kumar

Edited by: anand kumar on Jul 10, 2009 6:26 AM

Read only

Former Member
0 Likes
576

You can do it by sorting the internal table and deleting the duplicate record.