Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SBCOMS_SR_FROM_DOCUMENT_CREATE shows exception 'Error Document Insert' 'Save Document DB'

0 Likes
2,515

Iam trying to send smart form pdf to email as an attachment . The smart form document is converted to pdf by this code.

======== Code to call smart form and get Job Output Data =============

CALL FUNCTION lv_fm_name """"" Calling Smartform function module
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = l_user_settings
l_ponumber = lv_po
l_adrnr = l_adrnr
gs_frgct1 = l_frgct1
gs_frgct2 = l_frgct1
IMPORTING
job_output_info = ls_job_info
TABLES
gt_lines = gt_lines
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.

MOVE ls_job_info-otfdata TO lt_tsfotf.

====== Code to Convert the OTF to PDF ======================

CALL FUNCTION 'CONVERT_OTF' """""" Converting OFT data to xstring
EXPORTING
format = 'PDF'
* max_linewidth = 132
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_xstring " binary file
TABLES
otf = lt_tsfotf "lt_tstotf
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.

CALL METHOD cl_bcs_convert=>xstring_to_solix
EXPORTING
iv_xstring = lv_xstring
RECEIVING
et_solix = lt_pdf_xstring.

APPEND LINES OF lt_pdf_xstring TO lt_pdf_final.

======= Code to Append Body Recievers and Attachment ===========

CLEAR ls_message.
ls_message-line = '<!DOCTYPE html><html><head>'.
APPEND ls_message TO lt_message.

CLEAR ls_message.
ls_message-line = '</head><body>'.
APPEND ls_message TO lt_message.

CLEAR ls_message.
ls_message-line = 'Dear Customer,<br>'.
APPEND ls_message TO lt_message.

CLEAR ls_message.
ls_message-line = 'Find Attachment,<br>'.
APPEND ls_message TO lt_message.


CLEAR ls_message.
ls_message-line = '</body></html>'.
APPEND ls_message TO lt_message.

lv_start = 1.

ls_pack_list-transf_bin = 'X'.
ls_pack_list-head_start = 1.
ls_pack_list-head_num = 1.
ls_pack_list-body_start = lv_start.

DESCRIBE TABLE lt_pdf_xstring LINES ls_pack_list-body_num.
ls_pack_list-doc_type = 'PDF'.

CONCATENATE 'Invoice' 'Test' INTO ls_pack_list-obj_descr SEPARATED BY '_'.
ls_pack_list-obj_name = 'Test'.
ls_pack_list-doc_size = ls_pack_list-body_num * 255.
lv_start = lv_start + ls_pack_list-body_num.

APPEND ls_pack_list TO lt_pack_list.
CLEAR ls_pack_list.

MOVE sy-langu TO ls_doc_data-obj_langu.
MOVE 'Test' TO ls_doc_data-obj_descr.

DESCRIBE TABLE lt_message LINES ls_pack_list-body_num.
CLEAR lv_length.
MOVE ls_pack_list-body_num TO lv_length.
MOVE 'HTM' TO ls_pack_list-doc_type.
MOVE space TO ls_pack_list-transf_bin.
MOVE '1' TO ls_pack_list-head_start.
MOVE '0' TO ls_pack_list-head_num.
MOVE '1' TO ls_pack_list-body_start.

INSERT ls_pack_list INTO lt_pack_list INDEX 1.
CLEAR ls_pack_list.

MOVE 'test@ex.com' TO ls_receivers-receiver. "*Email ID
MOVE 'U' TO ls_receivers-rec_type.
ls_receivers-com_type = 'INT'.
ls_receivers-notif_del = 'X'.
ls_receivers-notif_ndel = 'X'.
APPEND ls_receivers TO lt_receivers.


CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc_data
put_in_outbox = c_x
commit_work = c_x
TABLES
packing_list = lt_pack_list
contents_txt = lt_message
receivers = lt_receivers
* contents_bin = lt_pdf_xstring
contents_hex = lt_pdf_final
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.

Function Module raises sy-subrc 6 and in debugging i found exception is raised in SBCOMS_SR_FROM_DOCUMENT_CREATE . Exception is shown in image attached in this question.

1 ACCEPTED SOLUTION
Read only

1,602

Solved the issue! In debugging i found content server was not running.

3 REPLIES 3
Read only

Lakshmipathi
SAP Champion
SAP Champion
0 Likes
1,602

Probably you need to implement the code corrections as recommended in OSS note 1430123

Read only

0 Likes
1,602

Hi G Lakshmipathi the same code works in other servers except the client server who has this requirement :'( .

Read only

1,603

Solved the issue! In debugging i found content server was not running.