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

Declaring the internal table in ABAP objects

Former Member
0 Likes
11,800

Hi every1,

Please any one let me know how to declare an internal table in class (ABAP objects). Bcos i am new to this classes.

help me out.

Regards,

Madhavi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,304

Hi,

Check this example..

TYPES: BEGIN OF TYPE_DATA,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

END OF TYPE_DATA.

DATA: T_DATA TYPE STANDARD TABLE OF TYPE_DATA.

DATA: WA_DATA TYPE TYPE_DATA.

  • Adding rows to the internal table.

WA_DATA-MATNR = 'AA'.

APPEND WA_DATA TO T_DATA.

  • Processing the interna table

LOOP AT T_DATA INTO WA_DATA.

ENDLOOP.

Thanks,

Naren

10 REPLIES 10
Read only

Former Member
0 Likes
2,305

Hi,

Check this example..

TYPES: BEGIN OF TYPE_DATA,

MATNR TYPE MATNR,

WERKS TYPE WERKS_D,

END OF TYPE_DATA.

DATA: T_DATA TYPE STANDARD TABLE OF TYPE_DATA.

DATA: WA_DATA TYPE TYPE_DATA.

  • Adding rows to the internal table.

WA_DATA-MATNR = 'AA'.

APPEND WA_DATA TO T_DATA.

  • Processing the interna table

LOOP AT T_DATA INTO WA_DATA.

ENDLOOP.

Thanks,

Naren

Read only

0 Likes
2,304

Thnx naren,

But my doubt is how to declare data type of an internal table in se24.

Read only

0 Likes
2,304

First declare a <b>Line type</b> and assign it to class attributes. Inside the class use a normal ABAP to populate the data for this internal table.

Regards,

Ramki.

Read only

Former Member
0 Likes
2,304

Hi,

Do you want to pass parameter to the method as an internal table..

THen create a table type in SE11..

Then use it in the method parameters to make it as an internal table..

Creating table type

-


You should define a table type Standard table in transaction SE11. In transaction SE11 go to field Data Type and insert the name of table, click on button create and select Table Type in the pop up window showed, in the next screen define the Line type of the table. THen save and activate..

Thanks,

Naren

Read only

Former Member
0 Likes
2,304

Hello,

Welcome to sdn,

Use the TABLES parameter.

Regards,

Shehryar Dahar

Read only

Former Member
0 Likes
2,304

Hi ,

It is same as normal abap report .

class <class name> definition .

public section .

data : it_mara type table mara .

---

---

---

endclass.

class <class name > implementation .

---

---

---

endclass.

start-of-selection.

types obj type ref to <class name> .

create object : obj1 type obj .

call method obj1-><method name> .

Please do reward points

Message was edited by:

Thasneem Fathima

Read only

Former Member
0 Likes
2,304

hai

goto tcode se24

create a class ZCLASS

In the application tool bar you can see LOCAL TYPES tab

there you can create your structure like

TYPES : begin of t_vbap,

vbeln type vbap-vbeln,

posnr type vbap-posnr,

end of T_vbap.

Below in the tab strip while creating methods,

you can declare internal tables like

DATA: i_vbap TYPE TABLE OF t_vbap.

Subhash.M

Read only

Former Member
0 Likes
2,304

class <class name> definition .

public section .

types : itab_mara type table mara .

methods fetch_data importing i_tab type itab_mara

exporting s_matnr type rsparams. ---

---

---

endclass.

class <class name > implementation .

---

method fetch_data (fetch the data using slect statement)

---

endclass.

types obj type ref to <class name> .

start-of-selection.

create object : obj1 type obj .

call method obj1-><method name> .

Please do reward points

Read only

Former Member
0 Likes
2,304

hi,

if u want to declare an internal table use the following one.

IT_MARA TYPE TABLE OF MARA.

if u want work area of type mara use the following one.

WA_MARA TYPE MARA.

reward if helpful

Read only

Former Member
0 Likes
2,304

Hi,

You cannot use the occurs clause in internal table declaration for classes.

for eg:

data: begin of wa_itab,

saknr like ska1-saknr,

prctr like cepc-prctr,

aufnr like aufk-aufnr,

end of wa_itab.

data: itab like table of wa_itab.

Regards

Subramanian