Sending output to a JTextArea
ok so i have a muntithread program which is working exactly as it should except for one thing. The output isnt reaching the JTextArea
here is my code:
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import java.awt.*;
import javax.swing.*;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.Graphics;
import java.util.Scanner;
import javax.swing.JTextArea.*;
public class TaskThreadDemo extends JFrame{
TaskThreadDemo(){
outputPanel p1 = new outputPanel();
setLayout(new FlowLayout());
add(p1);
public static void main(String[] args) {
// Create tasks
Runnable printA = new PrintChar('a', 100);
Runnable printB = new PrintChar('b', 100);
Runnable print100 = new PrintNum(100);
// Create threads
Thread thread1 = new Thread(printA);
Thread thread2 = new Thread(printB);
Thread thread3 = new Thread(print100);
// Start threads
thread1.start();
thread2.start();
thread3.start();
TaskThreadDemo frame = new TaskThreadDemo();
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("lab9");
frame.setVisible(true);
frame.setSize(500,500);
class Output{
char input1;
int input2;
String out;
Output(){
public Output(char text, int n)
this.input1 = text;
this.input2 = n;
public void setOutput(char text, int n){
String internal = " ";
if (text != '\\')
internal = Character.toString(text);
out +=internal;
internal = " ";
if (n != 0)
internal = Integer.toString(n);
out += internal;
internal = " ";
this.out = out;
System.out.println(text + n);//used for checking output at this point
public String getOutput(){
System.out.println(out);//used for checking output at this point
return out;
class outputPanel extends JPanel{
Output outtext = new Output();
String text = outtext.getOutput();
outputPanel()
System.out.println(text);
JTextArea jtaOutput = new JTextArea(text,10,20);
jtaOutput.setLineWrap(true);
jtaOutput.setWrapStyleWord(true);
jtaOutput.setEditable(false);
JScrollPane scrollPane = new JScrollPane(jtaOutput);
setLayout(new FlowLayout());
add(scrollPane);
// The task for printing a specified character in specified times
class PrintChar implements Runnable
Output output = new Output();
private char charToPrint; // The character to print
private int times; // The times to repeat
private static Lock lock = new ReentrantLock();
/** Construct a task with specified character and number of
* times to print the character
public PrintChar(char c, int t)
charToPrint = c;
times = t;
/** Override the run() method to tell the system
* what the task to perform
public void run()
lock.lock();
try{
Thread.sleep(100);
for (int i = 0; i < times; i++)
output.setOutput(charToPrint, 0);
System.out.print(charToPrint);//used for checking output at this level
catch (InterruptedException ex){
ex.printStackTrace();
finally
lock.unlock();
// The task class for printing number from 1 to n for a given n
class PrintNum implements Runnable
Output output = new Output();
private int lastNum;
private static Lock lock = new ReentrantLock();
/** Construct a task for printing 1, 2, ... i */
public PrintNum(int n)
lastNum = n;
/** Tell the thread how to run */
public void run()
lock.lock();
try{
for (int i = 1; i <= lastNum; i++)
output.setOutput('\\', i);
System.out.print(" " + i);//used for checking output at this point
finally{
lock.unlock();
}
rgfirefly24 wrote:
right it may be shorter and it may work. I'm not denying that fact.
and i <know> my code as it is doesnt work. But if you remove all the extra classes (output, outputPanel) and run it straight to system.out.print it does exactly what its sapposed to. Its the fact that i'm getting confused on how to send the data from the thread method run to the JTextArea. Well I can't say this any clearer I think. Take my code. Read it. Figure out why it works.
I mean you use a print stream to System.out.println and you know that works. So I created you a PrintStream that instead of outputting to the console outputs to a text area. But this isn't good enough? Why?
Especially in light of the fact that connecting the threads back to this text area is your admitted problem and I solved that. The outputstream class I wrote does exactly that.
But whatever if you don't want to go that route fine. For the love of all though it's been mentioned a few times that your code cannot possibly work. Why? Because you never update the JTextArea. So I have no idea why you would think it would work. Your output stuff and method are useless. You update a String in them after a bunch of gyrations. Okay fine. Where is the part where you update the JTextArea?
You feel free to point out where in this code of yours you think the text area would get updated.
public void setOutput(char text, int n){
String internal = " ";
if (text != '\\')
internal = Character.toString(text);
out +=internal;
internal = " ";
if (n != 0)
internal = Integer.toString(n);
out += internal;
internal = " ";
this.out = out;
System.out.println(text + n);//used for checking output at this point
}
Similar Messages
-
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 -
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 -
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 -
Send output as PDF during background job
Dear
can you suggest how to send output of schedule job log in PDF as attachment insted of HTML.
If i schedule any job & set spool receiption, then spool log is sent as html attachment,
but i want to send it as pdf is there is any way to change defalult attachment type.
In addition to it can i set message text during scheduling job, or can i insert message text in body along with
attachment. So that i can type desired message in Body, any standard template is available to change its text.
regards
PranavAnswer on the first question:
trxn SCOT
double click the INT node that sends your mail out
suported adres typs: internet click on SET
There you have 3 report types: set these to PDF. ( you can not set BO/Link to pdf)
I have to admit i have never tested, so let us know if this works !
Answer on the second question:
Not really ( AFAIK) , you can modify the header line of the message (and spool) via:
SM36 , shedule the job, during every step you can click at the bottem on "print specifications", then properties
There you can modify Name and title.
Maybe a cover page could fit your needs partially?
http://help.sap.com/saphelp_nw70/helpdata/en/d9/4a951b51ea11d189570000e829fbbd/frameset.htm -
Problem with the External send output for Portugal in Smartforms
Hello All,
I am facing an issue with a particular outtype for external send for portugal country.The print priview is of different font than original font of the form.
But When the same output type is assigned with the print output the form is showing the font with the original fonts of the form.
can any one suggest the solution for this?Hello ,
Actually the same external send output type is working fine in the development system.This is having issue only in quality system.
And the condition records are maintained same in both dev system and quality system.
Does the capturing of Font play any Role...
I read some where that sometimes in translations a particular coutry might not hold the fonts.
Regards,
Varun -
Redirecting cmd output to a JTextArea
can anyone help me, im curious how can the compilers for java e.g.: Netbeans, JCreator, redirect the command promt output to a JTextArea..
can anyone guide me on what class to look at??
thanks a lothere is a simple class that redirects the standard output to a file called a.txt. you have to look into the class java.class.System. and other i/o classes
import java.io.PrintStream;
public class A {
public A() {
public static void main(String[] args) throws Exception {
PrintStream fileOut = new PrintStream("a.txt");
System.setOut(fileOut);
for (int i = 0; i < 10; i++) {
System.out.println(i);
}for your case where output goes to a textArea you might wanna use a multithreaded solution. redirect your output to a file as above and use the thread to read the file and paste text into your text area. there is other better solution that directly passes data into the textArea. i'll post it if can find it in my code base. -
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 -
Script spol to mail , and report which sends output to spools
Hi All,
Please give me
script spol to mail , and report which sends output to spool.
thaks,
babuHi,
Check the below code:
scripts through email:
*& Report ZRICHA_OTF_PDF
report zricha_otf_pdf
message-id zz.
CONSTANTS *
constants : c_x(1) type c value 'X', " For constant value
c_otf(3) type c value 'OTF', " For format
c_u(1) type c value 'U'. " Mail Option
VARIABLES *
data : v_rqident type tsp01-rqident, " For Spool Number
v_rqclient type tsp01-rqclient, " For Client
v_rqo1name type tsp01-rqo1name, " For Object name
v_spool type tsp01-rqident, " For Spool Number
v_spool1 type tsp01-rqident. " For Spool Number
FLAGS *
data : f_spool type c.
INTERNAL TABLES *
Internal table for sending mails
data: it_pdf like tline occurs 10 with header line,
it_xi_pdf like tline occurs 0 with header line,
it_html like solisti1 occurs 0 with header line,
it_xi_temp like bapiqcmime occurs 0 with header line,
it_xi_mime(255) type c occurs 0 with header line.
For sending mail
data: it_objpack like sopcklsti1 occurs 2 with header line.
Internal table for Single List with Column Length 255
data : it_objbin like solisti1 occurs 10 with header line.
Internal table for Single List with Column Length 255
data : it_objtxt like solisti1 occurs 10 with header line.
Internal table for Structure of the API Recipient List
data : it_reclist like somlreci1 occurs 5 with header line.
Structure of the API Recipient List
data: x_doc_chng like sodocchgi1.
Internal table for storing the variants
data : begin of it_variant1 occurs 0,
variant like varid-variant,
end of it_variant1.
Internal table to store variants for the programs
data: it_variant2 like it_variant1 occurs 0 with header line.
Internal table for storing the selected values
data it_return type ddshretval occurs 0 with header line.
Internal table for storing the mail-ids
data : begin of it_mailid occurs 0,
kokrs like csks-kokrs,
kostl like csks-kostl,
datbi like csks-datbi,
telx1 like csks-telx1,
end of it_mailid.
Internal table for storing the mail-ids
data : it_mailid1 like it_mailid occurs 0 with header line.
SELECTION SCREEN *
data : v_char type char50.
selection-screen begin of block b1 with frame title text-001.
select-options: s_email for v_char no intervals
lower case
no-display.
select-options: s_email1 for v_char no intervals
lower case
no-display.
selection-screen end of block b1.
selection-screen begin of block a1 with frame title text-028.
selection-screen begin of line.
parameters : p_c1 as checkbox.
selection-screen comment 3(66) text-026 for field p_c1.
selection-screen end of line.
parameters : p_set like tsp1d-papart matchcode object zh_tsp1d.
selection-screen skip 1.
parameters : p_vara1 type rs38m-selset.
selection-screen end of block a1.
selection-screen begin of block a2 with frame title text-029.
selection-screen begin of line.
parameters : p_c2 as checkbox.
selection-screen comment 3(56) text-027 for field p_c1.
selection-screen end of line.
parameters : p_set1 like tsp1d-papart matchcode object zh_tsp1d.
selection-screen skip 1.
parameters : p_vara2 type rs38m-selset.
selection-screen end of block a2.
AT SELECTION SCREEN ON VALUE REQUEST
at selection-screen on value-request for p_vara1.
For fetching the variants available for the program
perform fetch_variants.
at selection-screen on value-request for p_vara2.
For fetching the variants available for the program
perform fetch_variants1.
AT SELECTION SCREEN
at selection-screen.
For Validation
perform validation.
START OF SELECTION *
start-of-selection.
To get the output data and mail
perform fetch_data.
END OF SELECTION *
end-of-selection.
if f_spool = c_x.
message e000 with 'Spool Not Generated'(060).
endif.
*& Form fetch_data
To get the output data and mail
form fetch_data .
To send the output to spool
perform generate_spool.
endform. " fetch_data
*& Form generate_spool
To send the output to spool
form generate_spool .
data: l_params like pri_params,
l_days(1) type n value 2,
l_count(3) type n value 1,
l_valid type c,
l_valid1 type c,
l_params1 like pri_params.
data: l_device type usr01-spld.
*Get the printer name for the user
select single spld into l_device from usr01 where bname = sy-uname.
if l_device is initial.
l_device = 'LOCL'.
endif.
For report-1
if p_c1 = 'X'.
Setting the print parameters
call function 'GET_PRINT_PARAMETERS'
exporting
destination = l_device
copies = l_count
list_name = sy-uname
list_text = 'SUBMIT ... TO SAP-SPOOL'(008)
release = c_x
new_list_id = c_x
expiration = l_days
LINE_SIZE = 255
LINE_COUNT = 65
layout = p_set
sap_cover_page = space
cover_page = space
receiver = 'SAP*'(010)
department = 'System'(011)
no_dialog = c_x
importing
out_parameters = l_params
valid = l_valid.
if l_valid <> space.
clear v_spool.
Fetch the spool number b4 submit
perform fetch_recent_spool using v_spool.
Submitting the program to spool
submit rkaep000 to sap-spool
using selection-set p_vara1
spool parameters l_params
without spool dynpro
and return.
clear v_spool1.
Fetch the spool number after submit
perform fetch_recent_spool using v_spool1.
if v_spool = v_spool1.
f_spool = c_x.
if p_c2 is initial.
stop.
endif.
else.
Checking the format ( ABAP/OTF)
perform format_check tables s_email.
endif.
else.
message e000 with 'Problem in print settings'(003).
stop.
endif.
endif.
For Report-2
if p_c2 = 'X'.
Setting the print parameters
call function 'GET_PRINT_PARAMETERS'
exporting
destination = l_device
copies = l_count
list_name = sy-uname
list_text = 'SUBMIT ... TO SAP-SPOOL'(008)
release = c_x
new_list_id = c_x
expiration = l_days
LINE_SIZE = 200
LINE_COUNT = 65
layout = p_set1
sap_cover_page = space
cover_page = space
receiver = 'SAP*'(010)
department = 'System'(011)
no_dialog = c_x
importing
out_parameters = l_params1
valid = l_valid1.
if l_valid1 <> space.
clear v_spool.
Fetch the spool number b4 submit
perform fetch_recent_spool using v_spool.
Submitting the program to spool
submit gp3diehxy88snfj0391v7kf9ek7050 to sap-spool
using selection-set p_vara2
spool parameters l_params1
without spool dynpro
and return.
clear v_spool1.
Fetch the spool number after submit
perform fetch_recent_spool using v_spool1.
if v_spool = v_spool1.
message e000 with 'Spool Not Generated'(060).
stop.
endif.
Checking the format ( ABAP/OTF)
perform format_check tables s_email1.
else.
message e000 with 'Problem in print settings'(003).
stop.
endif.
endif.
endform. " generate_spool
*& Form fetch_recent_spool
Fetch the recent spool number generated
form fetch_recent_spool using p_v_spool type tsp01-rqident .
data: l_user like tsp01-rq2name.
clear : v_rqident,
v_rqclient,
v_rqo1name.
l_user = sy-uname.
Get latest Spool No
select single rqident
rqclient
rqo1name
into (v_rqident , v_rqclient , v_rqo1name)
from tsp01
where rqcretime = ( select max( rqcretime )
from tsp01
where rq2name eq l_user
and rqfinal eq '.' ).
if sy-subrc = 0 .
p_v_spool = v_rqident.
endif.
endform. " fetch_recent_spool
*& Form format_check
Checking the format ( ABAP/OTF)
form format_check tables p_s_email structure s_email.
data : l_objtype like rststype-type.
call function 'RSTS_GET_ATTRIBUTES'
exporting
authority = 'SP01'(019)
client = v_rqclient
name = v_rqo1name
part = 1
importing
objtype = l_objtype
exceptions
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 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.
if l_objtype(3) = c_otf.
Convert OTF Spool to PDF
perform convert_otf2pdf tables p_s_email.
else.
Convert ABAP Spool to PDF
perform convert_abap2pdf tables p_s_email.
endif.
endform. " format_check
*& Form convert_otf2pdf
Convert OTF Spool to PDF
form convert_otf2pdf tables p_p_s_email structure s_email .
clear it_pdf.
refresh it_pdf.
data : l_bytecount type i.
Fn. to get the PDF format
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = v_rqident
no_dialog = 'X'
importing
pdf_bytecount = l_bytecount
tables
pdf = it_pdf
exceptions
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 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.
if sy-subrc = 0.
For page format
perform page_format tables p_p_s_email.
else.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " convert_otf2pdf
*& Form convert_abap2pdf
Convert ABAP Spool to PDF
form convert_abap2pdf tables p_p_s_email structure s_email.
clear it_pdf.
refresh it_pdf.
data : l_bytecount type i.
Fn. to convert to PDF format
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = v_rqident
no_dialog = 'X'
importing
pdf_bytecount = l_bytecount
tables
pdf = it_pdf
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.
if sy-subrc = 0.
For page formatting
perform page_format tables p_p_s_email.
else.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " convert_abap2pdf
*& Form send_mail
For sending mail
form send_mail tables mail structure s_email .
Structures and internal tables for the send data
data: objpack like sopcklsti1 occurs 2 with header line,
objhead like solisti1 occurs 1 with header line,
objbin like solisti1 occurs 0 with header line,
objtxt like solisti1 occurs 10 with header line,
reclist like somlreci1 occurs 5 with header line.
data: doc_chng like sodocchgi1,
tab_lines like sy-tabix.
Data for the status output after sending
data: sent_to_all like sonv-flag.
clear: it_reclist, it_reclist[],
it_objtxt , it_objtxt[],
it_objpack, it_objpack[],
it_objbin , it_objbin[],x_doc_chng.
loop at it_html.
objbin-line = it_html-line.
append objbin.
clear objbin.
endloop.
Create the document which is to be sent
doc_chng-obj_name = 'List'(012).
doc_chng-obj_descr = 'Mail'(013).
Heading
objtxt-line = 'Mail with pdf attachment'(014).
append objtxt.
clear objtxt.
Size
describe table objtxt lines tab_lines.
read table objtxt index tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
Fill the fields of the packing_list for the main document:
clear objpack-transf_bin.
The document needs no header (head_num = 0)
objpack-head_start = 1.
objpack-head_num = 0.
Body
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'(015).
append objpack.
Create the attachment (the list itself)
describe table objbin lines tab_lines.
Fill the fields of the packing_list for the attachment:
objpack-transf_bin = 'X'.
Header
objpack-head_start = 1.
objpack-head_num = 0.
Body
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'PDF'(016).
objpack-obj_name = 'Attachment'(017).
objpack-obj_descr = 'Mail with pdf Attachment'(018).
objpack-doc_size = tab_lines * 255.
append objpack.
*-Fill the mail recipient list
loop at mail.
reclist-receiver = mail-low.
reclist-rec_type = c_u.
append reclist.
clear: reclist,
mail.
endloop.
*-Send the document by calling the SAPoffice API1 module for sending
*-documents with attachments
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = doc_chng
put_in_outbox = c_x
commit_work = c_x
importing
sent_to_all = sent_to_all
tables
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
case sy-subrc .
when 0.
message i000 with 'Mail has been sent successfully'(006).
when others.
message e000 with 'Problem in sending the mail'(023).
endcase.
endform. " send_mail
*& Form page_format
For page foramtting
form page_format tables email structure s_email .
data : l_lines type i,
l_temp(500) type c,
l_offset type p,
l_lineslen(2) type p,
l_mimelen(2) type p,
l_tabix like sy-tabix.
clear : it_xi_pdf,
it_xi_temp.
refresh : it_xi_pdf,
it_xi_temp.
it_xi_pdf[] = it_pdf[].
Reformat the line to 255 characters wide (code from SAP)
clear: l_temp, l_offset, it_xi_temp.
describe table it_xi_pdf lines l_lines.
describe field it_xi_pdf length l_lineslen in character mode.
describe field it_xi_temp length l_mimelen in character mode.
loop at it_xi_pdf.
l_tabix = sy-tabix.
move it_xi_pdf to l_temp+l_offset.
if l_tabix = l_lines.
l_lineslen = strlen( it_xi_pdf ).
endif.
l_offset = l_offset + l_lineslen.
if l_offset ge l_mimelen.
clear it_xi_temp.
it_xi_temp = l_temp(l_mimelen).
append it_xi_temp.
shift l_temp by l_mimelen places.
l_offset = l_offset - l_mimelen.
endif.
if l_tabix = l_lines.
if l_offset gt 0.
clear it_xi_temp.
it_xi_temp = l_temp(l_offset).
append it_xi_temp.
endif.
endif.
endloop.
clear : it_xi_mime,
it_xi_mime[].
loop at it_xi_temp.
it_xi_mime(255) = it_xi_temp-line.
append it_xi_mime.
clear it_xi_mime.
endloop.
Final Data
clear : it_html,
it_html[].
it_html[] = it_xi_mime[].
For sending mail
perform send_mail tables email.
endform. " page_format
*& Form fetch_variants
For fetching the variants available for the program
form fetch_variants .
data : l_program like rs38m-programm value 'RKAEP000',
l_vara1 type dfies-fieldname value 'P_VARA1'.
clear : it_variant1,
it_variant1[].
Get variants
perform get_variants tables it_variant1
using l_program.
F4 Help
if not it_variant1[] is initial.
perform get_f4_help tables it_variant1
using l_vara1
changing p_vara1.
else.
message e000 with 'No variants available for report1'(054).
endif.
endform. " fetch_variants
*& Form validation
For Validation
form validation .
data : l_pro1 like rs38m-programm value 'RKAEP000',
l_pro2 like rs38m-programm value 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
l_c1,
l_c2.
If both check-box are unchecked
if p_c1 is initial
and p_c2 is initial.
message e000 with 'Check any one check-box'(049).
endif.
If checked without varaint
if not p_c1 is initial and p_vara1 is initial.
message e000 with 'Please give any one of the variant for report1'(055).
endif.
If checked without varaint
if not p_c2 is initial and p_vara2 is initial.
message e000 with 'Please give any one of the variant for report2'(061).
endif.
Reading the variant and fetching the mail-ids
if p_c1 = c_x.
l_c1 = '1'.
clear : s_email,
s_email[].
perform read_variants tables it_mailid
s_email
using p_vara1
l_pro1
l_c1.
if s_email[] is initial.
message e000 with 'No Id available for given Cost report1'(066).
else.
sort s_email by low.
delete adjacent duplicates from s_email comparing low.
endif.
endif.
Reading the variant and fetching the mail-ids
if p_c2 = c_x.
clear : s_email1,
s_email1[].
l_c2 = '2'.
perform read_variants tables it_mailid1
s_email1
using p_vara2
l_pro2
l_c2.
if s_email1[] is initial.
message e000 with 'No Id available for given Cost report2'(067).
else.
sort s_email1 by low.
delete adjacent duplicates from s_email1 comparing low.
endif.
endif.
endform. " validation
*& Form GET_VARIANTS
Fetching Variants
form get_variants tables p_it_variant structure it_variant1
using p_v_program type rs38m-programm.
select variant
from varid
into table p_it_variant
where report = p_v_program.
endform. " GET_VARIANTS
*& Form GET_F4_HELP
text
form get_f4_help tables p_it_variant1 structure it_variant1
using p_l_vara1 like dfies-fieldname
changing p_p_vara like p_vara1.
Fn. for Pop-Up
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = p_l_vara1
value_org = 'S'
display = ' '
tables
value_tab = p_it_variant1
return_tab = it_return
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc = 0.
p_p_vara = it_return-fieldval.
else.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " GET_F4_HELP
*& Form FETCH_VARIANTS1
text
form fetch_variants1 .
data : v_program1 like rs38m-programm value 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
l_vara2 type dfies-fieldname value 'P_VARA2'.
clear : it_variant2,
it_variant2[].
Get Variants
perform get_variants tables it_variant2
using v_program1.
F4 Help
if not it_variant2[] is initial.
perform get_f4_help tables it_variant2
using l_vara2
changing p_vara2.
else.
message e000 with 'No variants available for report2'(050).
endif.
endform. " FETCH_VARIANTS1
*& Form read_variants
Reading the variant and fetching the mail-ids
form read_variants tables p_it_mailid structure it_mailid
p_s_email structure s_email
using p_p_vara1 like p_vara1
p_l_pro1 like rs38m-programm
p_l_c1 type c.
data : l_temp(44),
it_valutab like rsparams occurs 0 with header line.
ranges : r_cocen for csks-kostl.
Function Module to get the variant contents
call function 'RS_VARIANT_CONTENTS'
exporting
report = p_l_pro1
variant = p_p_vara1
tables
valutab = it_valutab
exceptions
variant_non_existent = 1
variant_obsolete = 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.
clear : r_cocen,
r_cocen[].
loop at it_valutab where selname = 'KOSTL'
or selname = '_C-CCTR'.
Getting the range of cost centers
if it_valutab-option = 'BT'.
r_cocen-low = it_valutab-low.
For Conversion Routine
perform conversion using r_cocen-low.
r_cocen-high = it_valutab-high.
For Conversion Routine
perform conversion using r_cocen-high.
r_cocen-option = 'BT'.
r_cocen-sign = 'I'.
append r_cocen.
clear r_cocen.
endif.
Getting the single cost centers
if it_valutab-option = 'EQ'.
r_cocen-low = it_valutab-low.
For Conversion Routine
perform conversion using r_cocen-low.
r_cocen-option = 'EQ'.
r_cocen-sign = 'I'.
append r_cocen.
clear r_cocen.
endif.
endloop.
If no cost centers
if not r_cocen[] is initial.
select kokrs
kostl
datbi
telx1
from csks
into table p_it_mailid
where kostl in r_cocen.
if p_it_mailid[] is initial.
if p_l_c1 = '1'.
message e000 with 'No IDs available for report1'(059).
elseif p_l_c1 = '2'.
message e000 with 'No IDs available for report2'(062).
endif.
endif.
Deleting the blank entries
delete p_it_mailid where telx1 = space.
clear l_temp.
read table p_it_mailid index 1.
l_temp = p_it_mailid-telx1.
data : l_check.
loop at p_it_mailid where telx1 <> l_temp.
l_check = c_x.
endloop.
For checking the unique ids
if l_check = c_x.
if p_l_c1 = '1'.
message e000 with 'No unique mail-ids for report1'(058).
elseif p_l_c1 = '2'.
message e000 with 'No unique mail-ids for report2'(065).
endif.
endif.
Populating the IDs for the cost centers
loop at p_it_mailid.
set locale language sy-langu.
translate p_it_mailid-telx1 to lower case.
set locale language space .
concatenate p_it_mailid-telx1 '@allergan.com' into l_temp.
p_s_email-low = l_temp.
p_s_email-sign = 'I'.
p_s_email-option = 'EQ'.
append p_s_email.
clear p_s_email.
endloop.
else.
if p_l_c1 = '1'.
message e000 with 'No Cost Center Available for report1'(057).
elseif p_l_c1 = '2'.
message e000 with 'No Cost Center Available for report2'(063).
endif.
endif.
endform. " read_variants
*& Form CONVERSION
For Conversion Routine
form conversion using p_it_valutab_low type c.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = p_it_valutab_low
importing
output = p_it_valutab_low.
endform. " CONVERSION
REPORT Z_RMTIWARI_SEND_SPOOL_MAIL_ATT .
PARAMETERS : P_SPOOL TYPE TSP01-RQIDENT OBLIGATORY .
PARAMETERS : P_MAIL TYPE char100 OBLIGATORY .
TYPES : TY_LINE type string.
DATA: IT_ATTACHMENT TYPE soli OCCURS 0 WITH HEADER LINE.
DATA: IT_ATTACHMENT_LONG TYPE TY_LINE OCCURS 0 WITH HEADER LINE.
DATA: LV_PDF_SIZE type i.
DATA: LT_PDF type standard table of tline with header line.
PERFORM SEND_EMAIL USING P_SPOOL P_MAIL.
FORM send_email
--> X_SPOOL_ID
--> X_EMAIL
FORM send_email USING X_SPOOL_ID X_EMAIL.
DATA: LT_OBJPACK LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
LT_OBJHEAD LIKE solisti1 OCCURS 1 WITH HEADER LINE,
LT_OBJBIN LIKE solisti1 OCCURS 10 WITH HEADER LINE,
LT_OBJTXT LIKE solisti1 OCCURS 10 WITH HEADER LINE,
LT_RECLIST LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
LV_DOCUMENT_DATA TYPE sodocchgi1.
DATA: L_ATT_LINES TYPE i.
DATA : LV_SPOOL_DESC(68) type c.
CHECK NOT ( X_EMAIL IS INITIAL ).
CLEAR: LT_RECLIST, LT_RECLIST[],
LT_OBJHEAD, LT_OBJHEAD[],
LT_OBJTXT, LT_OBJTXT[],
LT_OBJBIN, LT_OBJBIN[],
LT_OBJPACK, LT_OBJPACK[].
CLEAR LV_DOCUMENT_DATA.
Read spool and get the pdf internal table and name of spool
PERFORM READ_SPOOL USING X_SPOOL_ID LV_SPOOL_DESC.
CHECK NOT ( LT_PDF[] IS INITIAL ).
Convert pdf itab to 255 line itab.
data :LV_COUNTER type i.
data :LV_FROM type i.
loop at LT_PDF.
translate LT_PDF using ' ~' .
concatenate IT_ATTACHMENT_LONG LT_PDF into it_attachment_long.
endloop.
translate IT_ATTACHMENT_LONG using '~ ' .
append IT_ATTACHMENT_LONG.
clear : LV_COUNTER.
DO.
LV_COUNTER = strlen( IT_ATTACHMENT_LONG ).
if LV_COUNTER ge 255.
IT_ATTACHMENT = IT_ATTACHMENT_LONG(255).
append IT_ATTACHMENT.
SHIFT IT_ATTACHMENT_LONG by 255 places.
else.
IT_ATTACHMENT = IT_ATTACHMENT_LONG(lv_counter).
append IT_ATTACHMENT.
exit.
endif.
ENDDO.
Body of email
MOVE 'Email sent to you from SAP' TO LT_OBJTXT.
APPEND LT_OBJTXT.
LV_DOCUMENT_DATA-obj_name = 'SpoolMail'.
Title of the email as spool name
LV_DOCUMENT_DATA-obj_descr = LV_SPOOL_DESC.
LV_DOCUMENT_DATA-sensitivty = 'O'.
LV_DOCUMENT_DATA-expiry_dat = SY-datum + 15.
LV_DOCUMENT_DATA-doc_size = STRLEN( LT_OBJTXT ).
e-mail body
CLEAR LT_OBJPACK.
LT_OBJPACK-head_start = 1.
LT_OBJPACK-head_num = 0.
LT_OBJPACK-body_start = 1.
LT_OBJPACK-body_num = 1.
LT_OBJPACK-doc_type = 'RAW'.
LT_OBJPACK-doc_size = STRLEN( LT_OBJTXT ).
APPEND LT_OBJPACK.
For e-mail attachment
DESCRIBE TABLE IT_ATTACHMENT LINES L_ATT_LINES.
READ TABLE IT_ATTACHMENT INDEX L_ATT_LINES.
CLEAR LT_OBJPACK.
LT_OBJPACK-transf_bin = 'X'.
LT_OBJPACK-head_start = 1.
LT_OBJPACK-head_num = 1.
LT_OBJPACK-body_start = 1.
LT_OBJPACK-body_num = L_ATT_LINES.
LT_OBJPACK-doc_type = 'PDF'.
LT_OBJPACK-obj_name = 'email'.
LT_OBJPACK-obj_descr = LV_SPOOL_DESC.
LT_OBJPACK-doc_size = ( 255 * ( L_ATT_LINES - 1 ) ) + STRLEN( IT_ATTACHMENT-line ).
APPEND LT_OBJPACK.
make recipient list
LT_RECLIST-receiver = X_EMAIL.
LT_RECLIST-rec_type = 'B'. "To external email id
APPEND LT_RECLIST.
send mail with attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = LV_DOCUMENT_DATA
put_in_outbox = 'X'
TABLES
packing_list = LT_OBJPACK
object_header = LT_OBJHEAD
contents_bin = IT_ATTACHMENT
contents_txt = LT_OBJTXT
receivers = LT_RECLIST
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
If SY-subrc = 0.
write:/ 'Message sent'.
else.
write:/ 'Error encountered'.
endif.
ENDFORM. " send_email
*& Form read_spool
FORM read_spool USING X_SPOOL_ID Y_SPOOL_DESC.
DATA : LV_SPOOL_TYPE TYPE TSP01-RQDOCTYPE.
SELECT SINGLE RQDOCTYPE RQTITLE
INTO (lv_spool_type, y_spool_desc)
FROM TSP01
WHERE RQIDENT eq X_SPOOL_ID.
IF Y_SPOOL_DESC IS INITIAL.
concatenate 'Spool-' X_SPOOL_ID into Y_SPOOL_DESC.
ENDIF.
IF LV_SPOOL_TYPE eq 'LIST'. " If spool is a list
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID -
Is there a way to send output from a Concurrent Request via email in r12?
We are looking for a way to send emails out from the Concurrent Request output in r12.
Discussions internally have involved using Unix procedures/commands but we were looking for an EBS integrated solution if one is available.
I did find document 811716.1which seems to provide a solution, but the patches and information given are for 11i (we are r12). If this functionality is available in r12, is there any further documentation we can use?
Any assistance would be appreciated.
Thanks.
Kevin
Edited by: user3065048 on Jul 21, 2009 2:52 PMDuplicate post.
Is there a way to send output from a Concurrent Request via email in r12?
Re: Is there a way to send output from a Concurrent Request via email in r12? -
REP-1885 Can't send output to the printer
I got the error: REP-1885 Can't send output to the printer
when trying to print a report from Live Previewer.
Report Builder: 6.0.8.19
Oracle 8.1.7.2
Any help is much appreciated.hello,
i'd try the latest patchset and if that does not help, contact oracle support services.
regards,
philipp
Maybe you are looking for
-
Ipod touch transfers memos as AAC files
Hi All, I have an iPhone 3G and a 2nd gen iPod Touch. Using voice memos and syncing them to iTunes, the iPhone syncs the memos as Apple Lossless files (what I have set as my default import setting) and the iPod Touch always imports it's memos as AAC
-
I got a call this morning from a friend saying she started her computer this morning (G5 PPC tower running 10.4.8) and although she was logged in as usual (her user name is correct) all her settings were gone, i.e. mail wanted to be set up, desktop w
-
Work Manager 6.1 New field - Read only
Hi, I'm attempting to add a new field for CATS time posting in Work Manager 6.1, when I add the field and run the WPF client the field is always rendered as read-only - I'm expecting it to be an input field. I've done the following Added a new proper
-
Need instructions on how to replace Ethernet port
My ethernet port died after a recent power surge. Does anyone know a helpful website that can walk me through replacing it? It's a flat panel 800 MHZ from about 5 years ago.
-
Question on SwingUtilities.invokeLater
The program I have included is attempting to "simulate" opening and loading a file into memory. Run the program, select File and then select Open. You will notice that the File menu does not disappear for 3 seconds (i.e. until the file has been compl