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: 

Collection in ABAP

Former Member
0 Kudos

Hello Friends,

Is there some kind of collection or Array concept in ABAP, Like in JAVA ( Java.util.Collection)??

In loop I want to take values 1 by 1 and store it in some kind of collection ??

Many thanks

Marek

8 REPLIES 8

Former Member
0 Kudos

Hi Marek,

You can use internal tables in ABAP programming as arrays/collections.If you really want to implement a specific kind of collection like stack or map etc. you can program a class of which methods supply you the necessary element of the internal table. Otherwise you can use internal tables simply as arrays(there are also kinds of internal tables like sorted, standard and hash tables). You can find detailed info and examples about internal tables in the standard abap help.

Kind Regards,

Sükrü

0 Kudos

Hi,

Can you pls specify and documentation, for using and working with Internal tables ??

Many thanks for your kind help!

Marek

0 Kudos

Hi Marek,

You can get all the documentation related to the Internal Tables here

http://help.sap.com/saphelp_nw04/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

Regards

Sidharth

0 Kudos

Hi Marek

As Suekrue stated, in ABAP the closest concept to an "array" is an "internal table". You can think of them as structured and semanticly-defined matrices. They are like database tables, but are not persistent i.e their lifetime is the programs' runtime.

You can define an internal table in various ways.

<u><b>e.g.</b></u>


DATA: BEGIN OF gt_itab OCCURS 0 ,
        <colmun_1> LIKE/TYPE <data_element/variable> ,
        <colmun_2> LIKE/TYPE <data_element/variable> ,
        ....
        <colmun_n> LIKE/TYPE <data_element/variable> ,
      END OF gt_itab .

With this data declaration, you define an internal table having n columns and several rows (row number is not indicated).

Alternatively, you can define internal table type at data dictionary and refer to them as

DATA gt_itab TYPE <DDIC_table_type> .

or you can refer a structure to be the row-type of an internal table as:

DATA gt_itab LIKE <DDIC_structure> OCCURS 0 .

However, reaching to specific records is not done directly indicating the coordinate. You read rows to a work area and reach its field by "-" operator.

<b><u>e.g.</u></b>

READ TABLE gt_itab INTO gs_itab INDEX 5 . "read fifth row"
WRITE:/ gt_itab-<column_name> .

For more information, I strongly recommend you to inspect SAP Online Help whose address was mentioned at Sidharth's post and the book

<a href="http://www.sap-press.com/product.cfm?account=&product=H958">"ABAP Objects — The Official Reference" A comprehensive guide to all ABAP language elements</a>

by Horst Keller & Joachim Jacobitz

or

"ABAP Objects: Introduction to Programming SAP Applications" by Horst Keller, Sascha Kruger.

*--Serdar

Message was edited by: Serdar Simsekler

0 Kudos

Hi Serdar,

The link does not work for ABAP Objects — The Official Reference" A comprehensive guide to all ABAP language elements .

Can you send the document to fulugay@yahoo.com.

Thanks

0 Kudos

Hi Fuat

I have replaced the new URL. It is the URL of SAP-Press introducing the book not of its e-book.

*--Serdar

0 Kudos

Hi Guys,

Thanks for the valuable input!

I'll revert to you guys soon!

Thanks once again!

With regards,

Marek

0 Kudos

Hi Marek,

Please remember to reward points in this forum. You can reward points by clicking on 'yellow star' which appears next to two icons: 'Reply' and 'email this post'.

Please let me know if you have any questions.

Thanks

Naved