on 10-21-2008 1:36 PM
I want to send a smartform related to PO through email.
in nace output type is allready assign for that smartforms.
where is the problem during sending this through email.
Hi Boss,
Where you are maintaining the e-mail address?.
Are you written the code for e-mail sending?.just clear this
Best Regards,
Narasimha Rao.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi vivek,
we were also having the same requiremnt and i develepd a customised function module which will not only help in sending smartform as a attacmnt but also will help in sending text as mail body.
this text can be maintained in NACE.
hope this can help u too.
import parameters
param name type associated type shrt text
I_TID LIKE THEAD-TDID Text ID of text to be read
I_LAN LIKE THEAD-TDSPRAS Language of text to be read
I_L_NAME LIKE THEAD-TDNAME Name of text to be read
I_OID LIKE THEAD-TDOBJECT Object of text to be read
W_RETURN TYPE SSFCRESCL Smart Forms: Return value at end of form printing
I_POTITLE TYPE EBELN purchase order number
W_DOC_CHNG TYPE SODOCCHGI1 data of an object which can be changed
I_ADDRNUM LIKE ADR6-ADDRNUMBER Address number of Vendor
source code :
DESCRIPTION : This function module helps in converting the smartform to *
pdf format and sends mail with proper text in mail body *
----
*"----
""Local Interface:
*" IMPORTING
*" REFERENCE(I_TID) LIKE THEAD-TDID
*" REFERENCE(I_LAN) LIKE THEAD-TDSPRAS
*" REFERENCE(I_L_NAME) LIKE THEAD-TDNAME
*" REFERENCE(I_OID) LIKE THEAD-TDOBJECT
*" REFERENCE(W_RETURN) TYPE SSFCRESCL
*" REFERENCE(I_POTITLE) TYPE EBELN
*" REFERENCE(W_DOC_CHNG) TYPE SODOCCHGI1
*" REFERENCE(I_ADDRNUM) LIKE ADR6-ADDRNUMBER
*"----
----
*data declaration
----
*Internal Table declaration
DATA : it_otf TYPE STANDARD TABLE OF itcoo ,
it_tline TYPE STANDARD TABLE OF tline ,
it_record TYPE STANDARD TABLE OF solisti1,
it_objpack TYPE STANDARD TABLE OF sopcklsti1,
it_objtxt TYPE STANDARD TABLE OF solisti1 ,
it_objbin TYPE STANDARD TABLE OF solisti1 ,
it_reclist TYPE STANDARD TABLE OF somlreci1 ,
it_tdline TYPE STANDARD TABLE OF tline,
*Work Area declarations
wa_objhead TYPE soli_tab,
wa_buffer TYPE string, "To convert from 132 to 255
wa_it_objtxt TYPE solisti1,
wa_it_objpack TYPE sopcklsti1,
wa_it_record TYPE solisti1,
wa_it_reclist TYPE somlreci1,
wa_it_tline TYPE tline,
wa_tdline TYPE tline,
*variable declaration
v_lines_bin TYPE i,
v_lines_txt TYPE i,
v_len_in TYPE sood-objlen, "#EC NEEDED
v_mailaddr TYPE adr6-smtp_addr.
*constant declaration
CONSTANTS : c_msgtype TYPE c VALUE 'E', " for declaring masseage type as error msg
c_X TYPE c VALUE 'X',
c_U TYPE c VALUE 'U'.
it_otf[] = w_return-otfdata[].
*calling function module to convert otf format of smartform to pdf format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = text-001 "PDF
max_linewidth = 132
ARCHIVE_INDEX =
COPYNUMBER =
ASCII_BIDI_VIS2LOG =
PDF_DELETE_OTFTAB =
IMPORTING
bin_filesize = v_len_in
BIN_FILE =
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5 .
IF sy-subrc NE 0.
sy-msgid = text-002. "/fir/rp2p0bgsi_msg
sy-msgty = c_msgtype. " E
sy-msgno = 040.
sy-msgv1 = ' '.
sy-msgv2 = ' '.
sy-msgv3 = ' '.
sy-msgv4 = ' '.
EXIT.
ELSE.
Convert PDF from 132 to 255.
LOOP AT it_tline INTO wa_it_tline.
TRANSLATE wa_it_tline USING ' ~'. " Replacing space by ~
CONCATENATE wa_buffer wa_it_tline INTO wa_buffer.
ENDLOOP.
TRANSLATE wa_buffer USING '~ '. " Replacing space by ~
DO.
wa_it_record = wa_buffer.
APPEND wa_it_record TO it_record. " Appending 255 characters as a record
SHIFT wa_buffer LEFT BY 255 PLACES.
IF wa_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH:it_objbin.
CLEAR wa_objhead.
Object with PDF.
it_objbin[] = it_record[].
DESCRIBE TABLE it_objbin LINES v_lines_bin.
*calling a function module read_text to get the text for the mail body
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = i_tid
language = i_lan
name = i_l_name
object = i_oid
IMPORTING
HEADER =
TABLES
lines = it_tdline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8
.
IF sy-subrc <> 0. "#EC
ENDIF.
IF it_tdline IS NOT INITIAL.
LOOP AT it_tdline INTO wa_tdline.
wa_it_objtxt = wa_tdline-tdline.
APPEND wa_it_objtxt TO it_objtxt.
CLEAR: wa_tdline,
wa_it_objtxt.
ENDLOOP.
DESCRIBE TABLE it_objtxt LINES v_lines_txt.
ENDIF.
Pack to main body as RAW.
CLEAR wa_it_objpack-transf_bin. "Obj. to be transported not in binary form
wa_it_objpack-head_start = 1. "Start line of object header in transport packet
wa_it_objpack-head_num = 0. "Number of lines of an object header in object packet
wa_it_objpack-body_start = 1. "Start line of object contents in an object packet
wa_it_objpack-body_num = v_lines_txt. "Number of lines of the object contents in an object packet
Code for document class
wa_it_objpack-doc_type = text-004. "RAW
APPEND wa_it_objpack TO it_objpack.
Packing as PDF.
wa_it_objpack-transf_bin = c_X. " X
wa_it_objpack-head_start = 1.
wa_it_objpack-head_num = 1.
wa_it_objpack-body_start = 1.
wa_it_objpack-body_num = v_lines_bin.
wa_it_objpack-doc_type = text-001. "PDF
wa_it_objpack-obj_name = text-006. "SmartForm
CONCATENATE i_potitle '.pdf' INTO wa_it_objpack-obj_descr.
wa_it_objpack-doc_size = v_lines_bin * 255.
APPEND wa_it_objpack TO it_objpack.
Document information.
CLEAR wa_it_reclist.
e-mail receivers.
SELECT SINGLE smtp_addr FROM adr6 INTO v_mailaddr "#EC *
WHERE addrnumber = i_addrnum.
wa_it_reclist-receiver = v_mailaddr.
wa_it_reclist-express = c_X. " X
wa_it_reclist-rec_type = c_U. "U -> Internet address
APPEND wa_it_reclist TO it_reclist.
Sending Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = c_X "X
COMMIT_WORK =
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = it_objpack
object_header = wa_objhead
contents_bin = it_objbin
contents_txt = it_objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = it_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.
sy-msgid = text-008. "/fir/rp2p0bgsi_msg
sy-msgty = c_msgtype. " E
sy-msgno = 041.
sy-msgv1 = ' '.
sy-msgv2 = ' '.
sy-msgv3 = ' '.
sy-msgv4 = ' '.
EXIT.
ENDIF.
ENDIF.
ENDFUNCTION.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
In the tcode...of PO...just check the output type that is given. Just see if the correct output type is given.
Regards,
Vishwa.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.