Sending Output to MS word
Hello all
I am planning to write a program that send the out put displayed on webdynpro view to a MS word document.So I request you if you have any plans to solve my problems or any helpfull URLs. Thank you for your time in advance
Regards
Maruti
hi maruti try this It will solve your prob.
create a single view with Text area,a button and a LinkTOUrl UI element. Write the following code on click of button. and set the refrence property of LinktoUrl equals to Url.
Note : Here Doc and Url are the value attribute of string type.
public void onActionConvert(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionConvert(ServerEvent)
final String formattedStr = wdContext.currentContextElement().getDoc();
try
final IWDCachedWebResource resource = WDWebResource.getWebResource
formattedStr.getBytes("UTF-8"), WDWebResourceType.DOC
resource.setResourceName("WordDoc.doc");
wdContext.currentContextElement().setUrl( resource.getAbsoluteURL() );
catch (final Exception ex)
wdComponentAPI.getMessageManager().reportException( new WDNonFatalException(ex), false );
//@@end
Regards
Jitender
Similar Messages
-
Function Module to send output list to mail.
Hi,
Could anyone let me know the function module to send output list to mail.
Regards,
RameshHi,
Please try with following sample code
Sending mail with attachment
This program will allowed you to send email with attachment.
First, specify the attachment file from your local hardisk and execute.
Next, specify the sender email address and click the send button.
report YUP_MAIL.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 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.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
Thanks,
-Pramod -
I cannot send a Pages document, Word via email if the doc contains a picture. If I email a Pages doc without a pic in Word format or pdf with a pic it with go through to sender? Not sure why Pages won't send Word doc with a picture in it. I check the security on the email recipient and the email doesn't get blocked or throw in the junk box?
thanks,
drainguy41If you have upgraded to Mountain Lion, Save As… has returned to the File menu when you hold down the Option/alt key. But you don't really "save" as other file types, you translate & export as Word or RTF or text or PDF & that is easily done by going to File > Export or Share > Export.
Also, please do us all a favor & don't use all capitals in your posts, either the body of the post or the title. All caps is the internet equivalent of shouting & is very hard to read. -
To send output of report to the mails ids as an excel attachment
Hi all,
I have a requirement that I have created a report using classes. Now I have to send output of my report to the particular mailids as an excel attachment.
Can anybody help me?
Regards,
Azra.Hi,
Refer Below links.
Re: Formatting Excel Attachment output in SO_DOCUMENT_SEND_API1
Information Broadcasting with Excel Report as attachment
Zip the excel and send as mail attachment
Regards
Md.MaahboobKhan -
I have Office 2011 which includes Word. Ever since downloading Mavericks, when I try to send a two-page Word document by email, some recipients get only one page. Also when burning an image from iPhoto (usually no larger than 1mb) on to a disc, only part of it appears. It appears to have been magnified so that only a part of the image appears. Can anyone enlighten me as to what is happening? And how to fix it??
I have Office 2011 which includes Word. Ever since downloading Mavericks, when I try to send a two-page Word document by email, some recipients get only one page. Also when burning an image from iPhoto (usually no larger than 1mb) on to a disc, only part of it appears. It appears to have been magnified so that only a part of the image appears. Can anyone enlighten me as to what is happening? And how to fix it??
-
Looking for a Dictation App for my Iphone and MacBook Pro.
Want to send all dictation to Word.
I have Dragon. Should I purchase Dragon Premium or Dragon for Mac?Care to share which OS you are using?
OS has its own dictation program.
Should I purchase Dragon Premium or Dragon for Mac?
Only you can make that determination. Read the system requirements for both and read the reviews. -
How to send output by mail?
Hi Experts,
Current output type in our system:
Document: SD delivey note
Output type: LD00
Medium: 1
Form: Smartforms.
Now we are printing delivery note by LD00 and Medium 1.
In the future, we need to send ducument output to customer by mail, format still as original smartforms.
Would you please give me a guide line to do this?
Thank you.
Richard.Hi Richard,
you need to do following things to send output as an email.
The output type should have medium 5. thats to send an email. Along with this you need to check following two things.
if you are using a copy of a standard program it should have code to send an email. Then you just need to configure following output type with medium '5' to send an email.
If you dont have code to send it as an email you can use FM to send it as an email.
you can use following FM if its an adobe form.
CALL FUNCTION 'SD_PDF_SEND_DATA'
EXPORTING
iv_device = p_w_device
iv_email_subject = w_lv_subject
it_email_text = w_mail_text
is_main_data = p_wa_fp_formoutput
iv_language = w_langu
is_address = w_ls_address
IMPORTING
ev_send_to_all = w_lv_send_to_all
EXCEPTIONS
exc_document = 1
exc_send_request = 2
exc_address = 3
OTHERS = 4.
Else for smart form you need to convert it to PDF format first and send it as an email. Refer below code.
Call Smartform function module.
CALL FUNCTION fm_name
EXPORTING
control_parameters = ssfctrlop
output_options = ssfcompop
IMPORTING
job_output_info = it_otf_data
TABLES
it_nfal = it_nfal.
***********appending the otf data into the final table*********************
it_otf_final[] = it_otf_data-otfdata[].
converting OTF data into pdf data**************************
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = bin_filesize
bin_file =
TABLES
otf = it_otf_final
lines = it_pdfdata[]
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
To send data as email attachment, we need to have a table of SOLISTI1.
This table contains line size of 255 characters. Below function module
does the trick of changing the table from X character sized lines into
any given Y character sized lines.
REFRESH it_pdf[].
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = '255'
TABLES
content_in = it_pdfdata[]
content_out = it_pdf[]
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.
ELSE.
"Subject of the mail.
w_document_data-obj_name = 'MAIL_TO_HEAD'.
w_document_data-obj_descr = 'Regarding Mail Program by SAP ABAP'.
"Body of the mail
w_body_msg = 'This is body of mail msg.'.
APPEND w_body_msg TO i_body_msg.
CLEAR w_body_msg.
"Write Packing List for Body
DESCRIBE TABLE i_body_msg LINES g_tab_lines.
w_packing_list-head_start = 1.
w_packing_list-head_num = 0.
w_packing_list-body_start = 1.
w_packing_list-body_num = g_tab_lines.
w_packing_list-doc_type = 'RAW'.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Write Packing List for Attachment
w_packing_list-transf_bin = 'X'.
w_packing_list-head_start = 1.
w_packing_list-head_num = 1.
w_packing_list-body_start = 1.
DESCRIBE TABLE it_pdf LINES w_packing_list-body_num.
w_packing_list-doc_type = 'PDF'.
w_packing_list-obj_descr = 'PDF Attachment'.
w_packing_list-obj_name = 'PDF_ATTACHMENT'.
w_packing_list-doc_size = w_packing_list-body_num * 255.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Fill the document data and get size of attachment
w_document_data-obj_langu = sy-langu.
READ TABLE it_pdf INTO w_pdf INDEX g_tab_lines.
w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).
"Receivers List.
w_receivers-rec_type = 'U'."Internet address
w_receivers-receiver = p_mail.
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
APPEND w_receivers TO i_receivers .
CLEAR:w_receivers.
"Function module to send mail to Recipients
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_document_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = g_sent_to_all
TABLES
packing_list = i_packing_list
contents_bin = it_pdf
contents_txt = i_body_msg
receivers = i_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 i303(me) WITH 'Mail has been Successfully Sent.'.
ENDIF.
ENDIF.
Edited by: Sumit Naik on Oct 13, 2010 11:20 PM -
Monitor CPU and send output to file
Hello
I want to monitor my CPU usage and my idea was this:
1. Use Top (/usr/bin/top –n 1|head –n 3| tail –n 1|awk ’{print $2}’)
2. Send output to file
3. crontab it
My problem is now that my top command (see above) works fine in terminal, it will give me a short and clean answer; 10.5%
But when sending this to a file the output looks more like: 10.5%^^8fewfwe[]€]]@£]@£[f9@£[]^^E^Efewfwef23 (Yes i just hit my keyboard but its alot of randoms characters)
How can i fix this?
Do you have any easier solution to monitor my CPU usage, i want it to be quite often, send cpu usage to file for at least every minute, then i can import this to excel and make nice diagram.
I dont want to install any extra program so ill have to work with whats there already. Im using RHEL 4.
Thanks in advance, JohanA better way to do it is using "sar"
man sarIt's already builtin and there are plenty of docs on the net.
kido -
How to send output of smartform in pdf format as an attachment to email
how to send output of smartform in pdf format as an attachment to email
search before posting further and follow Forum rules
Edited by: Vijay Babu Dudla on Jan 15, 2009 4:50 AMDid u check on sdn?
i dont think so or else there are many posts on this topic and good wikis too.
look at one of these code tutorial wiki
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/mail%2bsend%2bthrough%2boutput%2bcontrols
So next time do use the search functionality.
кu03B1ятu03B9к
Edited by: kartik tarla on Jan 15, 2009 12:33 PM -
SAP Output as MS word doc.
My requirement is to get the output as a MS word format ..
without using any third party toool? Can we really achieve it or not ?
What we propsed is a solution is to get the output to a PDF file then to use
the PDF to word converter which cost them some amount but they were not satisfied to that .
they need the output directly from SAP .
Can we do this in SAP or not ?>> NO experts are replying for this Question ....
Hm... I don't think you will get very far with comments like this
But anyway...
I don't think there is a way to convert any output to MS Word format natively using only ABAP. It is possible using OLE but that requires MS Word to be installed on the workstation, plus due to OLE, this doesn't work in programs running in the background.
The situation is similar to generating an Excel spreadsheet (and now I'm not talking about DAT and tab delimited format but real native Excel output). It is also not possible without involving OLE or some other third party tool as far as I'm aware.
I'm sure there is a reason for this - probably related to licensing or something like that.
It'd be certainly nice to have a way to create .DOC or .XLS files natively from ABAP... just nobody developed it yet -
Converting spool output to MS Word format
Is there any way to convert the SAP Script output to MS word format (like how we convert it into PDF) ?
Regards,
DinuHi,
Try with fm CONVERT_TEXT, you may go thro' the following link,
http://help.sap.com/saphelp_erp2004/helpdata/en/d6/0dba8f494511d182b70000e829fbfe/frameset.htm
Hope this helps,
Rgds, -
Urgent :- Sending output to SAP User's inbox as Excel Attachment.
Hi,
This is urgent requirement
Requirement Description in breif :-
1.I have a report and but when run in background, it should create an excel file and should be sent as attachment to sap inbox of the same user who is executing the report.
2.I have tried all most all function modules. the limitations were some of the F.M are not supported in background mode (which the sap it self uses) And I could able to send data to excel excel file only upto 255 chars per record. i.e these F.M's are allowing me to send a internal table but every record of 255 chars only.
3.Which is not sufficient to send my ITAB contents. and contents after 255 are truncating.
Sending output of report in Excel Format ,in BackgroundHi srinivas,
check this thread
Convert output display to Excel file and Email to a set of users
Regards,
Raj -
Urgent ...how to send output of sap through mail
Could you please guide me how to send output of SAP Script through mail in PDF format.
Thanks in Advance....
Regards,
Kumar.*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver,
p_sender LIKE somlreci1-receiver,
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
regards,
venkat -
Send output of smartforms by mail to a specified e-mail adress.
Dear all ,
How can I send output of smartforms to purchase order pdf format and send this pdf file to a specified e-mail address.
Best regards,
Merryzhang for the pdf you need to put the code as given below..........:-) .This include the complete sequence.
Converting the Smartform into PDF Format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = C_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
ERR_BAD_OTF = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE 'Error in CONVERT_OTF'(049) TYPE C_MSGTYPE_I.
ENDIF.
Convert PDF from 132 to 255.
LOOP AT I_TLINE INTO W_TLINE.
TRANSLATE W_TLINE USING ' ~'.
CONCATENATE W_BUFFER W_TLINE INTO W_BUFFER.
APPEND W_BUFFER TO I_BUFFER.
ENDLOOP.
LOOP AT I_BUFFER INTO W_BUFFER.
TRANSLATE W_BUFFER USING '~'.
DO.
W_RECORDS = W_BUFFER.
APPEND W_RECORDS TO I_RECORD.
SHIFT W_BUFFER LEFT BY 255 PLACES.
IF W_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
Object with PDF.
I_OBJBIN[] = I_RECORD[].
Content of the email.
W_OBJTXT-LINE = 'Smartform_output is attched'(020).
APPEND W_OBJTXT TO I_OBJTXT.
*I_OBJTXT[] = I_RECORDS[].
DESCRIBE TABLE I_OBJTXT LINES V_LINES_BIN.
Document Data
CLEAR W_DOC_CHNG.
W_DOC_CHNG-OBJ_NAME = 'ZSAS_TRAVAGREE'.
W_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
W_DOC_CHNG-OBJ_DESCR = 'Form for Travel Agreement'(021).
W_DOC_CHNG-PRIORITY = C_HIGH_1.
W_DOC_CHNG-DOC_SIZE = V_LINES_BIN * 255.
Pack to main body as RAW.
Obj. to be transported not in binary form
Start line of object header in transport packet
CLEAR W_OBJPACK.
REFRESH I_OBJPACK.
I_OBJPACK-HEAD_START = 1.
Number of lines of an object header in object packet
I_OBJPACK-HEAD_NUM = 0.
Start line of object contents in an object packet
I_OBJPACK-BODY_START = 1.
Number of lines of the object contents in an object packet
I_OBJPACK-BODY_NUM = V_LINES_TXT.
Code for document class
I_OBJPACK-DOC_TYPE = 'RAW'.
CLEAR I_OBJPACK-TRANSF_BIN.
APPEND I_OBJPACK.
To specify the mail content and subject.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
Packing as PDF.
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'ZSAS_TRAVAGREE'.
I_OBJPACK-OBJ_DESCR = 'Form for Travel Agreement'(021).
APPEND I_OBJPACK.
Document information.
REFRESH I_RECLIST.
e-mail receivers.
W_RECVLIST-RECEIVER = G_MAIL_ID.
W_RECVLIST-EXPRESS = C_X.
W_RECVLIST-REC_TYPE = C_EXTERNAL_EMAIL. "Internet address
APPEND W_RECVLIST TO I_RECLIST.
REFRESH I_OBJHEAD.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_CHNG
PUT_IN_OUTBOX = C_X
COMMIT_WORK = C_X
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = W_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.
ENDIF.
let me know if you wanna any help ....
Edited by: varghese oommen on Apr 29, 2009 10:16 AM -
Capturing the output of a jsp page and save that output in a WORD .doc file
Hi,
This is Naveen. I got stuck up with a problem/doubt. URGENT ! URGENT !
My doubt is how to capture the output of a jsp page(the content is dynamic generated) and save that output to a MS-Word doc file.
I know that therez an option of using Servlets Filters, but this concept is supported by Servlet 2.3 spec. and not earlier. And we are working on previous spec. and our web-servers also supports the prev. version and not the 2.3 version.
If incase, therez a third-party utility for free usage, suggestions are appreciated.
Hope most of them came across this kind of functional requirement. If anyone of them succeeded in this, please express ur bitter experience if any, faced during the coding.
Thanks in Advance for help.
NaveenYou can set the MIME content type as .doc and try to open the Page.
res.setContentType("application/vnd.ms-excel"); to generate the Page output as Excel
res.setContentType("application/vnd.ms-word"); to generate the Page output as MS Word doc
Hope this helps..
Maybe you are looking for
-
I have a lock on my screen and cant log in
I have an A1278 MacBook Pro. I had to replace the hard drive and decided to order one off of ebay. I am trying to get back into my computer with my new hard drive so that I can load from my factory disk, but it is going to a gray screen with a flas
-
I have a mac pro with lion os 10.7.4 and itunes 10.6.1, there is update for itunes and when i want to install it as upgrdae im getting an error and it is not installing and that cuases some problems in syncronizing with othe equipments.
-
Unable to carry out storage migration in VMM
Hi, I am trying to carry out storage migration using VMM but I get the following error message: VMM cannot complete the host operation on the HV01-LN1.vm.prod server because of the error: 'sps01.dev' failed to remove checkpoint. (Virtual machine ID A
-
Best & Quickest way to record AV from the iChat on a MB...
I am trying to sell my police department on the use of MacBook's... One feature that I think would be great is the ability to record audio and the video from the iSight... Basically if we have a victim on an incident scene we can quickly and easily r
-
Looking for a new file manager
Im currently using the Fvwm window manager with nautilus. I love the convenience of nautilus but you half to install half of gnome to get it working which sucks. Id apreciate it if people would post any suggestions as an alternative. Thanks!