
Appending Attachments at the Sender
Use
An attachment comprises any data (for example, text or graphics) that can be appended to a message. In principle, you can append an unlimited number of attachments to an output message of an outbound or inbound interface (in the synchronous case) using the
controller object.Procedure
data: l_attachment type ref to if_ai_attachment,
lt_attach type prx_attach,
l_name type string,
l_xstring type xstring,
l_type type string.
class cl_ai_factory definition load.
data: l_controller type ref to if_ai_posting_controller.
l_attachment =
cl_ai_factory=>create_attachment_from_binary(
p_data = l_xstring
p_type = l_type
p_name = l_name ).
append l_attachment to lt_attach.

The factory class also provides the method
create_attachment_from_text () for pure text attachments; you can append the attachment to this method as STRING.l_controller = cl_ai_factory=>create_controller( ).
l_controller->set_attachments( lt_attach ).

In the synchronous case, you can also set attachments at the receiver. Once you have fetched input message attachments, you can set attachments for the output message, using set_attachments (). Since only one controller object exists for the inbound interface, you overwrite the attachments of the input message, however.