‎2007 Apr 30 12:18 PM
Hii,
How to create an internal table in Global class of Abap object.
please reply me.
regards.
Reema jain
‎2007 May 01 4:31 AM
Hi Reema,
The recommended way is to make a table type for your internal table.
If you know the structure of your internal table, make a similar structure in SE11 (say ZSTRUCTURE).
Next go to SE11 again and create a table type :
Choose Data Type and give a name(say ZTABLETYPE) and press Create, next choose the radio-button for Table Type.
In the next screen, give your structure name(ZSTRUCTURE) as the Line type.
Activate this table type.
Now go to your global class in SE24, go to attributes.
Add a public attribute of TYPE ZTABLETYPE and this attribute will be an internal table of the type you wanted.
Hope this helps.
‎2007 Apr 30 12:30 PM
Hello Reema,
Follow these steps :-
 Go to transaction SE24.
 Enter the name of the global class you want to create, with Y or Z at the beginning.
 Press Create pushbutton.
 A dialog window shown above will appear. Check the radiobutton : Class.
 Press Enter.
 Another dialog window shown above will appear. Enter the description for the class.
 Select from the Instantiation listbox whether you want to create the class as PUBLIC/PROTECTED/PRIVATE/ABSTRACT.
 Check the radiobutton for Usual ABAP Class.
 Check the checkbox for Final.
 Press Save pushbutton
Enter the package name or save it as Local object.
 Go to the tab-page : Methods.
 Enter the details for the method mention name, type of method(instance/static), in which visibility section the method will reside and a short description of the method.
 Check off/uncheck the checkbox to ensure that the method will be implemented
Click the pushbutton for Parameters to navigate to the screen to enter parameters for the method.
<b>Here you can give the name of an internal table with associated type TABLE</b>
Rewards points if helpful
Thanks,
Sachin
‎2007 Apr 30 12:47 PM
hi sachin,
I want attribute of a global class as an internal table.Is it possible.
Regards.
Reema jain.
‎2007 Apr 30 2:33 PM
Hello Reema jain,
Just go in the se24 and edit your class.
In the tab 'Attribut'
add the name of your attribute, if it is an instance attribute or a constant..., the visibility (public/protected...) and the type (enter here the type of your internal table).
Regards,
Walter
‎2007 Apr 30 10:51 PM
Hello Reema
If your instance attribute is private then you can use private table type definitions to define an itab, e.g.:
" Type definition in private section
TYPES:
ty_t_knb1 TYPE STANDARD TABLE OF knb1." Define your instance attribute using this type definition, e.g.:
MT_KNB1 (instance, private) TYPE ty_t_knb1.However, if your itab should be either protected or even public then you must use a table type defined in the DDIC, e.g.:
MT_RETURN (instance, public) TYPE bapirettab (= table type of BAPIRET2).Regards
Uwe
‎2007 May 01 4:31 AM
Hi Reema,
The recommended way is to make a table type for your internal table.
If you know the structure of your internal table, make a similar structure in SE11 (say ZSTRUCTURE).
Next go to SE11 again and create a table type :
Choose Data Type and give a name(say ZTABLETYPE) and press Create, next choose the radio-button for Table Type.
In the next screen, give your structure name(ZSTRUCTURE) as the Line type.
Activate this table type.
Now go to your global class in SE24, go to attributes.
Add a public attribute of TYPE ZTABLETYPE and this attribute will be an internal table of the type you wanted.
Hope this helps.
‎2007 May 01 7:55 AM
Hai Reema Jain,
Just like declaring a data object(variable),You can declare them in your global class.
Example:
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS m1 IMPORTING p1 TYPE string.
PRIVATE SECTION.
DATA a1 TYPE string.
<b> DATA:
BEGIN OF ITAB ,
FIELD1 TYPE C,
FILED2 TYPE I,
END OF ITAB,
T_ITAB LIKE STANDARD TABLE OF ITAB.</b>
METHODS m2.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1.
a1 = p1.
m2( ).
ENDMETHOD.
METHOD m2.
DATA a1 TYPE string.
a1 = me->a1.
write:
/ a1.
ENDMETHOD.
ENDCLASS.
DATA:
OREF TYPE REF TO C1.
START-OF-SELECTION.
CREATE OBJECT OREF.
CALL METHOD OREF->M1('abc').
Hope this helps you.
Regds,
Rama chary.Pammi