Skip to Content
0
Former Member
Dec 13, 2009 at 02:16 PM

XML alignment problem when opening with notepad - XML generated from SAP

72 Views

Hi all,

I am sending a mail with attachment as XML format by using the function module SO_NEW_DOCUMENT_ATT_SEND_API1.

I am getting the xml file in mail and it was properly aligned when i open it. But when i open it with notepad the alignments are changing.

Below is the code for sending a mail. The content of the XML file populaed in int. table lt_attachment.

lt_attachment[] = pt_attachment[].

LOOP AT lt_attachment INTO ls_attachment.

ls_objtxt-line = ls_attachment-container.

APPEND ls_objtxt TO lt_objtxt.

CLEAR : ls_attachment, ls_objtxt.

ENDLOOP.

  • Creating the document to be sent

ls_mailsubject-obj_name = 'MAILATTCH'.

ls_mailsubject-obj_langu = sy-langu.

ls_mailsubject-obj_descr = 'You have got mail'.

ls_mailsubject-sensitivty = 'F'.

lv_cnt = LINES( lt_objtxt ).

ls_mailsubject-doc_size = ( lv_cnt - 1 ) * 255 + STRLEN( ls_objtxt ).

DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.

  • Header of the email

ls_objpack-transf_bin = space.

ls_objpack-head_start = 1.

ls_objpack-head_num = 0.

ls_objpack-body_start = 1.

ls_objpack-body_num = lv_tab_lines.

ls_objpack-doc_type = lc_raw.

APPEND ls_objpack TO lt_objpack.

CLEAR ls_objpack.

ls_objpack-transf_bin = lc_x.

ls_objpack-head_start = 1.

ls_objpack-head_num = 1.

ls_objpack-body_start = 1.

ls_objpack-body_num = lv_tab_lines.

ls_objpack-doc_type = 'XML'.

ls_objpack-obj_name = 'data'.

ls_objpack-obj_descr = 'data'.

ls_objpack-doc_size = ls_objpack-body_num * 255.

APPEND ls_objpack TO lt_objpack.

CLEAR ls_objpack.

  • Add Recipients

ls_reclist-rec_type = 'U'.

ls_reclist-com_type = 'INT'.

ls_reclist-receiver = pv_mail.

APPEND ls_reclist TO lt_reclist.

  • Mail Contents

ls_mailtxt-line = 'Please find attached your XML doc.'.

APPEND ls_mailtxt TO lt_mailtxt.

CLEAR ls_mailtxt.

ls_mailtxt-line = lc_regards.

APPEND ls_mailtxt TO lt_mailtxt.

CLEAR ls_mailtxt.

ls_mailtxt-line = lc_dewa.

APPEND ls_mailtxt TO lt_mailtxt.

CLEAR ls_mailtxt.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = ls_mailsubject

  • put_in_outbox = lc_x

  • commit_work = lc_x

TABLES

packing_list = lt_objpack

contents_bin = lt_objtxt

contents_txt = lt_mailtxt

receivers = lt_reclist

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.

IF sy-subrc EQ 0.

COMMIT WORK.

SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.

pv_return = 'Success'.

ELSE.

pv_return = 'Failed'.

ENDIF.

CLEAR: ls_objtxt,ls_reclist, ls_objpack ,ls_doc_chng.

REFRESH: lt_objtxt,lt_reclist,lt_objpack.

Could any one help me on this.

Thanks & Regards,

Vineel.