on 10-27-2009 12:19 PM
Hi all,
I have created a smartform for PO and assigned it to a driver program,and I am able to take the print out.
In NACE it is assigned and print out can be taken.
Now tell me how to send the same PO through Email because in NACE we can see the input options to take the print out for a smartform. But not for Emailing.
So please tell me how to Email a smartform? Do we need to make changes in the form created ?or we need to give some other inputs so that it can be mailed?
Please answer
Thx
Hi
Ask ur Functional Consultant to enhance Medium in the Output type for External Send also and you assgin the Program and smartform and in the smartform write the code to based on the condition convert to PDF and use Fm to send to the required Emails ..
Check these links below
https://wiki.sdn.sap.com/wiki/x/MYOmAw
/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp
http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=134545580
surya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In your driver program write the below logic..
IF NAST-NACHA EQ '5'.
* Get Vendor Details.
select single * from lfa1 into lvs_lfa1
where lifnr = nast-parnr.
* ... use stratagy to get communication type
call function 'ADDR_GET_NEXT_COMM_TYPE'
exporting
strategy = nast-tcode
address_number = lvs_lfa1-adrnr
importing
comm_type = lvs_comm_type
comm_values = lvs_comm_values
exceptions
address_not_exist = 1
person_not_exist = 2
no_comm_type_found = 3
internal_error = 4
parameter_error = 5
others = 6.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
* convert communication data
move-corresponding nast to intnast.
move sy-repid to l_programm.
call function 'CONVERT_COMM_TYPE_DATA'
exporting
pi_comm_type = lvs_comm_type
pi_comm_values = lvs_comm_values
pi_country = lfa1-land1
pi_repid = l_programm
pi_snast = intnast
importing
pe_itcpo = itcpo
pe_device = xdevice
pe_mail_recipient = lvs_recipient
pe_mail_sender = lvs_sender
exceptions
comm_type_not_supported = 1
recipient_creation_failed = 2
sender_creation_failed = 3
others = 4.
if sy-subrc <> 0.
* Avoids cancellation with message TD421
l_retcode = '1'.
PERFORM PROTOCOL_UPDATE USING '142' EKKO-EBELN SPACE SPACE SPACE.
if 1 = 2.
message s740(me).
endif.
exit.
endif.
if xdevice = 'mail'.
* Check validity of email address to avoid cancellation with TD463
call function 'SX_ADDRESS_TO_DEVTYPE'
exporting
recipient_id = lvs_recipient
sender_id = lvs_sender
exceptions
err_invalid_route = 1
err_system = 2
others = 3.
if sy-subrc <> 0.
l_retcode = '1'.
PERFORM PROTOCOL_UPDATE
USING '142' EKKO-EBELN SPACE SPACE SPACE.
if 1 = 2.
message s740(me).
endif.
exit.
endif.
endif
Regards
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To send form thru email, there are parameters in the function module that is generated when the Smart form is activated. The parameters are:
MAIL_SENDER
MAIL_RECEIPIENT
MAIL_APPL_OBJ
Also note that, in control structure the parameter DEVICE = u2018MAILu2019.
Regards,
Sana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can check the below code which can be used for sending the smartform as e-mail and do check in SDN before posting as it is a duplicate post.
This has been given earlier by somebody. I am copying it and giving it to you
Import parameters
Param name Type associated type short 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 :
PROGRAM TITLE : MAIL SEND
AUTHOR : K PRASHANTI
DATE : 08/08/2008
DESCRIPTION : This function module helps in converting the smart form to
pdf format and sends mail with proper text in
mail body
----
*" 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 ='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. "Vendor creation failed
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... puting a select on adr6 to get mail id on basis of address number which is getting from adrc table based on your requiremnt .
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. "The entered value is not a valid Storage Location
sy-msgty = c_msgtype. " E
sy-msgno = 041. sy-msgv1 = ' '.
sy-msgv2 = ' '.
sy-msgv3 = ' '.
sy-msgv4 = ' '.
EXIT.
ENDIF.
ENDIF.
ENDFUNCTION.
Please appreciate for the same.
Regards
Sachin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.