# SO_DOCUMENT_SEND_API1 — SAPoffice: Send Document with Attachments

> Sends a new SAPoffice document with attachments like SO_NEW_DOCUMENT_ATT_SEND_API1, but additionally lets you set a sender address and request encryption or signature. It is used in custom programs that must send e-mails from a specific address, for example a shared mailbox. Fill PACKING_LIST, RECEIVERS and the content tables, set COMMIT_WORK, and check the result in SOST; for new code prefer CL_BCS.

- Modules: CA
- Type: Function module
- Function group: SOI1
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/so-document-send-api1/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| DOCUMENT_DATA | SODOCCHGI1 | Attributes of the new document | Yes |
| PUT_IN_OUTBOX | SONV-FLAG | Put document in outbox after sending | - |
| SENDER_ADDRESS | SOEXTRECI1-RECEIVER | Sender address | - |
| SENDER_ADDRESS_TYPE | SOEXTRECI1-ADR_TYP | Sender address type | - |
| COMMIT_WORK | SONV-FLAG | Execute COMMIT WORK at the end | - |
| IP_ENCRYPT | BCSD_ENCR | Encryption required | - |
| IP_SIGN | BCSD_SIGN | Signature required | - |
| IV_VSI_PROFILE | VSCAN_PROFILE | Virus scan profile | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| SENT_TO_ALL | SONV-FLAG | Document sent to all recipients |
| NEW_OBJECT_ID | SOFOLENTI1-OBJECT_ID | ID of the created object |
| SENDER_ID | SOUDK | Sender ID |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| PACKING_LIST | SOPCKLSTI1 | Structure of body and attachments | Yes |
| OBJECT_HEADER | SOLISTI1 | Document header data | - |
| CONTENTS_BIN | SOLISTI1 | Binary contents (obsolete, use CONTENTS_HEX) | - |
| CONTENTS_TXT | SOLISTI1 | Text contents | - |
| CONTENTS_HEX | SOLIX | Binary contents of document and attachments | - |
| RECEIVERS | SOMLRECI1 | Recipients | Yes |
| ET_VSI_ERROR | BAPIRET2 | Virus scan messages | - |

## Exceptions

- TOO_MANY_RECEIVERS: Too many recipients
- DOCUMENT_NOT_SENT: Document was not sent
- DOCUMENT_TYPE_NOT_EXIST: Document or attachment type does not exist
- OPERATION_NO_AUTHORIZATION: No authorization to send
- PARAMETER_ERROR: Invalid parameter combination
- X_ERROR: Internal error
- ENQUEUE_ERROR: Locks could not be set

## Call template (ABAP)

```abap
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
  EXPORTING
    document_data = lv_document_data
  IMPORTING
    sent_to_all = lv_sent_to_all
    new_object_id = lv_new_object_id
    sender_id = lv_sender_id
  TABLES
    packing_list = lt_packing_list
    object_header = lt_object_header
    contents_bin = lt_contents_bin
    contents_txt = lt_contents_txt
    contents_hex = lt_contents_hex
    receivers = lt_receivers
    et_vsi_error = lt_et_vsi_error
  EXCEPTIONS
    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.
```


