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

ABAP OO - Class cl_bcs

Former Member
0 Likes
1,610

Hi,

I'm quite new to abap oo but...anyway:

I get a exception when I try to call

  • call method lo_bcs->set_sender

1. Any pointers to why this code doesn't work.

2. Why can't I do a CREATE OBJECT on lo_bcs.

method SETADDRESS_TO_FROM .

data: lo_sender type ref to if_sender_bcs.

data: lo_bcs type ref to cl_bcs.

*CREATE OBJECT lo_bcs. DONT WORK!!!?

try.

lo_sender = cl_cam_address_bcs=>create_internet_address( i_address_string = '[email protected]' ).

catch cx_address_bcs.

exit.

endtry.

TRY.

call method lo_bcs->set_sender

exporting

i_sender = lo_sender.

CATCH CX_SEND_REQ_BCS .

ENDTRY.

endmethod.

//Martin

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
1,350

You may want to check out this weblog where cl_bcs is class use is demonstrated.

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

Regards

Raja

Hi,

I'm quite new to abap oo but...anyway:

I get a exception when I try to call

  • call method lo_bcs->set_sender

1. Any pointers to why this code doesn't work.

2. Why can't I do a CREATE OBJECT on lo_bcs.

method SETADDRESS_TO_FROM .

data: lo_sender type ref to if_sender_bcs.

data: lo_bcs type ref to cl_bcs.

*CREATE OBJECT lo_bcs. DONT WORK!!!?

try.

lo_sender = cl_cam_address_bcs=>create_internet_address( i_address_string = '[email protected]' ).

catch cx_address_bcs.

exit.

endtry.

TRY.

call method lo_bcs->set_sender

exporting

i_sender = lo_sender.

CATCH CX_SEND_REQ_BCS .

ENDTRY.

endmethod.

//Martin

9 REPLIES 9
Read only

athavanraja
Active Contributor
0 Likes
1,351

You may want to check out this weblog where cl_bcs is class use is demonstrated.

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

Regards

Raja

Read only

0 Likes
1,350

Hi,

I have read it.

This is more a OO question...

//Martin

Read only

0 Likes
1,350

data: mybcs type ref to CL_BCS ,

send_request type ref to CL_SEND_REQUEST_BCS .

TRY.

CREATE OBJECT mybcs

EXPORTING

i_send_request = send_request

.

CATCH cx_send_req_bcs .

ENDTRY.

Did you miss the mandatory parameter(i_send_request ) for the constructor.

Regards

Raja

Read only

0 Likes
1,350

Thx getting there....

Error: "You cannot creat an instance of the class " CL_BCS" outisde the class.

Any Pointers?

//Martin

Read only

0 Likes
1,350

check out these programs.

BCS_EXAMPLE_1

BCS_EXAMPLE_2

BCS_EXAMPLE_5

Regards

Raja

Read only

0 Likes
1,350

Hello Martin,

Okay, I think I get what you're saying now. If you see the attributes of the class CL_BCS, The Instantiation is supposed to be Private. which means that this class cannot be instantiated outside itself.

Does that sufficiently answer your question?

Regards,

Anand Mandalika.

Read only

0 Likes
1,350

Hi,

Thx....I see...

Is this a common approach in the abap oo world ?.

Looks strange....why do they do this?

1. Looking at other examples I can see that I need to use the method CREATE_PERSISTENT in order to make o instance of this class CL_BCS. But how should I know this?

//Martin

Read only

0 Likes
1,350

Hello Martin,

If the Instantiation for the class is defined to be <i>Private</i>, then you

cannot create the object of the class outside of the class.

=============================================================================

You have asked: <i>Is this a common approach in the abap oo world ? </i>.

There's nothing common or uncommon about it. It depends on what functionality

needs to be achieved.

=============================================================================

<i>Looks strange....why do they do this?</i>

In Java, you can actually make the constructor as private. In ABAP, however,

that is not possible. So this is another way of achieving equivalent

functonality.

=============================================================================

Now you'd like to know <i>Why do they do this...?</i>

That is a reasonably big discussion and cannot possible be explained satisfactorily

in a Forum Post. but I can tell you something: This way of disallowing external

instantiation for a class is the key to implementing OO Design Patterns.

As I had said, you can easily find other weblogs and Forum posts which can introduce

you to what these are.

Regards,

Anand Mandalika.

Read only

0 Likes
1,350

One of the aim of CREATE PRIVATE (among others) is to implement single-instance approach. E.g. you can declare some variable as static and provite and keep in it the single intstance of the class.