CL_BCS - Business Communication Service
TXBHW - Original Tax Base Amount in Local Currency SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3upThis documentation is copyright by SAP AG.
Functionality
Class CL_BCS provides the application with an interface to send documents from the SAP system as e-mail, fax, or pager/SMS messages using Business Communication Services (BCS).
To send a document, a send request is needed to which various objects (main documents, attachments, receiver) are assigned.
The following functions are supported by the CL_BCS class.
- Sending documents with attachments
- Sending to internal and external recipients, including organizational units, address objects and other objects that support the interface IF_RECIPIENT_BCS
- Sending in all communication methods supported by the SAP System (fax, Internet, remote mail, SMS/paging, printing)
- Setting different send attributes
- Priority
- Immediate send (Immediately flag)
- Document title
- Status handling
- Express, copy, blind copy
- Expiry date
- Relating an application object to documents sent
- Sending under another name
- Storing MIME documents
- Activating signature and encryption mode
- Determining responsibility for the send request
Relationships
Example
The following process flow shows an example of how BCS can be called in several steps with example program lines.
1. Create a send request.
To do this, create an instance of the class CL_BCS with the method:CREATE_PERSISTENT
DATA send_request TYPE REF TO cl_bcs.
* create persistent send request
send_request = cl_bcs=>create_persistent( ).
2. Create the object that is to be sent as a BCS document.
To do this, create an instance of a class that implements the interface IF_DOCUMENT_BCS, also passingthe object to the send request. With method CREATE_DOCUMENT, an instance of the class CL_DOCUMENT_BCS can be created, as in the following example for the document type RAW:
DATA text TYPE bcsy_text.
DATA document TYPE REF TO cl_document_bcs.
* create document from internal table with text
APPEND 'Hello World' TO text.
document = cl_document_bcs=>create_document( i_type = 'RAW'
i_text = text
i_subject = 'Test created by BCS_EXAMPLE' ).
You can also add attachments with the method ADD_ATTACHMENT of the class CL_DOCUMENT_BCS.
3. Pass the object to the send request.
To do this, call the method SET_DOCUMENT of the class CL_BCS.
* add document to send request
send_request->set_document( document ).
4. It can be set explicitly if the current user is not be used as the sender.
To do this, create an instance of a class that implements the interface IF_SENDER_BCS, passing the sender(such as SAP user, organizational unit or even business object). In the example, the SAP user User is created as sender.
DATA sender TYPE REF TO if_sender_bcs.
* create sender object
sender = cl_sapuser_bcs=>create( 'USER' ).
5. If the current user is not to be used as sender, you must pass the sender previously created to the send request.
To do this, call the method SET_SENDER of the class CL_BCS.
* set sender at send request
send_request->set_sender( sender ).
6. Create a recipient.
To do this, create an instance of a class that implements the interface IF_ RECIPIENT_BCS, passing therecipient. You have to do this for every recipient. In this example, an e-mail address is created asrecipient by an instance created using the method CREATE_INTERNET_ADDRESS of the class CL_CAM_ADDRESS_BCS being passed.
DATA recipient TYPE REF TO if_recipient_bcs.
* create recipient - please replace the e-mail address!
recipient = cl_cam_address_bcs=>create_internet_address('example.user@company.com' ).
7. Pass the recipients with the relevant send attributes (express, copy, blind copy, no forwarding) to the send request.
To do this, call the method ADD_RECIPIENTof the class CL_BCS. In the example, the express indicator is set for the recipient.
* add recipient with its respective attributes to send request
send_request->add_recipient( i_recipient = recipient
i_express = 'X' ).
8. Send the object.
Call methodSEND for the send request
of class CL_BCS.
DATA send_to_all type boolean.
* send document
send_to_all = send_request->send( i_with_error_screen = 'X' ).
Alternatively, you can call the send screen if the users are to be able to specify recipients and send attributes. Sending is then initiated by the user.
To do this, call the method EDIT
of the class CL_BCS for the send request, with which you can call the send screen as a dialog box or a full screen.
* send document
send_request->edit( i_hide_note = 'X'
i_starting_at_x = 12
i_starting_at_y = 5
i_ending_at_x = 97
i_ending_at_y = 22 ).
9. You must set a COMMIT WORK explicitly at an appropriate point.
The application must set the COMMIT WORK itself. Otherwise, the Persistence Services of Object Servicesare not started and essential send data is missing, which can lead to the termination of the send operation.A further identifier for this so that no, or an insufficient, COMMIT WORK is set is an entry in the SOST with status: 'No entry in the queue'.
* set expicit commit work to persist objects of the send process
COMMIT WORK.
Excepted are those applications that use the Transaction Service of Object Services and call a send interface within an OO transaction. Applications that call the send interface during update are also excepted.
Example Programs:
Example reports BCS_EXAMPLE_* that map the different scenarios are provided in every system.
Notes
The related SAP system used should be configured for sending documents using SMTP. For more information about this, see SAP Note 455140.
Further information
BAL Application Log Documentation PERFORM Short Reference
This documentation is copyright by SAP AG.
Length: 9939 Date: 20120526 Time: 090258 triton ( 197 ms )






