1. WebAS as of rel. 6.20
2. BSP/ICF/ICM is configured.
3. Mail / Fax sub system connected to the R/3 system.
4. Basic ABAP / BSP skills.
The application is able to send a textual document per mail or fax. The subject, body, sender, recipient, send art are variable over a BSP UI. It is not a goal of this weblog to show all the possibilities (what and how) a document can be sent, the goal is to have a working program wich can be easily copied and modified upon own request. Some more feature /* e.g How to send attachments… */ can be found in the SAP note: #190669. The idea is: This feature is often used to send notification information, which is usually a textual document.
Create a BSP application from Tr. SE80. We will require a page with flow logic. Create this.
The page attributes:
Each UI input enabled field, has a page attribute, to hand over the data, and an extra attribute for the status. /* To see weather the document has been sent */
if me->typeSelector is initial.
me->typeSelector = ‘INT’.
In this method we realize the effective coding wich sends the document with the help of the Function Module: ‘SO_DOCUMENT_SEND_API1’. This part of the code will be examined in the last part of the blog, here you will find the complete coding, so you can copy paste it easily.
*for the htmlb event handling
evt type ref to if_htmlb_data,
bodyTable type table of char255, “body
receiver type somlreci1, “reciver
receivers type TABLE OF somlreci1, “table containing the reciver
senderAddr like sender, “sender
document_data type SODOCCHGI1, “header informations
packing_list type table of SOPCKLSTI1,”document content description
sent_to_all type boolean,
len type int4,
base type int4,
line type char255.
evt = cl_htmlb_manager=>get_event_ex( request ).
“check for the send button click when ‘SendItem’. “send item is pressed
*first we need to split the string into an internal table
*with line length of 255
len = strlen( body ) / 256.
if len gt 0.
do len times.
base = ( sy-index – 1 ) * 256.
if sy-index = len.
line = body+base.
line = body+base(256).
APPEND line to bodyTable.
ELSE. “one line length.
append body to bodyTable.
“The text is now in the table bodytable.
if typeSelector eq ‘INT’. “MAIL RECIPIENT
receiver-receiver = recipient.
receiver-rec_type = ‘U’.
APPEND receiver to receivers.
move sender to senderAddr.
Add the same for FAX, if required.
“Fill the document data /subject/
document_data-obj_descr = subject.
“Fill packing list
data: p_item type SOPCKLSTI1.
describe table bodyTable lines len. ” the length of the document
p_item-doc_type = ‘RAW’. ” text document
p_item-transf_bin = ‘ ‘. ” non binary
p_item-obj_descr = subject.
p_item-body_start = 1. ” first (and only) object
p_item-body_num = len. ” set the length.
APPEND p_item to packing_list.
**send the document call function
document_data = document_data
mput_in_outbox = ‘ ‘
commit_work = ‘X’
sender_address = senderAddr
sender_address_type = typeSelector
sent_to_all = sent_to_all
packing_list = packing_list
contents_txt = bodyTable
*contents_hex = contents_hex
receivers = receivers
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
case sy-subrc. “Error handling
statusT = ‘Document is sent.’.
statusT = ‘Error during the operation’.
Usage of the application:
– the subject is a one line text.
– the body is a multiline text, the CRLF characters are kept, so this can be a preformatted text.
– the sender and the recipient are:
-in case of mail: standard internet Mail Addresses, like ‘firstname.lastname@example.org‘
-in case of fax: Telephone number in the following format: 2 chr country code+faxnumber. E.g: ‘DE6227757575’ for SAP Germany.
The tricky things we must care of:
Now you have a working program wich sends mail / fax docuemts, it is upon you how you enhance this. Good luck 😉