Email a Smartform
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,
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
---- ""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 ='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
Similar Messages
-
Error while trying to open an attachment sent through email in smartform
Hi,
My requirement is to send the smartform through email as PDF attachment.I am able to send the mail.But when I try to open the attachment I am getting error as 'Adobe reader could not open the attachment 'advance shipment notification.PDF' because it is either not the supported file type or the file has been corrupted(for example, it was sent as an email attachment and was't correctly decoded)'.What does it mean?
Can anyone give me a proper solution for this?
It's very urgent.Useful answers will be rewarded.
Thanks,
HemaHi,
Are you using any webdispatcher or some proxy? Is there any URL filter configured in between?
If yes then I think you have to allow these pages.
Regards,
Vamshi. -
Error while emailing pdf Smartform- help needed
Hi All,
I have successsully saved smartform as pdf on my local machine and while trying to send the same as an attachment.i am encountering a run time error in SCOT transaction on pressing send message.
Error details are as follows:-
CPIC-CALL: THE SAPECMINIT UNABLE TO DETERMINE HOST ADDRESS
Source Code: SAPMSSY1
CALL RFCIMPORT
The program is given below. Kindly reply me the solution.
All helpful answers will b rewarded.
Regards,
Eureka.
*& Report Z24436_SMARTFORM2 *
REPORT Z24436_SMARTFORM2 .
Global Variables Declarations
DATA: MAt_id TYPE MATNR VALUE '1%',
fm_name TYPE rs38l_fnam.
DATA: ITAB_MAkt TYPE STANDARD TABLE OF MAkt.
DATA: p_form TYPE tdsfname VALUE 'ZUDAY_SMARTFORMS1'.
All Database Selections are here
*Getting Materials belonging to the given plant
SELECT * FROM MAkt INTO TABLE ITAB_MAkt
WHERE MATNR LIKE MAT_id.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
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.
EXIT.
ENDIF.
DATA : gw_ssfcrescl TYPE ssfcrescl.
DATA: gt_otf TYPE STANDARD TABLE OF itcoo ,
gt_tline TYPE STANDARD TABLE OF tline,
gt_pdf TYPE STANDARD TABLE OF tline,
gv_len LIKE sood-objlen,
gw_ssfctrlop TYPE ssfctrlop, "for CONTROL_PARAMETERS
gw_ssfcompop TYPE ssfcompop. "for OUTPUT_OPTIONS
gw_ssfctrlop-getotf = 'X'.
gw_ssfctrlop-no_dialog = 'X'.
gw_ssfcompop-tdnoprev = 'X'.
**Calling the generated function module
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = gw_ssfctrlop
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = gw_ssfcompop
USER_SETTINGS = 'X'
customer_info = customer
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = gw_ssfcrescl
JOB_OUTPUT_OPTIONS =
TABLES
it_makt = itab_makt
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.
gt_otf[] = gw_ssfcrescl-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = gv_len
TABLES
otf = gt_otf
lines = gt_pdf
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
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:
gt_pdf TYPE TABLE OF tline,
gt_xi_pdf TYPE TABLE OF tline,
gt_pdf_conv TYPE TABLE OF solisti1,
gt_xi_temp TYPE TABLE OF bapiqcmime.
CONSTANTS:
lc_x(1) TYPE c VALUE 'X',
lc_raw(3) TYPE c VALUE 'RAW',
lc_pdf(3) TYPE c VALUE 'PDF',
lc_attach(12) TYPE c VALUE 'ATTACHMENT'.
DATA:
lv_spool TYPE rspoid, "Spool Number
lv_pdf_size TYPE i, "PDF Size
lv_subject(40) TYPE c, "Email subject
lv_tab_lines TYPE sytabix, "Table Lines
lv_date(10) TYPE c, "Variable for date
lv_time(8) TYPE c. "Variable for Time
DATA:
For Compressing document
ls_objpack TYPE sopcklsti1,
lt_objpack TYPE STANDARD TABLE OF sopcklsti1,
To specify subject
lt_objhead TYPE STANDARD TABLE OF solisti1,
ls_objhead TYPE solisti1,
To send the PDF
lt_objbin TYPE STANDARD TABLE OF solisti1,
ls_objbin TYPE solisti1,
Email body
lt_objtxt TYPE STANDARD TABLE OF solisti1,
ls_objtxt TYPE solisti1,
To specify Receivers
lt_reclist TYPE STANDARD TABLE OF somlreci1,
ls_reclist TYPE somlreci1,
Documenting Data
ls_doc_chng TYPE sodocchgi1,
ls_pdf_conv TYPE solisti1.
CONSTANTS: lc_under(1) TYPE c VALUE '_'.
**Copy the Spool request to a Local Variable
lv_spool = sy-spono.
Convert spool job to PDF
***************this is normal report spool to pdf.
but your case it will be smartform to pdf
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spool
no_dialog = lc_x
IMPORTING
pdf_bytecount = lv_pdf_size
TABLES
pdf = gt_pdf
EXCEPTIONS
OTHERS = 0.
To Format the PDF file so as each row contains 255 characters
PERFORM page_format .
Transfer the file to objbin table
LOOP AT gt_pdf_conv INTO ls_pdf_conv.
ls_objbin-line = ls_pdf_conv-line.
APPEND ls_objbin TO lt_objbin.
CLEAR ls_objbin.
ENDLOOP.
*// Creating the document to be sent - Mail subject creation
ls_doc_chng-obj_name = sy-repid.
lv_subject = text-008. "Mail subject
WRITE sy-datum TO lv_date USING EDIT MASK '__/__/____'.
WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
CONCATENATE lv_subject lc_under lv_date lc_under lv_time
INTO ls_doc_chng-obj_descr.
*// Email body
PDF attachment of Product Allocation for Open orders
ls_objtxt = text-009.
APPEND ls_objtxt TO lt_objtxt.
Write Date when the mail was sent in the email body
CONCATENATE text-010 lv_date INTO ls_objtxt.
APPEND ls_objtxt TO lt_objtxt.
Write Time when the mail was sent in the email body
CONCATENATE text-011 lv_time INTO ls_objtxt.
APPEND ls_objtxt TO lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.
READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_tab_lines.
Calculate the document size
ls_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( ls_objtxt ).
*// Creating the entry for the compressed document
CLEAR ls_objpack-transf_bin.
ls_objpack-head_start = 1.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
ls_objpack-body_num = lv_tab_lines.
ls_objpack-doc_type = 'RAW' . "RAW
APPEND ls_objpack TO lt_objpack.
CLEAR lv_tab_lines.
DESCRIBE TABLE lt_objbin LINES lv_tab_lines.
ls_objhead = ls_doc_chng-obj_descr.
APPEND ls_objhead TO lt_objhead.
*// Creating the entry for the compressed attachment
ls_objpack-transf_bin = lc_x.
ls_objpack-head_start = 1.
ls_objpack-head_num = 1.
ls_objpack-body_start = 1.
ls_objpack-body_num = lv_tab_lines.
ls_objpack-doc_type = 'PDF'. "PDF
ls_objpack-obj_name = 'ATTACHMENT'. "ATTACHMENT
CONCATENATE lv_subject lc_under lv_date lc_under lv_time
INTO ls_objpack-obj_descr.
CLEAR: ls_objbin.
READ TABLE lt_objbin INTO ls_objbin INDEX lv_tab_lines.
ls_objpack-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( ls_objbin ).
APPEND ls_objpack TO lt_objpack.
ls_reclist-receiver = '[email protected]'.
ls_reclist-receiver = gv_email_addr.
ls_reclist-rec_type = 'U'.
APPEND ls_reclist TO lt_reclist.
IF ls_reclist-receiver IS INITIAL.
MESSAGE i175.
ELSE.
*// Send EMail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc_chng
put_in_outbox = lc_x
commit_work = lc_x
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 3
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
Mail successfully delivered
*// Do nothing
WHEN 1.
This will never occur as at any point of time mail will be
sent to one processor only.
*// Do nothing
WHEN 2.
MESSAGE i175.
WHEN 3.
MESSAGE i175.
*// Do nothing
ENDCASE.
ENDIF.
REFRESH: lt_objpack,
lt_objbin,
lt_objtxt,
lt_objhead,
lt_reclist.
CLEAR: ls_reclist,
ls_doc_chng,
ls_objpack,
ls_objhead,
ls_objtxt.
DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\Udaya4.pdf'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = gv_len
filename = gv_filename
filetype = 'BIN'
filetype_no_show = 'X'
IMPORTING
act_filename = gv_filename
filesize = gv_len
cancel = ''
TABLES
data_tab = gt_pdf.
FORM page_format .
Local data
DATA : lv_lines TYPE i,
lv_temp(500) TYPE c,
lv_offset TYPE p,
lv_lineslen(2) TYPE p,
lv_mimelen(2) TYPE p,
lv_tabix LIKE sy-tabix,
ls_pdf_conv TYPE solisti1,
ls_xi_temp TYPE bapiqcmime,
ls_xi_pdf TYPE tline.
CLEAR : gt_xi_pdf,
gt_xi_temp.
REFRESH: gt_xi_pdf,
gt_xi_temp.
Copy the PDF file into table gt_xi_pdf
gt_xi_pdf[] = gt_pdf[].
Reformat the line to 255 characters wide (code from SAP)
CLEAR: lv_temp, lv_offset, gt_xi_temp.
DESCRIBE TABLE gt_xi_pdf LINES lv_lines.
DESCRIBE FIELD ls_xi_pdf LENGTH lv_lineslen IN CHARACTER MODE.
DESCRIBE FIELD ls_xi_temp LENGTH lv_mimelen IN CHARACTER MODE.
Go through all the lines of table gt_xi_pdf
LOOP AT gt_xi_pdf INTO ls_xi_pdf.
lv_tabix = sy-tabix.
Move ls_xi_pdf into lv_temp variable
MOVE ls_xi_pdf TO lv_temp+lv_offset.
Check if its the last line of table gt_xi_pdf
IF lv_tabix = lv_lines.
lv_lineslen = STRLEN( ls_xi_pdf ).
ENDIF.
Calculate the new offset
lv_offset = lv_offset + lv_lineslen.
Check if the new offset is equal to or greater than the length of
gt_xi_temp
IF lv_offset GE lv_mimelen.
CLEAR ls_xi_temp.
Copy the PDF data into gt_xi_temp
ls_xi_temp = lv_temp(lv_mimelen).
APPEND ls_xi_temp TO gt_xi_temp.
SHIFT lv_temp BY lv_mimelen PLACES.
Calculate the new offset
lv_offset = lv_offset - lv_mimelen.
ENDIF. "Offset GE MIMELEN
Check if its the last line of gt_xi_pdf
IF lv_tabix = lv_lines.
Check if lv_temp has some data that is not been transferred to
gt_xi_temp
IF lv_offset GT 0.
CLEAR ls_xi_temp.
Copy the PDF data into gt_xi_temp
ls_xi_temp = lv_temp(lv_offset).
APPEND ls_xi_temp TO gt_xi_temp.
ENDIF. "lv_offset GT 0
ENDIF. "lv_tabix = lv_lines
ENDLOOP.
gt_pdf_conv[] = gt_xi_temp[].
ENDFORM. " page_formatall settings in SCOT is ok ? like SMTP settings , link b/w ur Outlook server and SAP server ?
Regards
Prabhu -
Hi Gurus
We are trying to stop the Smartforms from sending e-mails to bidders/vendors when a bid <b>(BUS2202)</b> is accepted, rejected or returned.Please how can we achieve this?
We have tried using raising a USER_EXCEPTION in the initialization page of the Smartforms but the email is still be generated with empty content and with the subject Bid <bid document no.> rejected.
in our scenario we are not required to send emails at all to the bidders/vendors.
Kindly assist.
Regards
GbemilekeWe have vigorously tried with SAP. They came back with an answer to try either text or PDF emails. which we are already doing. Our HTML emails work well wth Entourage / Outlook and generic email clients. We have problem only with free email services like Yahoo, Hotmail, Gmail etc.
The reason is this.
Smart Form HTML Mail is not the best solution for the customer requirements, though it is good for Text and PDF.
They have two restrictions here:
- the complex style-structure, that cannot be shown in the page design of any free-mail site, as they have no sophisticated approach, Free-mail (eg. Yahoo) changes the Smart Forms HTML and shows the changed HTML in a cell of a table.
After such changes the original box positioning is destroyed.
(May be the free-mail servers doesn't supported the CSS2 layout in our HTML-preview).
Also please note SAP has stopped further research/development on Smart Forms, they no more support for new features.
We have already shelved this idea of generating HTML emails from sap based on Smart Forms. -
Email pdf smartform error!
Hi,
I manage to send pdf to email with attachment, but getting this error
"An unrecognized token BT28.35" was found"
My code:
statics: ls_doc type sodocchgi1,
lv_lines type i,
ls_objhead type soli_tab,
i_objpack type table of sopcklsti1 WITH HEADER LINE,
i_objtxt type table of solisti1 WITH HEADER LINE,
i_objbin type table of solisti1 WITH HEADER LINE,
i_reclist type table of somlreci1 wiTH HEADER LINE.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = lv_filesize
TABLES
OTF = gs_output-otfdata
LINES = gt_lines
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
refresh: i_objpack, i_objtxt, i_objbin, i_reclist.
convert to bin
LOOP AT gt_lines into gs_lines.
TRANSLATE gs_lines USING '~'.
CONCATENATE gs_buffer gs_lines INTO gs_buffer.
ENDLOOP.
TRANSLATE gs_buffer USING '~'.
DO.
i_objbin = gs_buffer.
APPEND i_objbin.
SHIFT gs_buffer LEFT BY 255 PLACES.
IF gs_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Create Message Body
Title and Description
concatenate 'Invoice' ls_rseg-belnr
into i_objtxt separated by space.
append i_objtxt.
describe table i_objtxt lines lv_lines.
read table i_objtxt index lv_lines.
ls_Doc-obj_name = 'INVOICE'.
concatenate 'TSL Invoice' ls_rseg-belnr into ls_Doc-obj_descr
separated by space.
ls_doc-expiry_dat = sy-datum + 10.
ls_Doc-sensitivty = 'F'.
ls_Doc-doc_size = lv_lines * 255.
clear i_reclist.
i_reclist-receiver = gv_emailaddr.
i_reclist-rec_type = 'U'.
append i_reclist.
clear i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = lv_lines.
i_objpack-doc_type = 'RAW'.
append i_objpack.
(pdf-Attachment)
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
Länge des Attachment ermitteln
describe table i_objbin lines lv_lines.
read table i_objbin index lv_lines.
i_objpack-doc_size = lv_lines * 255.
i_objpack-body_num = lv_lines.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'INVOICE'.
concatenate 'TSL Invoice' ls_rseg-belnr into i_objpack-obj_descr
separated by space.
append i_objpack.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = ls_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.
message e398(00) with 'Email ERS invoice failed'
ls_rseg-belnr into g_dummy.
cf_retcode = sy-subrc.
PERFORM protocol_update.
endif.HI
GOOD
GO THROUGH THIS LINK WHICH LL GIVE YOU BRIEF IDEA ABOUT SENDING PDF FILE USING MAIL, THAT YOU CAN IMPLEMNET IN YUOR PROGRAM
http://www.sapgenie.com/abap/example_code.htm
/people/emmanuele.prudenzano/blog/2006/08/03/an-advanced-solution-for-sending-email-from-solution-manager-or-crm
THANKS
MRUTYUN -
when there are any changes to the Purchse order the email has to be sent . I created a new condition type to send the email to the respective vendor. but the email is not getting triggered.
Pls tell me whats the rt way to email changes to a PO ?
What is the use of SCOT transaction ? are any settings required in SCOT specific to the PO to have this done ?
ThanksHi Jesus,
The settings depicts the use of program FM06AEND in the Program Name box in the spro -> mm -> po-> messages .
Routine name is : CHANGE_FLAG.
what is the standard way to do the same ? would appreciate if anyone can let me know that .
Thanks -
Subject Change in Email in Smartforms
Hi,
I am getting the issue as i want to change the subjet as " reminder" so where i can change it pls tell me how to change the description in case of smartforms
Regards
RaviHi,
U r right acutally i want to mention the subject for my smartform when i am sending through mail for body i mention but how can i send the subject so actually i want to add the subject as HI UR SERVICE REQUEST NO IS ( Here one number it want to change ) so how can i change it and where i want to add it ,
For the given smartform just it showing the body only as
Dear Customer,
Some text here
Regards
it is showing like this for this i want to add one subject so pls tell me how can i do this
Thanks & Regards
Ravi -
How to send EMAIL through SmartForms
Hi,
Anyone plz help me how to send mails through smartforms.
I want to send mails through smartforms.
Plz suggest me regarding the same.
Thanks & Regards,
SumivasuHi Sumi,
Same method as normal program, use the function SO_OBJECT_SEND.
I'm sure you have tips about that in this forums.
Regards
Frédéric -
Smartforms output as HTML in email
Hi,
I want to send the output of a smartform as html in email body.
I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
I did everything as per the blog.
However I am getting the email as:
sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
When I display the document using SOST, I get the output as
Address bar has this: C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
and window contains:
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
Regards,
Reema
Message was edited by:
Reema Shahbazkar
In case anyone needs to have a look at my code:
REPORT ZSMARTFORM_2_HTML_EMAIL.
get generated function module for the smartform
DATA: FM_NAME TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSF_SAMPLE_HTML'
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.
get smartform contetnt
set smartform output options
data:
control_parameters type SSFCTRLOP,
OUTPUT_OPTIONS TYPE SSFCOMPOP,
DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
JOB_OUTPUT_INFO TYPE SSFCRESCL,
JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
XSFPARAM_LINE TYPE SSFXSFP,
P_HTML TYPE TRFRESULT,
P_GRAPHICS TYPE TSF_XSF_GR,
WA_RETURN TYPE BAPIRET2.
CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
control_parameters-NO_DIALOG = 'X'.
*control_parameters-GETOTF = 'X'.
OUTPUT_OPTIONS-TDNEWID = SPACE.
OUTPUT_OPTIONS-TDIMMED = SPACE.
OUTPUT_OPTIONS-XSFCMODE = 'X'. "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
OUTPUT_OPTIONS-XSF = 'X'. "XSF OUTPUT ACTIVATED
OUTPUT_OPTIONS-XSFOUTMODE = 'A'. "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
CLEAR: OUTPUT_OPTIONS-XSFOUTDEV. "OUTPUT SPOOL DEVICE
OUTPUT_OPTIONS-XSFFORMAT = 'X'. "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
XSFPARAM_LINE-NAME = 'GRAPHICS'.
XSFPARAM_LINE-VALUE = 'EXTRACT'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
XSFPARAM_LINE-VALUE = C_GR_DIR.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'CONTENT-ID'.
XSFPARAM_LINE-VALUE = 'ENABLE'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
CALL FUNCTION FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = CONTROL_PARAMETERS
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
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.
SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
PROCEED TO SEND EMAIL
DATA: HTML_DATA TYPE TRFRESULT,
L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
HTML_XSTR TYPE XSTRING.
CLEAR: HTML_XSTR.
LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
ENDLOOP.
HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
SPECIAL CHARACTER CONVERSION
DATA: HTML_STR TYPE STRING,
HTML_LEN TYPE I.
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
INBUFF = HTML_XSTR
INBUFFLG = 0
INCODE = '4110' "utf-8
OUTBUFFLG = 0
OUTCODE = '0000'
CSUBST = 'X'
SUBSTC_HASH = ' '
SUBSTC_DOT = ' '
SUBSTC_SPACE = 'x'
SUBSTC = '00035'
IMPORTING
INUSED =
OUTBUFF = HTML_STR
OUTOVERFLOW =
OUTUSED = HTML_LEN
SUBSTED =
INPUT_ENDS_IN_CHAR =
ERRMSG =
EXCEPTIONS
INVALID_CODEPAGE = 1
INTERNAL_ERROR = 2
CANNOT_CONVERT = 3
FIELDS_BAD_TYPE = 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.
CHANGE ENCODING UTF-8 TO LATIN1
REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
HTML_LEN = STRLEN( HTML_STR ).
DATA: L_OFFSET TYPE I,
L_LENGTH TYPE I,
L_DIFF TYPE I,
LT_SOLI TYPE SOLI_TAB,
LS_SOLI TYPE SOLI.
L_OFFSET = 0.
L_LENGTH = 255.
WHILE L_OFFSET < HTML_LEN.
L_DIFF = HTML_LEN - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLI TO LT_SOLI.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
CREATE OBJECT LO_MIME_HELPER
EXPORTING
CODEPAGE = '1133'.
CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
EXPORTING
CONTENT = LT_SOLI
FILENAME =
DESCRIPTION =
HANDLE GRAPHICS
DATA: L_GRAPHIC TYPE SSF_XSF_GR,
GR_XSTR TYPE XSTRING,
L_GR_RAW TYPE BAPICONTEN,
L_CONTENT_ID TYPE STRING,
L_CONTENT_TYPE TYPE W3CONTTYPE,
L_OBJ_LEN TYPE SO_OBJ_LEN,
L_FILENAME TYPE STRING,
LT_SOLIX TYPE SOLIX_TAB,
LS_SOLIX TYPE SOLIX.
LOOP AT P_GRAPHICS INTO L_GRAPHIC.
CLEAR: GR_XSTR.
LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
ENDLOOP.
GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
L_OFFSET = 0.
L_LENGTH = 255.
CLEAR LT_SOLIX[].
WHILE L_OFFSET < L_GRAPHIC-LENGTH.
L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLIX TO LT_SOLIX.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
L_OBJ_LEN = L_GRAPHIC-LENGTH.
ADD IMAGES TO EMAIL
CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
EXPORTING
CONTENT = LT_SOLIX
FILENAME =
EXTENSION =
DESCRIPTION =
CONTENT_TYPE = L_CONTENT_TYPE
LENGTH = L_OBJ_LEN
CONTENT_ID = L_CONTENT_ID
ENDLOOP.
DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
P_SUBJECT TYPE SO_OBJ_DES,
LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
TRY.
CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
EXPORTING
I_SUBJECT = P_SUBJECT
I_LANGUAGE = SY-LANGU
I_IMPORTANCE = '5'
I_SENSITIVITY = 'F'
I_MULTIREL_SERVICE = LO_MIME_HELPER
RECEIVING
RESULT = LO_DOC_BCS
CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
CATCH CX_GBT_MIME INTO LV_GBT_MIME.
ENDTRY.
RECEIVERS
DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
RECEIVER TYPE SOMLRECI1,
L_MAIL_ADDRESS TYPE AD_SMTPADR,
LO_BCS TYPE REF TO CL_BCS,
LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
L_USERNAME TYPE UNAME,
SEND_PARTNER TYPE BU_PARTNER,
LI_SENDER TYPE REF TO IF_SENDER_BCS,
LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
LV_SENT_TO_ALL TYPE BOOLEAN.
CLEAR RECEIVER.
RECEIVER-RECEIVER = '[email protected]'.
RECEIVER-REC_TYPE = 'U'.
RECEIVER-COM_TYPE = 'INT'.
APPEND RECEIVER TO P_RECEIVERS.
L_USERNAME = SY-UNAME.
CLEAR RECEIVER.
LOOP AT P_RECEIVERS INTO RECEIVER.
L_MAIL_ADDRESS = RECEIVER-RECEIVER.
TRY.
CALL METHOD CL_BCS=>CREATE_PERSISTENT
RECEIVING
RESULT = LO_BCS
CALL METHOD LO_BCS->SET_DOCUMENT
EXPORTING
I_DOCUMENT = LO_DOC_BCS
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
CREATE SENDER
CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
TRY.
IF L_USERNAME NS '@'.
L_USERNAME = SEND_PARTNER.
TRANSLATE L_USERNAME TO UPPER CASE.
LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
ELSE.
DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
L_FROM_MAIL_ADDRESS = L_USERNAME.
LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
ENDIF.
CALL METHOD LO_BCS->SET_SENDER
EXPORTING
I_SENDER = LI_SENDER
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
create recepient
data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
TRY.
CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
EXPORTING
I_ADDRESS_STRING = L_MAIL_ADDRESS
I_ADDRESS_NAME =
I_INCL_SAPUSER =
RECEIVING
RESULT = LO_RECEPIENT
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
ENDTRY.
TRY.
CALL METHOD LO_BCS->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = LO_RECEPIENT
I_EXPRESS =
I_COPY =
I_BLIND_COPY =
I_NO_FORWARD =
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
SEND EMAIL DOCUMENT
TRY.
CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
EXPORTING
I_REQUESTED_STATUS = 'N'
TRY.
CALL METHOD LO_BCS->SEND
EXPORTING
I_WITH_ERROR_SCREEN = SPACE
RECEIVING
RESULT = LV_SENT_TO_ALL
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
ENDTRY.
ENDLOOP.
COMMIT WORK.Hi,
I want to send the output of a smartform as html in email body.
I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
I did everything as per the blog.
However I am getting the email as:
sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
When I display the document using SOST, I get the output as
Address bar has this: C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
and window contains:
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
Regards,
Reema
Message was edited by:
Reema Shahbazkar
In case anyone needs to have a look at my code:
REPORT ZSMARTFORM_2_HTML_EMAIL.
get generated function module for the smartform
DATA: FM_NAME TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSF_SAMPLE_HTML'
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.
get smartform contetnt
set smartform output options
data:
control_parameters type SSFCTRLOP,
OUTPUT_OPTIONS TYPE SSFCOMPOP,
DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
JOB_OUTPUT_INFO TYPE SSFCRESCL,
JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
XSFPARAM_LINE TYPE SSFXSFP,
P_HTML TYPE TRFRESULT,
P_GRAPHICS TYPE TSF_XSF_GR,
WA_RETURN TYPE BAPIRET2.
CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
control_parameters-NO_DIALOG = 'X'.
*control_parameters-GETOTF = 'X'.
OUTPUT_OPTIONS-TDNEWID = SPACE.
OUTPUT_OPTIONS-TDIMMED = SPACE.
OUTPUT_OPTIONS-XSFCMODE = 'X'. "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
OUTPUT_OPTIONS-XSF = 'X'. "XSF OUTPUT ACTIVATED
OUTPUT_OPTIONS-XSFOUTMODE = 'A'. "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
CLEAR: OUTPUT_OPTIONS-XSFOUTDEV. "OUTPUT SPOOL DEVICE
OUTPUT_OPTIONS-XSFFORMAT = 'X'. "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
XSFPARAM_LINE-NAME = 'GRAPHICS'.
XSFPARAM_LINE-VALUE = 'EXTRACT'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
XSFPARAM_LINE-VALUE = C_GR_DIR.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'CONTENT-ID'.
XSFPARAM_LINE-VALUE = 'ENABLE'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
CALL FUNCTION FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = CONTROL_PARAMETERS
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
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.
SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
PROCEED TO SEND EMAIL
DATA: HTML_DATA TYPE TRFRESULT,
L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
HTML_XSTR TYPE XSTRING.
CLEAR: HTML_XSTR.
LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
ENDLOOP.
HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
SPECIAL CHARACTER CONVERSION
DATA: HTML_STR TYPE STRING,
HTML_LEN TYPE I.
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
INBUFF = HTML_XSTR
INBUFFLG = 0
INCODE = '4110' "utf-8
OUTBUFFLG = 0
OUTCODE = '0000'
CSUBST = 'X'
SUBSTC_HASH = ' '
SUBSTC_DOT = ' '
SUBSTC_SPACE = 'x'
SUBSTC = '00035'
IMPORTING
INUSED =
OUTBUFF = HTML_STR
OUTOVERFLOW =
OUTUSED = HTML_LEN
SUBSTED =
INPUT_ENDS_IN_CHAR =
ERRMSG =
EXCEPTIONS
INVALID_CODEPAGE = 1
INTERNAL_ERROR = 2
CANNOT_CONVERT = 3
FIELDS_BAD_TYPE = 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.
CHANGE ENCODING UTF-8 TO LATIN1
REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
HTML_LEN = STRLEN( HTML_STR ).
DATA: L_OFFSET TYPE I,
L_LENGTH TYPE I,
L_DIFF TYPE I,
LT_SOLI TYPE SOLI_TAB,
LS_SOLI TYPE SOLI.
L_OFFSET = 0.
L_LENGTH = 255.
WHILE L_OFFSET < HTML_LEN.
L_DIFF = HTML_LEN - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLI TO LT_SOLI.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
CREATE OBJECT LO_MIME_HELPER
EXPORTING
CODEPAGE = '1133'.
CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
EXPORTING
CONTENT = LT_SOLI
FILENAME =
DESCRIPTION =
HANDLE GRAPHICS
DATA: L_GRAPHIC TYPE SSF_XSF_GR,
GR_XSTR TYPE XSTRING,
L_GR_RAW TYPE BAPICONTEN,
L_CONTENT_ID TYPE STRING,
L_CONTENT_TYPE TYPE W3CONTTYPE,
L_OBJ_LEN TYPE SO_OBJ_LEN,
L_FILENAME TYPE STRING,
LT_SOLIX TYPE SOLIX_TAB,
LS_SOLIX TYPE SOLIX.
LOOP AT P_GRAPHICS INTO L_GRAPHIC.
CLEAR: GR_XSTR.
LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
ENDLOOP.
GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
L_OFFSET = 0.
L_LENGTH = 255.
CLEAR LT_SOLIX[].
WHILE L_OFFSET < L_GRAPHIC-LENGTH.
L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLIX TO LT_SOLIX.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
L_OBJ_LEN = L_GRAPHIC-LENGTH.
ADD IMAGES TO EMAIL
CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
EXPORTING
CONTENT = LT_SOLIX
FILENAME =
EXTENSION =
DESCRIPTION =
CONTENT_TYPE = L_CONTENT_TYPE
LENGTH = L_OBJ_LEN
CONTENT_ID = L_CONTENT_ID
ENDLOOP.
DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
P_SUBJECT TYPE SO_OBJ_DES,
LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
TRY.
CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
EXPORTING
I_SUBJECT = P_SUBJECT
I_LANGUAGE = SY-LANGU
I_IMPORTANCE = '5'
I_SENSITIVITY = 'F'
I_MULTIREL_SERVICE = LO_MIME_HELPER
RECEIVING
RESULT = LO_DOC_BCS
CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
CATCH CX_GBT_MIME INTO LV_GBT_MIME.
ENDTRY.
RECEIVERS
DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
RECEIVER TYPE SOMLRECI1,
L_MAIL_ADDRESS TYPE AD_SMTPADR,
LO_BCS TYPE REF TO CL_BCS,
LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
L_USERNAME TYPE UNAME,
SEND_PARTNER TYPE BU_PARTNER,
LI_SENDER TYPE REF TO IF_SENDER_BCS,
LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
LV_SENT_TO_ALL TYPE BOOLEAN.
CLEAR RECEIVER.
RECEIVER-RECEIVER = '[email protected]'.
RECEIVER-REC_TYPE = 'U'.
RECEIVER-COM_TYPE = 'INT'.
APPEND RECEIVER TO P_RECEIVERS.
L_USERNAME = SY-UNAME.
CLEAR RECEIVER.
LOOP AT P_RECEIVERS INTO RECEIVER.
L_MAIL_ADDRESS = RECEIVER-RECEIVER.
TRY.
CALL METHOD CL_BCS=>CREATE_PERSISTENT
RECEIVING
RESULT = LO_BCS
CALL METHOD LO_BCS->SET_DOCUMENT
EXPORTING
I_DOCUMENT = LO_DOC_BCS
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
CREATE SENDER
CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
TRY.
IF L_USERNAME NS '@'.
L_USERNAME = SEND_PARTNER.
TRANSLATE L_USERNAME TO UPPER CASE.
LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
ELSE.
DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
L_FROM_MAIL_ADDRESS = L_USERNAME.
LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
ENDIF.
CALL METHOD LO_BCS->SET_SENDER
EXPORTING
I_SENDER = LI_SENDER
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
create recepient
data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
TRY.
CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
EXPORTING
I_ADDRESS_STRING = L_MAIL_ADDRESS
I_ADDRESS_NAME =
I_INCL_SAPUSER =
RECEIVING
RESULT = LO_RECEPIENT
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
ENDTRY.
TRY.
CALL METHOD LO_BCS->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = LO_RECEPIENT
I_EXPRESS =
I_COPY =
I_BLIND_COPY =
I_NO_FORWARD =
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
SEND EMAIL DOCUMENT
TRY.
CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
EXPORTING
I_REQUESTED_STATUS = 'N'
TRY.
CALL METHOD LO_BCS->SEND
EXPORTING
I_WITH_ERROR_SCREEN = SPACE
RECEIVING
RESULT = LV_SENT_TO_ALL
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
ENDTRY.
ENDLOOP.
COMMIT WORK. -
Smartforms: How to CC email & Include a few lines of Text in Body of email?
I have created a smartform and have it outputting PDf documents and sending then via e-mail and it all works great. Except u2026 now I would like to CC someone and also have a few lines of text in the e-mail. Does anyone have any ideas?
Here is my code:
IF p_mail = 'X'.
wa_ctrlop-device = 'MAIL'.
PERFORM mail_recipient_object.
PERFORM mail_sender_object.
PERFORM mail_appl_object CHANGING g_mail_app_obj.
ENDIF.
LOOP AT my_table.
CONCATENATE 'ECS' comp_year izhr_emp_comp_summary-emp_lname INTO wa_outopt-tdtitle separated by space.
CALL FUNCTION func_mod_name
EXPORTING
CONTROL_PARAMETERS = wa_ctrlop
MAIL_APPL_OBJ = g_mail_app_obj
MAIL_RECIPIENT = email_recipient
MAIL_SENDER = email_sender
OUTPUT_OPTIONS = wa_outopt
USER_SETTINGS = u2018Xu2019
IMPORTING
DOCUMENT_OUTPUT_INFO = document_output_info
JOB_OUTPUT_INFO = t_otfdata
TABLES
I_MYTABLE = imy_table
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
ENDLOOP.
Determines the Recipent of the E-Mail
FORM mail_recipient_object.
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_mailaddr = email_address "E-mail Addr:Input Screen
ip_type_id = 'U' "Internet Address
IMPORTING
ep_recipient_id = email_recipient "Recipient Obj Key
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e531(0u) WITH text-003. "Error E-Mailing
ENDIF.
ENDFORM. "mail_recipient_object.
*Sender of E-mail
FORM mail_sender_object.
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname "User Logged in
IMPORTING
ep_sender_id = email_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e531(0u) WITH text-e15. "Error E-Mailing
ENDIF.
ENDFORM. "mail_sender_object.
*Creates Mail Application Object to E-Mail Smartform
FORM mail_appl_object CHANGING g_mail_app_obj.
SELECT SINGLE * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
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
sap_name_not_exist = 4
OTHERS = 5.
ENDIF.
CLEAR sofmfol_key.
sofmfol_key-type = 'FOL'.
sofmfol_key-year = soud-inbyr.
sofmfol_key-number = soud-inbno.
bor_key = sofmfol_key.
IF NOT bor_key IS INITIAL.
swc_create_object folder 'SOFMFOL' bor_key.
IF sy-subrc = 0.
swc_object_to_persistent folder g_mail_app_obj.
IF sy-subrc NE 0.
CLEAR g_mail_app_obj.
ENDIF.
ENDIF.
ELSE.
CLEAR g_mail_app_obj.
ENDIF.
ENDFORM. "mail_appl_object.Get rid of the smartform-based mail sending code if you can. That interface is quite old, simplistic, and inflexible (i.e., you can't do what you're asking). I would use class CL_BCS. It's especially much easier once you have developed a (custom) standard email wrapper class for sending various types of emails, including smartform-based PDF-attached emails. You can even go with HTML and dress-up your emails a bit.
-
I am trying to email my smartform output to a specified email address, but I am getting an error messege as mail could not me send as in the function module 'SO_NEW_DOCUMENT_SEND_API1'
Below is the code. The smartform contains a logo only.
Pls see the code and tell me what isn that I am missing!
*& Report ZKHA_SMARTFORM
REPORT zkha_smartform.
TYPE-POOLS: slis,
abap.
DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
END OF it_mara.
DATA: wa_ctrlop TYPE ssfctrlop, "Smart Forms: Control structure
wa_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer)
t_otfdata TYPE ssfcrescl, "Smart Forms: Return value at end of form Printing
t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE, "#EC *
t_otf TYPE itcoo OCCURS 100 WITH HEADER LINE,"#EC * "itcoo is OTF Struct
w_filesize TYPE i, "#EC *
w_bin_filesize TYPE i, "#EC NEEDED
fm_name TYPE rs38l_fnam.
DATA : fullpath TYPE string, "#EC *
filename TYPE string, "#EC *
path TYPE string, "#EC *
user_action TYPE i, "#EC *
encoding TYPE abap_encoding. "#EC *
PARAMETERS: p_file TYPE rlgrap-filename NO-DISPLAY.
DATA: numbytes TYPE i,
cancel.
*wa_outopt-tddest = ' '.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
*wa_outopt-tdnoprev = 'X'.
*wa_outopt-tdnoprint = 'X'. " CHANGED HERE
*wa_ctrlop-device = 'MAIL'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_KHATEST1'
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.
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = wa_ctrlop " CHANGED HERE
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = wa_outopt " CHANGED HERE
user_settings = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otfdata
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.
*CASE sy-ucomm.
WHEN 'PRNT'. " ADDED HERE
t_otf[] = t_otfdata-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
bin_filesize = w_bin_filesize
BIN_FILE =
TABLES
otf = t_otf
lines = t_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
Data: t_objbin type standard table of SOLISTI1 with header line.
Converted to length of 255 Char
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
LINE_WIDTH_SRC =
LINE_WIDTH_DST = '255'
TRANSFER_BIN = ' '
TABLES
content_in = t_pdf_tab
content_out = t_objbin
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM download_w_ext(rstxpdft) TABLES t_pdf_tab
USING p_file
'.pdf'
'BIN'
numbytes
cancel. "#EC *
CLEAR: wa_outopt, wa_ctrlop.
*ENDCASE.
DATA:
t_tline TYPE TABLE OF tline,
t_reclist TYPE TABLE OF somlreci1,
wa_doc_chng TYPE sodocchgi1,
wa_reclist TYPE somlreci1,
wa_return TYPE ssfcrescl,
v_descr TYPE so_obj_des,
v_mailid TYPE ad_smtpadr,
v_adrnr TYPE ad_addrnum ,
v_len_in TYPE string.
wa_doc_chng-obj_name = 'SMARTFORM'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = v_descr.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-obj_langu = sy-langu.
wa_doc_chng-no_change = 'X' .
Selecting email address depending on
address no.from ADR6 Table
SELECT smtp_addr "E-Mail Address
FROM adr6 UP TO 1 ROWS
INTO v_mailid
WHERE addrnumber = v_adrnr.
ENDSELECT .
wa_reclist-receiver = v_mailid.
wa_reclist-receiver = '[email protected]'.
" I have hard coded the mail address. It is automatically populating the adr6 table, I donno why???
Pls give immediate resolution!!!!
wa_reclist-rec_type = 'U'.
APPEND wa_reclist TO t_reclist.
break-point.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
DOCUMENT_TYPE = 'PDF'
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
OBJECT_HEADER =
OBJECT_CONTENT = t_objbin
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = t_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Use the following steps for doing the same. These steps are tested succesfully.
1. Get the Function Module Name for the Smart form
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_fmname
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = w_fmname
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
2. Set the values to be passed in the Function Module to get the output of the Smart form in OTF format.
Set the call for OTF format.
t_control_parameters-no_dialog = c_x.
t_control_parameters-getotf = c_x.
3. Call the function Module for the smartform.
CALL FUNCTION w_fmname
EXPORTING
ARCHIVE_INDEX = H_ARCHIVE_INDEX
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS = H_ARCHIVE_PARAMS
CONTROL_PARAMETERS = t_control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
Variable = v_flag
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = w_job_output_info
JOB_OUTPUT_OPTIONS =
TABLES
I_table = t_itab
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
4. Convert the OTF format to PDF format using the w_job_output_info-otfdata
DATA: l_filesize TYPE i,
t_lines LIKE tline OCCURS 0,
t_objbin TYPE ty_tab_objbin.
**/ Get the PDF version of the OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = l_filesize
bin_file = bin_file
TABLES
otf = w_job_output_info-otfdata
lines = t_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
5. Convert the PDF format to format required for attachment.
**/ Convert the PDF format to the table type required for the attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = t_lines
t_target_tab = t_objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
6. Create the document to be sent by e-mail
Creation of the document to be sent
File Name: Name of the file to be attached
w_doc_chng-obj_name = Flename.
Mail Subject
w_doc_chng-obj_descr = Test E-mail(em1).
Completing the recipient list
t_reclist-receiver = t_rec. e-mail id of the recipient
t_reclist-rec_type = 'U'.
APPEND t_reclist.
Mail Contents
t_objtxt = 'Line 1'(bd1).
APPEND t_objtxt.
CLEAR t_objtxt.
APPEND t_objtxt. " to put in a blank line
t_objtxt = 'Line 2'(bd2).
APPEND t_objtxt.
CLEAR t_objtxt.
t_objtxt = Line 3'(bd3).
APPEND t_objtxt.
CLEAR t_objtxt.
APPEND t_objtxt. " to put in a blank line
t_objtxt = Line 4(bd3).
APPEND t_objtxt.
Calculate email size in bytes
DESCRIBE TABLE t_objtxt LINES w_tab_lines.
READ TABLE t_objtxt INDEX w_tab_lines.
w_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( t_objtxt ).
Creation of the entry for the compressed document
for the email text
CLEAR t_objpack-transf_bin.
t_objpack-head_start = 1.
t_objpack-head_num = 0.
t_objpack-body_start = 1.
t_objpack-body_num = w_tab_lines.
t_objpack-doc_type = 'RAW'.
APPEND t_objpack.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
DESCRIBE TABLE p_objbin LINES w_tab_lines.
t_objhead = Fielname.PDF'(em5).
APPEND t_objhead.
CLEAR t_objpack.
**/ Creation of the entry for the compressed/attached document
t_objpack-transf_bin = c_x.
t_objpack-head_start = 1.
t_objpack-head_num = 1.
t_objpack-body_start = 1.
t_objpack-body_num = w_tab_lines.
t_objpack-doc_type = 'PDF'.
t_objpack-obj_name = 'Possibly hover name'.
t_objpack-obj_descr = Mail Description'(em6).
t_objpack-doc_size = w_tab_lines * 255.
APPEND t_objpack.
7. Send the document by e-mail
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = c_x
TABLES
packing_list = t_objpack
object_header = t_objhead
contents_bin = t_objbin
contents_txt = t_objtxt
receivers = t_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
WRITE: / text-014, sy-subrc.
ELSE.
WRITE: / text-015.
ENDIF.
8. Commit work: this step is important to send the email to transaction SOST.
Once the email has reached the transaction SOST then its the job of the basis to do the configuration to send it to the specified e-mail id by internet.
**commit work for the email to go into transaction SOST.
COMMIT WORK.
9. In transaction SOST the mail will appear. -
Emailed Smartform Not Producing a Spool ID
Hi,
I'm trying to create a spool ID when I email my smartform. The emailing works but when I call the smartform function module the table JOB_OUTPUT_INFO-SPOOLIDS isn't being populated.
I'm passing the following parameters to my smartform:
OUTPUT_OPTIONS-TDNOPREV = 'X'.
OUTPUT_OPTIONS-TDNEWID = 'X'.
OUTPUT_OPTIONS-TDIMMED = 'X'.
CONTROL_PARAMETERS-NO_DIALOG = 'X'.
CONTROL_PARAMETERS-GETOTF = 'X'.
Can you tell me what I'm doing wrong?
Thanks,
GillHi Gill,
I guess when calling the function module of the Smartform from your print program you set parameter CONTROL_PARAMETERS-DEVICE = 'MAIL'. In this case the smartform is converted to a PDF mail attachment. usually a different setting is used in the application for printing so different parameters are used to call the smartforms function module.
You could acticate the SAVE_OTF_SPOOL option via report RSTXPDF3 but this is only recomended for a short period for testing as per SAP note 924752.
Regards,
Aidan -
Error while sending PO email as PO is in smartform
As my PO is in smartform so when I am sendin the email of PO using SAP standard Program 'SAPFM06P', FORM routine ENTRY_NEU' the processing routines,system is giving the error to open PO form.
So is there any way to send the email of smartform.
Thanks in advanceHi
I think some basis related configuartions to be done
Try like this and inform me
A cyclic job runs, which processes the messages seen in the SOST queue.
Are you sure it's not the frequency of the cyclic job, rather than the
number of messages in the queue, that you are observing? In messages
that are queued and before the cyclic job runs, "wait for comm. service"
is the normal status.
If you mean that there are always 4 items queued in SOST regardless of
the cyclic send job, then I have no ideas. I would have thought there
was no way to do that.
when the send job runs it just never
picks them up & sends them, while it picks up many others. The send job
is somehow blind to these; no error message occurs. In this case, I
'delete' them from the queue (in SOST) and then 'undelete' (drop down
menu -> /Go to /Deleted Items) them and then re-queue them. THEN they
actually get picked up & sent when the next cyclic send job executes.
Regards
Pavan -
Hi All,
I have a requirement to email one smartform as a PDF attachment, and another smartform in the body of a mail.
Currently, the settings in SCOT is that smartform will be sent out as PDF.
Can I know where and how I can manually code to make the smartform be sent in the body of a mail? Thks...
PS: Or could this be done by config through email action configuration?Sorry, let me rephrase. I saw the following post, and I was wondering where I could populate the TEXT document type as mentioned by Sharif. According to Sharif, it can be done, and according to the person who started the following thread, it seems that Sharif's way works.
Hope the above is clear
<i>Ramachandran Si...
Posts: 8
Questions: 2
Registered: 3/23/06
Forum points: 0
Doubt with usage of SMTP in actions ??
Posted: Sep 4, 2007 1:53 PM Reply E-mail this post
We have multiple actions configured in the system for outgoing email and the SMTP setting in SCOT is setup to be PDF's....How can i configure actions so that few of the outgoing emails can be TXT and others to be PDF's ?
Sharifuddin Ina...
Posts: 262
Questions: 0
Registered: 7/24/07
Forum points: 568
Re: Doubt with usage of SMTP in actions ??
Posted: Sep 4, 2007 5:49 PM in response to: Ramachandran Si... Reply E-mail this post
Hi,
This can be achieved by copying the Action Class to a Z class and modify the Method used by the action.
In this mthod you pass the Document Type as TEXT to the FM that sends the EMAIL.
i hope this works
Kindly reward with points in case helpful
Sharif
Ramachandran Si...
Posts: 8
Questions: 2
Registered: 3/23/06
Forum points: 0
Re: Doubt with usage of SMTP in actions ??
Posted: Sep 12, 2007 11:26 AM in response to: Sharifuddin Ina... Reply E-mail this post
This works , Thanks !
</i> -
I would like to be able to email a Smartform on a future date from ABAP code.
I have all the code working to call the Smartform and email it immediately.
I need to know how to set the "Do Not Send Before Date" & "Do Not Send Before Time" fields that are shown in tx SOST.
We are running a 4.7 system.
Any ideas would be great.I would like to be able to email a Smartform on a future date from ABAP code.
I have all the code working to call the Smartform and email it immediately.
I need to know how to set the "Do Not Send Before Date" & "Do Not Send Before Time" fields that are shown in tx SOST.
We are running a 4.7 system.
Any ideas would be great.
Maybe you are looking for
-
Help! Safari crashes when opening for one user on my macbook. Here is the error report: Date/Time: 2007-11-12 20:40:37.341 -0500 OS Version: 10.4.10 (Build 8R2218) Report Version: 4 Command: Safari Path: /Applications/Safari.app/Contents/MacOS/Safari
-
Changing default target namespace for a JPD
Hi, Is there a way in Workshop 8.1 to change the target namespace used when a WSDL is generated from a JPD? Currently, Workshop uses http://www.openuri.org. I have tried to use the @common:target-namespace annotation in my JPD, but that appears to on
-
Use the Project Bin in the Edit workspace
This question was posted in response to the following article: http://help.adobe.com/en_US/photoshopelements/using/WS287f927bd30d4b1f626a494c12e28b3ab58- 7fed.html
-
Computer crashed, must reinstall photoshop 12
must reinstall photoshop 12 on new hardrive
-
Connection pooling - where to start
I'm starting to learn about connection pooling but I am unsure of how it can be used to in the web server environment. Are connection pools just static classes placed in a global environment for all webapps to use? What is the best approach for creat