SAP Knowledge Base Article - Public

3367875 - Merging issue with billing document attachments - S/4HANA Cloud


When trying to send a billing document to a customer with attachments, the following error message pops up:

"Error(s) occurred when merging the document. The return code is 107."



Reproducing the Issue

  1. Go to Application 'Manage Billing Documents'
  2. Open the Billing Document
  3. Section 'Output Items' -> Select item ID -> 'Display Document' Action ->
  4. "Error(s) occurred when merging the document. The return code is 107."

    Technical Data:
    Message type__________ E (Error)
    Message class_________ APOC_OR_MESSAGES (Messages for Output Control)
    Message number________ 397
    Message variable 1____ 107


The reported error message usually occurs when attachment(s) originally brings security permissions, therefore system cannot merge those documents.

Restrictions, document versions, or tagging of the documents also could be the reason why the documents can not be merged.


  1. It’s currently not possible for customers to change the settings for PDF protection in S/4HANA Public Cloud system. In addition, protected PDFs cannot be merged, it’s the intention of the protection that the PDF cannot be modified. In order to proceed with the merging, please choose PDFs with no additional security settings. Originally these attachment blocks data copying at permission level.

  2. Also, the issue can happen if any of the uploaded documents are damaged. In this case, please try to upload the required undamaged attachments again.

  3. Untagging a PDF also could be the solution. Tagged PDFs are not read by the system as untagged versions. It is hard to copy the tagging metadata, therefore they are not always available for merging. 

See Also

Setting Up Output Management (1LQ) -> 6.1.3  Merging of Documents

SAP Help - Controlling the Output Relevance and Merging of Attachments

SAP Help - Adding Attachments


attachment, merging, error, APOC_OR_MESSAGES, number 397, variable 107, Messages for Output Control, merge, restriction, untag, tagging, data block, permission, manage billing documents, output item , KBA , SD-BIL-GF-OC-2CL , Output Control Billing (Public Cloud) , CA-GTF-OC , SAP S/4HANA output management , Problem


SAP S/4HANA Cloud 2302