# SO_NEW_DOCUMENT_ATT_SEND_API1 — SAPoffice: Send New Document with Attachments

> Creates a SAPoffice document with optional attachments and sends it to internal users, e-mail addresses or other recipient types through SAPconnect. Older custom reports use it to e-mail lists, spool output or files as attachments. Describe body and attachments in PACKING_LIST, set COMMIT_WORK or commit yourself, and check the send status in SOST; for new developments the BCS classes (CL_BCS) are recommended.

- 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-new-document-att-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 | - |
| COMMIT_WORK | SONV-FLAG | Execute COMMIT WORK at the end | - |

## 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 |

## 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 | - |
| OBJECT_PARA | SOPARAI1 | SET/GET parameters for processing | - |
| OBJECT_PARB | SOPARBI1 | Fields and values for processing | - |
| RECEIVERS | SOMLRECI1 | Recipients | Yes |

## 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_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    document_data = lv_document_data
  IMPORTING
    sent_to_all = lv_sent_to_all
    new_object_id = lv_new_object_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
    object_para = lt_object_para
    object_parb = lt_object_parb
    receivers = lt_receivers
  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.
```


