2005 Apr 13 12:18 PM
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
2005 Apr 13 12:33 PM
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
2005 Apr 13 12:33 PM
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
2005 Apr 13 12:56 PM
2005 Apr 13 1:09 PM
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
2005 Apr 13 1:28 PM
Thx getting there....
Error: "You cannot creat an instance of the class " CL_BCS" outisde the class.
Any Pointers?
//Martin
2005 Apr 13 1:36 PM
check out these programs.
BCS_EXAMPLE_1
BCS_EXAMPLE_2
BCS_EXAMPLE_5
Regards
Raja
2005 Apr 13 2:13 PM
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.
2005 Apr 13 2:43 PM
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
2005 Apr 13 4:02 PM
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.
2005 Apr 13 7:04 PM
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.