03-19-2009 12:04 PM
Hi Experts,
we have an issue with one of our programs regarding the carriage return that is used when creating a csv file. This issue has only came about because of the recent upgrade to ECC6.
The main change to the program was the redefinition of the line feed variable.
Existing statement was --> DATA: v_lf TYPE x VALUE '0D'.
This was then replaced with
New statement --> DATA: v_lf type c VALUE cl_abap_char_utilities=>cr_lf.
Since this change has been implemented, the csv file that is created and sent on as an attachment via the function SO_NEW_DOCUMENT_ATT_SEND_API1 is now not displayed correctly.
When looking at the attachment in trn SOST, a message is also displayed saying the file is not in a recognizable format when selecting the file to view.
The hex value for cl_abap_char_utilities=>cr_lf is 000D000A and this seems to be causing the issue.
I've also tried using Function FI_DME_CHARATERS as I only really want to use the CR. However, the hex value for this is 000D and not 0D.
Is there any way of converting this to have a hex value of 0D?
Thanks in advance,
Chris
03-19-2009 12:17 PM
Hi Avinash,
the CONTENTS_TXT is okay. The issue is with the data in CONTENTS_BIN, specifically with the end of line charater.
Cheers
Chris
03-19-2009 12:09 PM
HI,
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.
* APPEND object_header.
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = lt_objbin
objcont_new = lt_objbin.
LOOP AT lt_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.
Use this FM and convert raw data to hexa and pass to the it to CONTENTS_HEX of the FM instead of
CONTENTS_TXT.
This might work.
Edited by: Avinash Kodarapu on Mar 19, 2009 5:41 PM
03-19-2009 12:17 PM
Hi Avinash,
the CONTENTS_TXT is okay. The issue is with the data in CONTENTS_BIN, specifically with the end of line charater.
Cheers
Chris
03-19-2009 12:36 PM
HI,
Sorry it is not the CONTENTS_TXT it is CONTENTS_BIN. Instead of CONTENTS_BIN you need to pass to CONTENTS_HEX
Check my Code..i have used the CONTENTS_HEX instead of CONTENTS_BIN
DATA: l_tab_lines TYPE i,
l_string TYPE char300,
l_line TYPE string.
CONSTANTS : l_c_255(255) TYPE c VALUE '255',
l_c_txt(3) TYPE c VALUE 'TXT'.
DATA: lt_reclist TYPE STANDARD TABLE OF somlreci1, "Recipients
lt_objpack TYPE STANDARD TABLE OF sopcklsti1,
lt_objhead TYPE STANDARD TABLE OF solisti1,
lt_objtxt TYPE STANDARD TABLE OF solisti1, "Body of EMail
lt_objbin TYPE STANDARD TABLE OF solisti1."Attachment of EMail
DATA: l_doc_chng TYPE sodocchgi1, "attributes of document to send
l_reclist LIKE LINE OF lt_reclist,
l_objpack LIKE LINE OF lt_objpack,
l_obj LIKE LINE OF lt_objhead.
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.
* Completing the recipient list
l_reclist-receiver = p_emailid.
l_reclist-express = 'X'.
l_reclist-rec_type = 'U'.
APPEND l_reclist TO lt_reclist.
CLEAR l_reclist.
* Body of Email Message
APPEND l_obj TO lt_objtxt. CLEAR l_obj. " Blank line
l_obj-line = '<html>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<body>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<p><code>Hello,</p></code>'(t04).
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = cl_abap_char_utilities=>newline.
APPEND l_obj TO lt_objtxt. CLEAR l_obj. " Blank line
CONCATENATE
'<p><code>'(f01)
'Please click the link to access the Confirmation Form.'(t01)
'Kindly complete the same and return it to the HR contact 15 days' &
' prior to the date of confirmation of the employee.'(t02)
'</p></code>'(f02) INTO l_obj-line SEPARATED BY space.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = cl_abap_char_utilities=>newline.
APPEND l_obj TO lt_objtxt. CLEAR l_obj. " Blank line
CONCATENATE '<a href="' text-l01 text-l02 '">'
INTO l_obj-line.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
CONCATENATE '<p><code>'(f01)
'Link to Confirmation Forms'(034)
'</p></code>'(f02)
'</a>'
INTO l_obj-line.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = cl_abap_char_utilities=>newline.
APPEND l_obj TO lt_objtxt. CLEAR l_obj. " Blank line
l_obj-line = '<p><code>The details of the employees ' &
'are as follows:</p></code>'(017).
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = cl_abap_char_utilities=>newline.
APPEND l_obj TO lt_objtxt. CLEAR l_obj. " Blank line
* Table headings in the Mail Body
l_obj-line = '<table border="1">'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<tr>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<th><p><code>Name</p></code></th>'(030).
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<th><p><code>Department</p></code></th>'(031).
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<th><p><code>DOJ</p></code></th>'(032).
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '<th><p><code>Confirmation Date</p></code></th>'(033).
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '</tr>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
** Body of Email Message
* Email Attachment
* Append headings
CONCATENATE 'Employee No.'(002)
'Employee Group'(016)
'Employee Name'(001)
'Designation'(003)
'Joining Date'(004)
'Department'(005)
'Branch/Location'(006)
'Unit'(007)
'Confirmation Due'(008)
'Form sent on'(009)
'Form Return by'(010)
'Employee Group'(016)
'Qualification'(012)
'Trainee Category'(013)
INTO l_string
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
APPEND l_string TO lt_objbin.
CLEAR l_string.
APPEND INITIAL LINE TO lt_objbin.
LOOP AT p_emp_details INTO i_emp_details_line.
CONCATENATE i_emp_details_line-pnalt
i_emp_details_line-egroup
i_emp_details_line-ename
i_emp_details_line-stext
i_emp_details_line-srvdt
i_emp_details_line-ltext
i_emp_details_line-pbtxt
i_emp_details_line-btrtx
i_emp_details_line-mndat
i_emp_details_line-fsdate
i_emp_details_line-frdate
i_emp_details_line-egroup
i_emp_details_line-ptext
i_emp_details_line-ftext
INTO l_string
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
APPEND l_string TO lt_objbin.
CLEAR l_string.
l_obj-line = '<tr>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
CONCATENATE '<td>' '<p><code>'(f01)
i_emp_details_line-ename '</p></code>'(f02) '</td>'
INTO l_string.
APPEND l_string TO lt_objtxt. CLEAR l_string.
CONCATENATE '<td>' '<p><code>'(f01)
i_emp_details_line-ltext '</p></code>'(f02) '</td>'
INTO l_string.
APPEND l_string TO lt_objtxt. CLEAR l_string.
CONCATENATE '<td>' '<p><code>'(f01)
i_emp_details_line-srvdt '</p></code>'(f02) '</td>'
INTO l_string.
APPEND l_string TO lt_objtxt. CLEAR l_string.
CONCATENATE '<td>' '<p><code>'(f01)
i_emp_details_line-mndat '</p></code>'(f02) '</td>'
INTO l_string.
APPEND l_string TO lt_objtxt. CLEAR l_string.
l_obj-line = '</tr>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
ENDLOOP.
l_obj-line = ' </table>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '</body>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
l_obj-line = '</html>'.
APPEND l_obj TO lt_objtxt. CLEAR l_obj.
IF r_cprob EQ 'X'.
l_string = 'Completion of probation List'(018).
ELSE.
l_string = 'Completion of extension of probation List'(035).
ENDIF.
APPEND l_string TO lt_objhead.
* APPEND object_header.
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = lt_objbin
objcont_new = lt_objbin.
LOOP AT lt_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.
* File name for attachment
CONCATENATE 'Completion of probation List'(018)
sy-datum '.XLS' INTO l_obj SEPARATED BY space.
APPEND l_obj TO lt_objhead.
* Email Body Details
CLEAR l_tab_lines.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 +
STRLEN( l_string ). "size of doc in bytes
l_doc_chng-obj_name = sy-repid.
l_doc_chng-obj_langu = sy-langu.
l_doc_chng-obj_descr = l_string.
l_doc_chng-sensitivty = 'P'. " Send mail as a confidential
l_objpack-head_start = 1.
l_objpack-head_num = 1.
l_objpack-body_start = 1.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_type = 'HTML'. "l_c_txt.
APPEND l_objpack TO lt_objpack.
CLEAR l_objpack.
* Email Attachment Details
CLEAR l_tab_lines.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
* Creation of the entry for the compressed attachment
l_objpack-transf_bin = 'X'.
l_objpack-head_start = 1.
l_objpack-head_num = 1.
l_objpack-body_start = 1.
l_objpack-doc_type = 'XLS'.
l_objpack-obj_name = l_obj.
l_objpack-obj_descr = l_obj.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_size = l_tab_lines * l_c_255.
APPEND l_objpack TO lt_objpack.
CLEAR l_objpack.
* Send the document
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = l_doc_chng
put_in_outbox = ' '
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
* contents_bin = lt_objbin
contents_txt = lt_objtxt
contents_hex = lt_contents_hex
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.
03-19-2009 12:46 PM
TABLES
packing_list = t_packing_list
check what format are supported in ECC6.0 RAW, XLS etc... try changing them in SO_NEW_DOCUMENT_ATT_SEND_API1