Hi Friends,
I am currently using FM SO_DOCUMENT_SEND_API1 to send out emails with xls attachment. But I am facing a strange issue while sending out Well Numbers of char10.
These Well numbers are appended to the CONTENTS_BIN Table.
The issue is that a particular Well Number( 1234567890 ) is not coming in the xls attachment with the mail while other Well Numbers are coming in the xls attachment.
WELL NUMBERS coming in xls attachment send out with mail
0630000000
0630000001
0630000002
0630000003
0630000004
0630000005
0630000006
0630000007
0630000008
0630000009
0630000010
0630000011
0630000012
0630000013
0630000014
0630000015
0630000016
0630000017
0630000018
WELL NUMBERS NOT coming in xls attachment send out with mail
1234567890
While all the Well Numbers are coming in the CONTENTS_BIN but only after mail is sent out calling the Function Module SO_DOCUMENT_SEND_API1 the particular Well Number 1234567890 is not appearing in the Excel Attachment while all the others as mentioned above are appearing in the xls attachment.
I am attaching the code and also the value of the Internal Table of CONTENTS_BIN in debug mode.
As you can see in the attachment the value highlighted in RED is not coming in the xls attachment while the other values are coming inspite of the value( 1234567890 ) coming in the CONTENTS_BIN Table.
CODE
gd_sender_type = 'INT'.
* Creating the xls attachment
* Heading
CONCATENATE 'YWELL-ZWELLNO' c_tab 'YWELL-REGIO' c_tab 'YWELL-LAND1' c_tab 'YWELL-ZLATI' c_tab 'YWELL-ZLONG' c_tab
'YWELL-ZAPINO' c_tab INTO objbin_final.
APPEND objbin_final.
CLEAR objbin_final.
* Records
LOOP AT it_xls INTO wa_xls.
CONCATENATE wa_xls-zwellno c_tab wa_xls-regio c_tab wa_xls-land1 c_tab wa_xls-zlati c_tab wa_xls-zlong c_tab
wa_xls-zapino c_tab INTO objbin_final.
CONCATENATE c_ret objbin_final INTO objbin_final.
APPEND objbin_final.
CLEAR objbin_final.
ENDLOOP .
* Mail Subject
CONCATENATE c_maildesc '(' sy-sysid ')' INTO docdata-obj_descr.
docdata-obj_name = 'Mail_Excel_File'.
* Mail Addressed To
CONCATENATE objtxt cl_abap_char_utilities=>newline INTO objtxt.
objtxt = 'Dear All,'.
APPEND objtxt.
CLEAR: objtxt.
* Mail Body
CONCATENATE objtxt cl_abap_char_utilities=>newline INTO objtxt.
objtxt = c_mailbody1.
CLEAR: objtxt.
CONCATENATE objtxt cl_abap_char_utilities=>newline INTO objtxt.
objtxt = 'Kindly update the Well Sites Data in SAP with required etails to clear the error.' .
APPEND objtxt.
CLEAR: objtxt.
* Mail Closing
CONCATENATE objtxt cl_abap_char_utilities=>newline INTO objtxt.
objtxt = 'Regards' .
APPEND objtxt.
CLEAR: objtxt.
CONCATENATE objtxt cl_abap_char_utilities=>newline INTO objtxt.
CONCATENATE 'System Admin' '-' sy-sysid INTO objtxt.
APPEND objtxt.
CLEAR: objtxt.
CONCATENATE objtxt cl_abap_char_utilities=>newline INTO objtxt.
objtxt = 'NOTE: This is a system generated Email' .
APPEND objtxt.
CLEAR: objtxt.
* Prepare Packing List For Sending Email.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* Creation of the entry for the compressed document
CLEAR objpack.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type ='RAW'.
APPEND objpack.
CLEAR objpack.
* Attachment
n = 1.
CLEAR tab_lines.
DESCRIBE TABLE it_error LINES tab_lines.
objpack-doc_size = tab_lines * 255.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = n.
objpack-body_num = tab_lines.
objpack-doc_type = 'XLS'.
docdata-obj_name = 'Excel_File_Attachment1'.
* objpack-obj_descr = 'Failed Records'.
CONCATENATE 'ZWELL_TO_OTM_' sy-datum sy-uzeit INTO objpack-obj_descr.
APPEND objpack .
* Creating Reciepients
LOOP AT it_tvarvc INTO wa_tvarvc.
reclist-receiver = wa_tvarvc-low.
reclist-rec_type = 'U'.
reclist-express = 'X'.
APPEND reclist.
CLEAR reclist.
reclist-receiver = wa_tvarvc-high.
reclist-rec_type = 'U'.
reclist-express = 'X'.
APPEND reclist.
CLEAR reclist.
ENDLOOP.
*Send the e-mail
* CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
* EXPORTING
* document_data = docdata
* put_in_outbox = 'X'
* commit_work = 'X'
* TABLES
* packing_list = objpack
* contents_bin = objbin_final
* contents_txt = objtxt
* 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.
* COMMIT WORK.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = docdata
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
tables
packing_list = objpack
CONTENTS_BIN = objbin_final
CONTENTS_TXT = objtxt
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.
ENDIF.
v_dev = sy-sysid.
IF sy-sysid = v_dev.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = ''
AND RETURN.
ENDIF.
IF sy-subrc = 0.
WRITE: / 'Email succesfully delivered'.
ELSE.
WRITE: / 'Failure in delivering Email'.
ENDIF.