‎2006 Dec 12 5:53 AM
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
‎2006 Dec 12 5:55 AM
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
‎2006 Dec 12 5:55 AM
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
‎2006 Dec 12 6:03 AM
Thnx naren,
But my doubt is how to declare data type of an internal table in se24.
‎2007 Jan 21 10:21 AM
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.
‎2006 Dec 12 6:09 AM
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
‎2006 Dec 12 6:39 AM
Hello,
Welcome to sdn,
Use the TABLES parameter.
Regards,
Shehryar Dahar
‎2006 Dec 12 7:05 AM
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
‎2007 Jan 17 4:56 AM
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
‎2007 Jan 17 5:19 AM
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
‎2007 Jan 18 5:44 AM
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
‎2007 Jan 18 5:54 AM
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