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

ABAP collection similar to Java collection

Former Member
0 Likes
2,282

Hi Folks,

I was wondering if there's ABAP collection object similar to java collection (arraylist, hashmap, etc) that I can I use as storage of objects so I can just iterate them once needed.

Thanks,

Robert

Hi Folks,

I was wondering if there's ABAP collection object similar to java collection (arraylist, hashmap, etc) that I can I use as storage of objects so I can just iterate them once needed.

Thanks,

Robert

6 REPLIES 6
Read only

Sm1tje
Active Contributor
0 Likes
1,207

I'm not familiar with Java collections, but for storing multiple line of data in ABAP, we used internal tables which you can iterate with:


LOOP AT internal_table INTO 

ENDLOOP.

Look at F1 help on LOOP statement and how to declare these internal tables.

Read only

Former Member
0 Likes
1,207

Can I use this internal table as return type of method? Thanks.

Read only

Former Member
0 Likes
1,207

sure, just look at method signature and define a return parameter with the type of internal_table.

Read only

Former Member
0 Likes
1,207

Hi ,

You can find internal tables as arraylist in Abap.Below link will help u in understanding Internal tables in detail.

http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb35de358411d1829f0000e829fbfe/content.htm

Thanks,

Ramakrishna.

Read only

Former Member
0 Likes
1,207

Was recently wondering myself...also needed to have a "collection" of objects as a return value.

so found solution like this. The rest is like working with tables...

types:

my_object_collection TYPE STANDARD TABLE OF REF TO if_my_object with DEFAULT KEY.

methods GET_MY_OBJECTS

returning

value(MY_OBJECTS) type MY_OBJECT_COLLECTION.

Edited by: Konstantin Tarmyshov on Aug 12, 2009 2:10 PM

Read only

0 Likes
1,207

Hi,

there are Classes in ABAP:

CL_OBJECT_COLLECTION which is a collection

and

CL_OBJECT_COLLECTION_ITERATOR that can be used to Iterate over a collection.

You can put every Object into such a collection.