on 09-12-2008 1:27 AM
Hi friends,
i'm trying to send a form as pdf trough an email. When testing with Sapoffice (rec_type = 'B') it's working fine but with rec_type = 'U' (Internet) i'm not geting email in sost T-code. Also, smtp is configured in the machine i'm using for testing, i tested it in another development.
here is my code :
lf_formname = irldrc-formu.
ls_control_param-device = 'PRINTER'.
ls_control_param-no_dialog = 'X'.
* ls_control_param-preview = ' '.
ls_control_param-langu = sy-langu.
* ls_composer_param-TDARMOD = '1'.
ls_composer_param-tddelete = it329p-tddelete.
ls_composer_param-tddest = irldrc-ldest.
ls_composer_param-tdimmed = it329p-tdimmed.
ls_composer_param-tdreceiver = sy-uname.
ls_composer_param-tdcopies = it329p-tdcopies.
ls_composer_param-tddataset = it329p-tddataset.
ls_composer_param-tdnewid = p_newspool.
IF return_code = 0.
* determine smartform function module for invoice
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING formname = lf_formname
* variant = ' '
* direct_call = ' '
IMPORTING fm_name = lf_fm_name
EXCEPTIONS no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
return_code = sy-subrc.
* PERFORM protocol_update.
ENDIF.
ENDIF.
REFRESH: t_likp, t_lips.
SELECT * FROM likp INTO TABLE t_likp
FOR ALL ENTRIES IN irldrh
WHERE vbeln = irldrh-vbeln.
IF NOT t_likp[] IS INITIAL.
SELECT * FROM lips INTO TABLE t_lips
FOR ALL ENTRIES IN irldri
WHERE vbeln = irldri-vbeln
AND posnr = irldri-posnr.
ENDIF.
IF return_code = 0.
nast_anzal = it329p-tdcopies.
DO nast_anzal TIMES.
ls_composer_param-tdarmod = 1.
ls_control_param-getotf = 'X'.
* call smartform
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
* mail_appl_obj =
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = ' '
is_nast = nast
IMPORTING job_output_info = w_return
TABLES
t_rldrc = irldrc[]
t_rldrh = irldrh[]
t_rldri = irldri[]
t_rldru = irldru[]
t_t329p = it329p[]
t_likp = t_likp[]
t_lips = t_lips[]
* importing document_output_info =
* job_output_info =
* job_output_options =
EXCEPTIONS formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* error handling
return_code = sy-subrc.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
* PERFORM add_smfrm_prot.
ELSE.
PERFORM send_mail USING irldrh-vbeln. *<----------Here is my form*
ENDIF.
ENDDO.
*&---------------------------------------------------------------------*
*& Form send_mail
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM send_mail USING p_vbeln TYPE vbeln.
DATA : ls_usr21 TYPE usr21.
DATA : ls_adr6 TYPE adr6.
*PDF Conversion
REFRESH: i_record.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = p_vbeln
IMPORTING
output = p_vbeln.
i_otf[] = w_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
bin_file = wa_bufferx
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
lt_solix[] = cl_document_bcs=>xstring_to_solix( wa_bufferx ).
* Attachment
REFRESH:
i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
i_objbin[] = i_record[].
******* Create Message Body
**** Title and Description
CLEAR i_objtxt.
CONCATENATE 'Please find as attachment the Picking List for delivery'
p_vbeln INTO i_objtxt SEPARATED BY space.
APPEND i_objtxt.
CLEAR i_objtxt.
i_objtxt = 'Sincerly.'. "mail text
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
READ TABLE i_objtxt INDEX v_lines_txt.
CONCATENATE 'Picking list for delivery' p_vbeln
INTO wa_doc_chng-obj_name SEPARATED BY space.
* wa_doc_chng-expiry_dat = sy-datum + 10.
CONCATENATE 'Picking list for delivery' p_vbeln
INTO wa_doc_chng-obj_descr SEPARATED BY space.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.
**** Main Text
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
**** Attachment
* (pdf-Attachment)
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
* L?nge des Attachment ermitteln
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
* i_objpack-doc_size = v_lines_bin * 255 .
i_objpack-doc_size = XSTRLEN( wa_bufferx ). .
* i_objpack-body_num = v_lines_bin.
DESCRIBE TABLE lt_solix LINES i_objpack-body_num.
i_objpack-doc_type = 'PDF'.
CONCATENATE 'Pick_List_' p_vbeln '.pdf' INTO i_objpack-obj_name.
* name of the PDF file
CONCATENATE 'Pick_List_' p_vbeln '.pdf' INTO i_objpack-obj_descr.
APPEND i_objpack.
* Get user Email
SELECT SINGLE * FROM usr21 INTO ls_usr21
WHERE bname = sy-uname.
IF sy-subrc = 0.
CLEAR i_reclist.
SELECT SINGLE smtp_addr FROM adr6
INTO i_reclist-receiver
WHERE addrnumber = ls_usr21-addrnumber
AND persnumber = ls_usr21-persnumber.
ENDIF.
* i_reclist-receiver = sy-uname.
i_reclist-rec_type = 'U'.
APPEND i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = wa_objhead
* contents_bin = i_objbin
contents_txt = i_objtxt
contents_hex = lt_solix
receivers = i_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.
ENDFORM. "send_mail
Points will be rewarded, Thanks for yur help.
Edited by: Soufiane FAYSSAL on Sep 12, 2008 2:27 AM
Solved !! I had to flag commit_work...
Thanks for your replies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
after the mail sending function call , check the sy-subrc and then call the below function some thing like this..
if sy-subrc eq 0.
commit work.
call function 'SO_DEQUEUE_UPDATE_LOCKS'.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.