dear all
i have created a smartform which needs to send to external mail ID.s as an .doc attachment else without attchment mail has to open directly.i dont want pdf file.i want output in word or direct mail has to open....how to do this. even i have no basic idea also. kindly help out.
regards
&----
*& Report ZTEST_MAIL_ASW
*&
&----
*&
*&
&----
REPORT ZTEST_MAIL_ASW NO STANDARD PAGE HEADING..
****************Data Declaration
TABLES: nast,
tnapr,
pb0105.
DATA : BEGIN OF it_final OCCURS 0,
ename LIKE pb0001-ename,
END OF it_final.
DATA: price_print_mode(1) TYPE c. "Print-mode
DATA: retcode LIKE sy-subrc. "Returncode
DATA: repeat(1) TYPE c.
DATA: xscreen(1) TYPE c. "Output on printer or screen
DATA: fm_name TYPE rs38l_fnam.
***************Selection Screen**********************
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME.
PARAMETERS: p_pernr LIKE pb0006-pernr MATCHCODE OBJECT zform1 OBLIGATORY
.
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME.
PARAMETERS: r1 RADIOBUTTON GROUP c.
PARAMETERS: r2 RADIOBUTTON GROUP c.
SELECTION-SCREEN END OF BLOCK b.
*************End Of Selection Screen*****************
PERFORM processing.
&----
*& Form PROCESSING
&----
text
----
--> p1 text
<-- p2 text
----
FORM processing .
DATA: lf_formname TYPE tdsfname.
DATA: lf_fm_name TYPE rs38l_fnam.
DATA: ls_control_param TYPE ssfctrlop.
DATA: ls_composer_param TYPE ssfcompop.
DATA: ls_recipient TYPE swotobjid.
DATA: ls_sender TYPE swotobjid.
DATA: ls_job_info TYPE ssfcrescl.
DATA: g_sales_document TYPE vbak-vbeln.
DATA: zz_adr6 TYPE adr6.
DATA: l_send_mail TYPE c.
DATA: l_format TYPE string.
DATA: l_filesize TYPE string.
DATA: lt_otf TYPE TABLE OF itcoo,
lt_lines TYPE TABLE OF tline WITH HEADER LINE,
fle1 TYPE i,
fle2 TYPE i,
off1 TYPE i,
hltlines TYPE i,
hfeld(500) TYPE c,
htabix TYPE syst-tabix,
linecnt TYPE i,
l_flag TYPE flag,
l_type TYPE soextreci1-adr_typ VALUE 'INT'.
DATA: it_msg LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_title(50) TYPE c,
w_doc_data LIKE sodocchgi1,
l_texts LIKE tline OCCURS 0 WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all TYPE flag,
w_sender TYPE soextreci1-receiver,
x_objcont LIKE soli OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZCSF_HR_CFI'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF r1 IS INITIAL.
ls_composer_param-tdnewid = 'X'.
ls_control_param-no_dialog = 'X'.
ls_composer_param-tdcopies = 1.
ls_control_param-getotf = 'X'.
CALL FUNCTION fm_name
EXPORTING
p_pernr = p_pernr
control_parameters = ls_control_param
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = space
p_date = p_date
IMPORTING
job_output_info = ls_job_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
lt_otf = ls_job_info-otfdata.
*
Convert OTF data into PDF format
l_format = 'PDF'.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = l_format
max_linewidth = 132
IMPORTING
bin_filesize = l_filesize
TABLES
otf = lt_otf
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
DESCRIBE TABLE lt_lines LINES hltlines.
DESCRIBE FIELD lt_lines LENGTH fle1 IN CHARACTER MODE.
DESCRIBE FIELD x_objcont LENGTH fle2 IN CHARACTER MODE.
LOOP AT lt_lines.
htabix = sy-tabix.
MOVE lt_lines TO hfeld+off1.
IF htabix = hltlines.
fle1 = STRLEN( lt_lines ).
ENDIF.
off1 = off1 + fle1.
IF off1 GE fle2.
CLEAR x_objcont.
x_objcont = hfeld(fle2).
APPEND x_objcont.
SHIFT hfeld BY fle2 PLACES.
off1 = off1 - fle2.
ENDIF.
IF htabix = hltlines.
IF off1 GT 0.
CLEAR x_objcont.
x_objcont = hfeld(off1).
APPEND x_objcont.
ENDIF.
ENDIF.
ENDLOOP.
Populate body of message
it_msg-line = 'This is a Computer Generated Mail.'.
APPEND it_msg.
it_msg-line = 'Please do not Reply'.
APPEND it_msg.
CLEAR: it_att[].
it_att[] = x_objcont[].
Populate the subject
CLEAR w_doc_data.
READ TABLE it_att INDEX linecnt.
w_doc_data-doc_size =
( linecnt - 1 ) * 255 + STRLEN( it_att ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = 'Interview Call Letter from Nitco Tiles Ltd. '.
w_doc_data-sensitivty = 'F'.
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_msg LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_att LINES t_packing_list-body_num.
t_packing_list-doc_type = 'PDF'.
t_packing_list-obj_descr = 'Interview Call Letter from Nitco Tiles Ltd.'.
t_packing_list-obj_name = 'DYSTAR.PDF'.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
SELECT SINGLE * FROM pb0105 CLIENT SPECIFIED
WHERE mandt = sy-mandt
AND pernr = p_pernr
AND subty = '0010'.
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = pb0105-usrid_long.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
w_sender = ' '.
l_flag = 'X'.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = l_flag
sender_address = w_sender
sender_address_type = l_type
commit_work = l_flag
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = it_att
contents_txt = it_msg
receivers = t_receivers
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 'Mail Sent' TYPE 'I'.
ENDIF.
SUBMIT rsconn01 WITH mode = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ELSE.
CALL FUNCTION fm_name
EXPORTING
p_pernr = p_pernr
IMPORTING
job_output_info = ls_job_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " PROCESSING
INCLUDE zcrpt_hr_pri_mail_init_paio01.