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

Class Constructor

Former Member
0 Likes
560

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
Read only

sreekanthgo
Contributor
0 Likes
505

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
Read only

sreekanthgo
Contributor
0 Likes
506

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

Read only

uwe_schieferstein
Active Contributor
0 Likes
505

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

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
505

Hi Jassy,

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

Cheers

Graham Robbo