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

Loop at Conditions within internal table

Former Member
0 Likes
743

I have not been ABAPing long so primarily have been using keyword help...

I am trying to loop round an itab and only select and process unique keys from within the table!

However the table I am using to obtain the records has multiple records with the same reference and I am only interested in each unique occurrence of the IBASE_COMPONENT_GUID field.

So there could be four items for one Appliance and four for another one. So of the eight records, I would only need to loop round and select the unique GUIDS.

So there would only be two unique appliances I need to extract the records for.

Basically I am trying to do something like this:

    LOOP AT GT_ITEM_DATA INTO GS_ITEM_DATA WITH UNIQUE KEY IBASE_COMPONENT_GUID. 

Is there a way to select each unique occurrence?

I have not been ABAPing long so primarily have been using keyword help...

I am trying to loop round an itab and only select and process unique keys from within the table!

However the table I am using to obtain the records has multiple records with the same reference and I am only interested in each unique occurrence of the IBASE_COMPONENT_GUID field.

So there could be four items for one Appliance and four for another one. So of the eight records, I would only need to loop round and select the unique GUIDS.

So there would only be two unique appliances I need to extract the records for.

Basically I am trying to do something like this:

    LOOP AT GT_ITEM_DATA INTO GS_ITEM_DATA WITH UNIQUE KEY IBASE_COMPONENT_GUID. 

Is there a way to select each unique occurrence?

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
658

Basically, I use the COLLECT statement when I need to get the unique field (character only) field from the internal table.

Create a table with only one field, GUID.

LOOP through your main table, assign its GUID to new table's field GUID

Use COLLECT new_table.

Other option is,

Sort the table by GUID

Loop through it and use AT NEW GUID or AT END OF GUID

Fill out the table with this GUID.

Regards,

Naimesh Patel

Read only

0 Likes
658

>

> Other option is,

> Sort the table by GUID

> Loop through it and use AT NEW GUID or AT END OF GUID

> Fill out the table with this GUID.

Bear in mind that GUID has to be the first field of the table.

Rob

Read only

Former Member
0 Likes
658

i went for the option DELETE ADJACENT DUPLICATES before hitting the loop and that does the trick! :o]

thank you!