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

Constructor Signature

ammad_zaman
Explorer
0 Likes
2,180

hi

i have just solved an example for method and i m reading the constructor ... the issue is i have read that the "Constructor's signature cannot have importing parameters or exception " where as in almost all examples i saw importing parameter passed by constructors.

kindly help me to remove my confusion

Regards

Ammad

5 REPLIES 5
Read only

Former Member
0 Likes
1,300

Constructors can only have Importing and Execptions.

They are special methods that is called at runtime as soon as object has been generated in the memory.

Ex:

Calss <name> Definition.

Method Constructor
 Importing
 parameter type <type>
Execptions
 Execption.
Endclass.

[Refer|https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abap%252bobjects%252b-%252bcreating%252byour%252bfirst%252blocal%252bclass%252b-%252busing%252binstance%252bconstructor]

Regards,

Gurpreet

Read only

former_member376453
Contributor
0 Likes
1,300

This message was moderated.

Read only

MarcinPciak
Active Contributor
0 Likes
1,300

Hi Ammad,

You probably missread something. What you say is oposite to the truth.

Instance contructor (so the one which is called an object of the class is created) can have only IMPORTING parameters and EXCEPTIONS (but doesn't have to). No EXPORTING and RETURNIG ones are possible though.

On contrary, class contructor (created only once when first object of class is created) cannot have any of the parameters (no interface to it is allowed).

Hope this claryfies your confusion.

Regards

Marcin

Read only

Former Member
0 Likes
1,300

Hi:

have a look

[Constructor|http://help.sap.com/saphelp_erp2004/helpdata/EN/08/d27c03b81011d194f60000e8353423/content.htm]

Regards

Shashi

Read only

Former Member
0 Likes
1,300

Hi,

Constructors only have importing and exceptions signatures