on 01-18-2008 4:30 PM
hiii friends
can any one tell me hw to send the smartform by using email....
i have to send the smartform to an email .
hw can i do that
Hello,
Below is the code to sent smartform to email.
&----
*& Report ZTEST_PDF_MAIL
*&
&----
REPORT ZTEST_PDF_MAIL.
Internal Table declarations
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
Objects to send mail.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
Work Area declarations
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
Variables declarations
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZTEST'
IMPORTING
FM_NAME = V_FORM_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.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
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.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
Create Message Body Title and Description
I_OBJTXT = 'test with pdf-Attachment!'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
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 = 0.
I_OBJPACK-BODY_START = 1.
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-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'smart'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = 'nareshreddy.k@gmail.com'.
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'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
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.
IF SY-SUBRC <> 0.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF.
If you want to send some text as Body of the Mail then follow this once
when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
I_OBJPACK-TRANSF_BIN = ' '.
I_OBJPACK-HEAD_START = 000000000000001.
I_OBJPACK-HEAD_NUM = 000000000000001.
I_OBJPACK-BODY_START = 000000000000002
I_OBJPACK-BODY_NUM = 000000000000010.
I_OBJPACK-DOC_TYPE = 'RAW'.
append I_OBJPACK-.
by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
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
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.
Please Reward.
Viswam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello all,
In solution manager 4.0. through (CRM_SLFN_ORDER_SERVICE_01) standard smartform the mail is triggered to SuperUser and EndUser..,
and mail comes as a attachment ..The attachment name is
service Transaction m/ssge.pdf.. which comes under the subject field in mail...now my problem is ,i want the message number(ticket no. for particular super or enduser) and description of that particular message in place of name of the .pdf name that is service Transactionm/ssge.pdf.. ..please help it out
Deepak Saini
hi,
tyr this code ,hope usefull to u, reward point ,dont forget.
&----
*& Report ZTEST_SMARTFORM
*&
&----
*&
*&
&----
REPORT ztest_smartform.
DATA: formname TYPE tdsfname,
fm_name TYPE rs38l_fnam,
control_parameters TYPE ssfctrlop,
job_output_info TYPE ssfcrescl,
otf_data TYPE tsfotf,
bin_filesize TYPE i,
otf TYPE TABLE OF itcoo WITH HEADER LINE,
doctab_archive TYPE TABLE OF docs WITH HEADER LINE,
lines TYPE TABLE OF tline WITH HEADER LINE.
INITIALIZATION.
formname = 'ZSMARTFROM'.
START-OF-SELECTION.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
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.
control_parameters-no_dialog = 'X'.
control_parameters-preview = ''.
control_parameters-getotf = 'X'.
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX = ARCHIVE_INDEX
ARCHIVE_INDEX_TAB = ARCHIVE_INDEX_TAB
ARCHIVE_PARAMETERS = ARCHIVE_PARAMETERS
control_parameters = control_parameters
MAIL_APPL_OBJ = MAIL_APPL_OBJ
MAIL_RECIPIENT = MAIL_RECIPIENT
MAIL_SENDER = MAIL_SENDER
OUTPUT_OPTIONS = OUTPUT_OPTIONS
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO
job_output_info = job_output_info
JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS
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.
otf_data[] = job_output_info-otfdata[].
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
USE_OTF_MC_CMD = 'X'
ARCHIVE_INDEX = ARCHIVE_INDEX
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = otf_data[]
doctab_archive = doctab_archive[]
lines = lines
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 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.
DATA: filename TYPE string.
filename = 'c:\test\smart.pdf'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = filename
filetype = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH = FILELENGTH
TABLES
data_tab = lines[]
FIELDNAMES = FIELDNAMES
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA: document_data LIKE sodocchgi1 ,
contents_txt TYPE TABLE OF solisti1 WITH HEADER LINE,
contents_bin TYPE TABLE OF solisti1 WITH HEADER LINE,
tab_lines TYPE i,
packing_list TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
OBJECT_HEADER type table of SOLISTI1 with header line,
RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
l_str(255) ,
v1 TYPE i,
v2 TYPE i,
v3 type i.
CONSTANTS: c_raw TYPE so_obj_tp VALUE 'RAW',
c_pdf TYPE so_obj_tp VALUE 'PDF',
c_255 TYPE i VALUE 255,
c_134 TYPE i VALUE 134,
C_X TYPE C VALUE 'X',
C_U TYPE C VALUE 'U'.
document_data-obj_name = 'EMAIL'.
document_data-obj_descr = 'subject'.
contents_txt = 'THIS IS first line DATA'.
APPEND contents_txt.
CLEAR contents_txt.
contents_txt = 'THIS IS second line DATA'.
APPEND contents_txt.
CLEAR contents_txt.
APPEND contents_txt.
APPEND contents_txt.
DESCRIBE TABLE contents_txt LINES tab_lines.
READ TABLE contents_txt INDEX tab_lines.
document_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( contents_txt ).
document_data-doc_size = tab_lines .
CLEAR packing_list-transf_bin.
packing_list-head_start = 1.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = tab_lines.
packing_list-doc_type = c_raw.
packing_list-doc_size = document_data-doc_size.
APPEND packing_list.
LOOP AT lines.
CLEAR l_str.
l_str+0(2) = lines-tdformat.
l_str+2(132) = lines-tdline.
v2 = v1 + c_134.
IF v2 LE c_255.
contents_bin-line+v1(c_134) = l_str. v1 = v2.
ELSE.
v3 = v2 - c_255.
v2 = c_255 - v1.
IF NOT v2 IS INITIAL.
contents_bin-linev1(v2) = l_str0(v2).
ENDIF.
APPEND contents_bin.
CLEAR contents_bin.
v1 = v3.
v3 = 134 - v1.
IF NOT v1 IS INITIAL.
contents_bin-line0(v1) = l_strv3(v1).
ENDIF.
ENDIF.
ENDLOOP.
APPEND contents_bin.
CLEAR contents_bin.
DESCRIBE TABLE contents_bin LINES tab_lines.
READ TABLE contents_bin INDEX tab_lines.
OBJECT_HEADER = 'objhead'.
APPEND OBJECT_HEADER.
packing_list-transf_bin = c_x.
packing_list-head_start = 1.
packing_list-head_num = 1.
packing_list-body_start = 1.
packing_list-body_num = tab_lines.
packing_list-doc_type = c_pdf.
packing_list-obj_name = 'text1'.
packing_list-obj_descr = 'filename'.
packing_list-doc_size = tab_lines * 255 + STRLEN( contents_bin ).
APPEND packing_list.
RECEIVERS-receiver = 'FAREEDAS@INTELLIGROUP.COM'.
RECEIVERS-rec_type = c_u.
APPEND RECEIVERS.
CLEAR RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = SY-UNAME
SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID = NEW_OBJECT_ID
SENDER_ID = SENDER_ID
TABLES
packing_list = packing_list
OBJECT_HEADER = OBJECT_HEADER
CONTENTS_BIN = CONTENTS_BIN
CONTENTS_TXT = CONTENTS_TXT
CONTENTS_HEX = CONTENTS_HEX
OBJECT_PARA = OBJECT_PARA
OBJECT_PARB = OBJECT_PARB
receivers = 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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards
sft
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do it via SCOT (configuration needed) but you also need a piece of code attached.
Configuration part:
You need to create an output type via NACE with the transmission medium set as "External send". Pass also your print program name and smartform name. The communication strategy should be "CS01".
Code needed in print program:
CONSTANTS: lc_type TYPE c VALUE 'U'.
DATA: lv_recipient TYPE swotobjid,
lv_sender TYPE swotobjid.
"FM to pass mail address
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_mailaddr = "add email address here
ip_type_id = lc_type
IMPORTING
ep_recipient_id = lv_recipient
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"To send the mail to the recipeint
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = lv_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA: BEGIN OF wa_sofmfol_key,
foldertype LIKE sofm-foltp,
folderyear LIKE sofm-folyr,
foldernumber LIKE sofm-folno,
type LIKE sofm-doctp,
year LIKE sofm-docyr,
number LIKE sofm-docno,
forwarder LIKE soub-usrnam,
END OF wa_sofmfol_key,
folder TYPE swc_object,
bor_key LIKE swotobjid-objkey,
lv_mail_app_obj TYPE swotobjid.
CONSTANTS: lc_fol LIKE sofm-doctp VALUE 'FOL',
lc_sofmfol(7) TYPE c VALUE 'SOFMFOL' .
SELECT *
FROM soud UP TO 1 ROWS
WHERE sapnam LIKE sy-uname
AND deleted = ' '.
ENDSELECT.
IF sy-subrc NE 0.
CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'
EXPORTING
sapname = sy-uname
EXCEPTIONS
no_insert = 1
sap_name_exist = 2
x_error = 3
OTHERS = 4.
IF sy-subrc NE 0.
CLEAR soud.
ELSE.
SELECT *
FROM soud UP TO 1 ROWS
WHERE sapnam LIKE sy-uname
AND deleted = ' '.
ENDSELECT.
IF sy-subrc EQ 0.
"do nothing
ENDIF.
ENDIF.
ENDIF.
CLEAR wa_sofmfol_key.
wa_sofmfol_key-type = lc_fol.
wa_sofmfol_key-year = soud-inbyr.
wa_sofmfol_key-number = soud-inbno.
bor_key = wa_sofmfol_key.
IF NOT bor_key IS INITIAL.
swc_create_object folder lc_sofmfol bor_key.
IF sy-subrc = 0.
swc_object_to_persistent folder lv_mail_app_obj.
IF sy-subrc NE 0.
CLEAR lv_mail_app_obj.
ENDIF.
ENDIF.
ELSE.
CLEAR lv_mail_app_obj.
ENDIF.
Finally call your smartform as usual via FM SSF_FUNCTION_MODULE_NAME. The smartform will be sent as attachment thru mail.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello all,
In solution manager 4.0. through (CRM_SLFN_ORDER_SERVICE_01) standard smartform the mail is triggered to SuperUser and EndUser..,
and mail comes as a attachment ..The attachment name is
service Transaction m/ssge.pdf.. which comes under the subject field in mail...now my problem is ,i want the message number(ticket no. for particular super or enduser) and description of that particular message in place of name of the .pdf name that is service Transactionm/ssge.pdf.. ..please help it out
Deepak Saini
hi,
use this fm ''SO_NEW_DOCUMENT_ATT_SEND_API1''
reward points if useful,
seshu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.