Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Error when emailing XML document

Hi there

I am trying to email an XML document to an external vendor by using the CL_DOCUMENT_BCS class. The email is sent successfully and I receive it in the relevant mailbox. To make it an XML document, I move 'XML' to the I_TYPE parameter of the class. This sends it perfectly as an XML document.

The problem occurs when I receive the email and open the attachment. When I open the attachment, I get the error "Whitespace is not allowed at this location". To rectify this problem, I open the XML attachment in notepad, concatenate these lines by deleting the return characters and I save the file and open it again. It then displays perfectly.

When I send the email as a normal text document and I change the extension manually to 'XML', the XML can be viewed perfectly.

Can anyone assist in rectifying this so that there is no manual intervention?

Kind Regards

Gustav Coleske

Tags:
Former Member
replied

i tried and its working, here is the code sample.

DATA: binary_content     TYPE solix_tab.
  DATA: xl_content TYPE xstring ,
output TYPE string .
  DATA: flights TYPE flighttab .


CALL TRANSFORMATION (`ID`)
              SOURCE flights   = flights[]
              RESULT XML output.


    CLEAR: xl_content .
*      xl_content = output .

    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
      EXPORTING
        text           = output
*   MIMETYPE       = ' '
*   ENCODING       =
     IMPORTING
       buffer         = xl_content
     EXCEPTIONS
       failed         = 1
       OTHERS         = 2
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    REFRESH binary_content .

    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer     = xl_content
      TABLES
        binary_tab = binary_content.

now add the attachment.

 CALL METHOD document->add_attachment
          EXPORTING
            i_attachment_type    = 'XML'
            i_attachment_subject = atta_sub
            i_att_content_hex    = binary_content.

Regards

Raja

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question