HI ,
I am facing problem in the attachment of XLS file with the Smartform data through mail.
We are receiving the mail but the XLS file is not opening properly and the data is not
in proper format.
We are using ECC6 system.
This thing works in SAP 4.6 C
Can anyone please help me regarding this.
We are using function module SX_OBJECT_CONVERT_OTF_RAW' and 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_RAW'
EXPORTING
format_src = 'OTF'
format_dst = 'RAW'
devtype = 'ASCIIPRI'
len_in = w_len_in
IMPORTING
LEN_OUT =
TABLES
content_in = t_spool
content_out = objbin
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_chng
PUT_IN_OUTBOX = ' '
sender_address = p$_send
sender_address = p$_sendt
sender_address_type = 'INT'
*{ INSERT RE2K900945 2
COMMIT_WORK = 'X'
*} INSERT
IMPORTING
sent_to_all = sent_to_all
NEW_OBJECT_ID =
SENDER_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = 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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE: / 'Excel file was send'(m05).
ENDIF.
Also somewhere I have read that contents_bin has become obsolete and been replaced by contents_hex like :
Filled the OBJPACK like this:
clear objpack-transf_bin.
The document needs no header (head_num = 0)
objpack-head_start = 1.
objpack-head_num = 0.
but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
of type RAW
objpack-doc_type = 'RAW'.
append objpack.
clear tab_lines.
create the attachment (the list itself)
describe table objbin lines tab_lines.
objpack-transf_bin = 'X'.
The document needs no header (head_num = 0)
objpack-head_start = 1.
objpack-head_num = 0.
but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
of type RAW
*{ REPLACE RE2K901725 2
*\ objpack-doc_type = 'ZXL'.
Begin of Changes - 46C To ECC6 - IN9GUPTA
objpack-doc_type = 'XLS'.
End of Changes - 46C To ECC6 - IN9GUPTA
*} REPLACE
objpack-obj_name = 'Payment data'(019).
objpack-obj_descr = 'Payment data'(019).
objpack-doc_size = tab_lines * 255.
append objpack.
*
DATA :
l_hex LIKE solix,
lt_contents_hex LIKE STANDARD TABLE OF solix ,
conv TYPE REF TO cl_abap_conv_out_ce,
l_buffer TYPE xstring,
l_hexa(510) TYPE x,
l_line TYPE string.
LOOP AT objbin INTO l_line.
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
CALL METHOD conv->write( data = l_line ).
l_buffer = conv->get_buffer( ).
MOVE l_buffer TO l_hexa.
MOVE l_hexa TO l_hex-line.
APPEND l_hex TO lt_contents_hex.
ENDLOOP.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = doc_chng
put_in_outbox = 'X'
*{ INSERT RE2K901149
Begin of Changes - 46C To ECC6 - IN9PAVITHRAM
COMMIT_WORK = 'X'
End of Changes - 46C To ECC6 - IN9PAVITHRAM
*} INSERT
importing
sent_to_all = sent_to_all
tables
packing_list = objpack
object_header = objhead
*{ REPLACE RE2K901725
*\ contents_bin = objbin
Begin of Changes - 46C To ECC6 - IN9GUPTA
contents_hex = lt_contents_hex
End of Changes - 46C To ECC6 - IN9GUPTA
*} REPLACE
contents_txt = objtxt
receivers = reclist
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
Can anyone help me in this regarding and guide me where I am going wrong.....
I am not getting the proper data in XLS file .
Regards,
Amit Gupta