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: 

Class Constructor

Former Member
0 Kudos

Hi experts,

I have the doubt about class constructor.

I write the code in Class constructor like,

DATA : ZCURRSTR TYPE IHTTPNVP,
       ZCURRTTYPE TYPE TIHTTPNVP.

ZCURRSTR-NAME   = 'INDIA'.
ZCURRSTR-VALUE  =  'RS'.
APPEND ZCURRSTR TO ZCURRTTYPE.

Now I want to call this Table ZCURRTTYPE in One of the method of Same class.

Any one help me on this issue.

Thanks in Advance,

Points Assured for all suggestions.

1 ACCEPTED SOLUTION

sreemsft
Contributor
0 Kudos

Hi Jasmine,

I think i gave you an example on this in ABAP forums.

<i>Please reward if that helps you and close both the forums.</i>

Thanks,

Sreekanth

3 REPLIES 3

sreemsft
Contributor
0 Kudos

Hi Jasmine,

I think i gave you an example on this in ABAP forums.

<i>Please reward if that helps you and close both the forums.</i>

Thanks,

Sreekanth

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jasmine

The class constructor is executed <i>once </i>for all instances of your class within your application. Since you can always access static attributes from within any instance method simply code within your instance method:

METHOD my_instance_method.
* define local data
  DATA:
    ls_zcurrstr     TYPE ihttpnvp.

  READ TABLE zcurrttype INTO ls_zcurrstr INDEX 1.  " read first entry in static itab
...
ENDMETHOD.

Regards

Uwe

GrahamRobbo
Active Contributor
0 Kudos

Hi Jassy,

the table ZCURRTTYPE must be defined as a class attribute so it is available from all methods.

Cheers

Graham Robbo