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

global class

Former Member
0 Likes
2,282

Hii,

How to create an internal table in Global class of Abap object.

please reply me.

regards.

Reema jain

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,397

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.

6 REPLIES 6
Read only

sonu_p2
Active Participant
0 Likes
1,397

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

Read only

Former Member
0 Likes
1,397

hi sachin,

I want attribute of a global class as an internal table.Is it possible.

Regards.

Reema jain.

Read only

Former Member
0 Likes
1,397

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

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,397

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

Read only

Former Member
0 Likes
1,398

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.

Read only

Former Member
0 Likes
1,397

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