Swing worker question -- two lines performing a similar task concurrently

Hi,
I've been playing around with swingworker.
The code below has a window with two buttons and two text areas.
When you click a button, the text area will count out 10000 random numbers, and print "done." when it's finished.
Each of the buttons works when pressed separately (one is running while the other is idle) But I can't push one, then the other and have the tasks run independantly.
One stops and abruptly finishes while the other pauses.
Sorry to post a lot of code, I'm going through the tutorials, I've looked at the example from the tutorial pretty extensivley, but that is only running one task.
thanks.
bp
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.border.Border;
import javax.swing.BorderFactory;
import java.awt.Insets;
import javax.swing.*;
import javax.swing.SwingWorker;
public class TestGui2 extends JFrame{
      JButton button1;
      JButton button2;
      JTextArea tArea1;
      JTextArea tArea2;
      Border border;
      public void buildGui(){
            JPanel mainPanel = new JPanel();
            mainPanel.setLayout(new GridBagLayout());
            GridBagConstraints mpc = new GridBagConstraints();
            mpc.insets = new Insets(3, 10, 3, 10);
         border = BorderFactory.createLoweredBevelBorder();
            JLabel titleLabel = new JLabel("<html><h1><font face=\"Courier\">GridBagLayout Test Gui</font></h1></html>");
            mpc.weightx=0.5;
            mpc.fill = GridBagConstraints.CENTER;
            mpc.gridx=1;
            mpc.gridy=0;
            mainPanel.add(titleLabel, mpc);
            button1 = new JButton("run job1");
         button1.addActionListener(new Button1Listener());
            mpc.weightx=0.5;
            mpc.fill = GridBagConstraints.EAST;
            mpc.gridx=0;
            mpc.gridy=1;
            mainPanel.add(button1, mpc);
            tArea1 = new JTextArea("sample text");
         tArea1.setBorder(border);
            mpc.weightx=0.5;
            mpc.fill = GridBagConstraints.HORIZONTAL;
            mpc.gridx=1;
            mpc.gridy=1;
            mainPanel.add(tArea1, mpc);
            button2 = new JButton("run job2");
         button2.addActionListener(new Button2Listener());
            mpc.weightx=0.5;
            mpc.fill = GridBagConstraints.EAST;
            mpc.gridx=0;
            mpc.gridy=2;
            mainPanel.add(button2, mpc);
            tArea2 = new JTextArea("sample text");
         tArea2.setBorder(border);
            mpc.weightx=0.5;
            mpc.fill = GridBagConstraints.HORIZONTAL;
            mpc.gridx=1;
            mpc.gridy=2;
            mainPanel.add(tArea2, mpc);
            // frame settings
            add(mainPanel);
            setSize(700,450);
            setTitle("TestGui2");
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setVisible(true);
     // inner classes   
     class Button1Listener implements ActionListener{
          public void actionPerformed(ActionEvent e) {
          BigJobWorker worker = new BigJobWorker();
          worker.execute();
     class Button2Listener implements ActionListener{
          public void actionPerformed(ActionEvent e) {
               BigJobWorker2 worker2 = new BigJobWorker2();
               worker2.execute();
     //SwingWorker class
      class BigJobWorker2 extends SwingWorker<Void, Void>{
          protected Void doInBackground(){
               try{
                    for(int i=0; i<10000;i++){
                    int num2 = (int)(Math.random() * 100);
                    Integer integerNum2 = num2;
                    tArea2.setText("iteration: " + i + " " + integerNum2.toString());
                    //ReallyBigJob rbj = new ReallyBigJob();
                    //tArea1.setText(rbj.doBigJob().toString());
                    tArea2.setText("done.");
               } catch (Exception e3){
               e3.printStackTrace();
          return null;
     private class BigJobWorker extends SwingWorker<Void, Void>{
          protected Void doInBackground(){
               try{
                    for(int i=0; i<10000;i++){
                    int num = (int)(Math.random() * 100);
                    Integer integerNum = num;
                    tArea1.setText("iteration: " + i + " " + integerNum.toString());
                    //ReallyBigJob rbj = new ReallyBigJob();
                    //tArea1.setText(rbj.doBigJob().toString());
                    tArea1.setText("done.");
               } catch (Exception e2){
               e2.printStackTrace();
          return null;
      public static void main(String[] args) {
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                        TestGui2 test = new TestGui2();
                        test.buildGui();
BTW, I realize this code isn't as OOO as it could be (2 SwingWorker classes that do the same thing, 2 listeners that do the same thing) But I wanted to isoloate the problem first.
thanks.
Also, it's not impossible the program is working properly, it just finishes before the textArea can be updated.
Edited by: badperson on Feb 28, 2008 8:24 AM
Edited by: badperson on Feb 28, 2008 8:57 AM

Hi,
I reworked the code, and it now sort of works What I had wanted was to watch each window increment at the same rate, independant of each other. This will show a number in the window intemittenly, but not in a smooth continuous flow.
      class BigJobWorker2 extends SwingWorker<Void, String>{
          @Override
          protected Void doInBackground(){
               try{
                    for(int i=0; i<100000;i++){
                    int num2 = (int)(Math.random() * 100);
                    Integer integerNum2 = num2;
                    //tArea2.setText("iteration: " + i + " " + integerNum2.toString());
                    publish("iteration: " + i + " " + integerNum2.toString());
                    //ReallyBigJob rbj = new ReallyBigJob();
                    //tArea1.setText(rbj.doBigJob().toString());
                    publish("done.");
               } catch (Exception e3){
               e3.printStackTrace();
               tArea2.setText("EXCEPTION:");
          return null;
     // override process method
     @Override
        protected void process(List<String> messages) {
     Iterator i = messages.iterator();
          while (i.hasNext()){
          String message = (String)i.next();
          tArea2.setText(message);               
     } // end BigJobWorker2thanks,
badperson

Similar Messages

  • HT201303 Please help me. I have forgotten my security answers on two questions. It is not easy to restore it. Apple support did not send me on my e-mail  the answers or did not make opportunity to have as an option to reset my security questions on line.

    Please help me. I have forgotten my security answers on two questions. It is not easy to restore it. Apple support did not send me on my e-mail  the answers or did not make opportunity to have as an option to reset my security questions on line.

    You need to ask Apple to reset your security questions; ways of contacting them include clicking here and picking a method for your country, phoning AppleCare and asking for the Account Security team, and filling out and submitting this form.
    (97776)

  • Making An Event Two Lines Long In Month View

    Hey Everyone,
    I only use iCal in month view and most of the time when I enter an event that has a long name it shows up as two lines, so I am able to read it all. However, sometimes it only goes for a single line and cuts off the end of the event title. How do I change this to show two lines?
    Thanks!!

    I have the same question. One workaround is to copy an existing two-line event to the day that you want to create a new event. Then edit that to change it to the event name you want. This seems to work even though just typing a new name truncates it to one line.
    I hope someone can provide a more elegant solution.

  • How display two-line descriptions in month view

    In the iCal version in Snow Leopard, it was possible to display a two-line description of an event in month view. Is there a way to do that in the version included with OS 10.9 and 10.10? The descriptions now are so truncated it can be hard to understand what they refer to. Also, the text of the descriptions in month view no longer is in the color of the calendar they are assigned to (except for all-day events). Instead, the descriptions are marked with tiny dots. This makes it much more difficult to distinguish between event types. Apple seems to be changing its apps for some misguided sense of aesthetics instead of emphasizing utility.

    I have the same question. One workaround is to copy an existing two-line event to the day that you want to create a new event. Then edit that to change it to the event name you want. This seems to work even though just typing a new name truncates it to one line.
    I hope someone can provide a more elegant solution.

  • I have lost first two lines of tool bar, how do I retrieve?

    I inadvertently deleted the first two lines of the tool bar. I have no file, edit, view, bookmarks, tools, etc. I have no way to go to the previous page or to the next page. I don't know how I deleted these important tools. Please help!

    '''<u>Menu Bar</u>''' (File, Edit, View, History, Bookmarks, Tools, Help)<br /> Firefox 3.6.x versions allow the user to hide the Menu Bar.<br />
    *Tap the ALT key or the F10 key, Menu Bar will display, click View, click Toolbars, click Menu Bar to place a check mark next to it, '''''OR'''''
    *Press and hold the ALT key while pressing the letters VTM on your keyboard, then release the ALT key
    *See: http://support.mozilla.com/en-US/kb/Menu+bar+is+missing
    '''<u>Other Toolbars</u>''', see: https://support.mozilla.com/en-US/kb/Back+and+forward+or+other+toolbar+items+are+missing<br />
    '''<u>Status Bar</u>''': click View, click Status Bar to place a check mark<br />
    '''<u>Full Screen Mode</u>''': If you have no Toolbars or Tab Bar: Press F11 (F11 is an on/off toggle). See: http://kb.mozillazin'''e.org/Netbooks#Full_screen<br />
    Also see: http://kb.mozillazine.org/Toolbar_customization_-_Firefox#Restoring_missing_menu_or_other_toolbars
    '''Other issues that need your attention''''''
    The information submitted with your question indicates that you have out of date plugins with known security and stability issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post. You can also see your plugins from the Firefox menu, Tools > Add-ons > Plugins.
    *Adobe Shockwave for Director Netscape plug-in, version 11.5.9.615
    **'''''Security update version 11.5.9.620 released 2011-02-08'''''
    *Adobe PDF Plug-In For Firefox and Netscape 10.0.0
    **'''''Security update version 10.0.1 released 2011-02-08'''''
    *Next Generation Java Plug-in 1.6.0_22 for Mozilla browsers
    **2 updates behind
    **'''''Security update version 1.6.0_24 released 2011-02-10'''''
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Shockwave for Director'''
    #*NOTE: this is not the same as Shockwave Flash; this installs the Shockwave Player.
    #*Use Firefox to download and SAVE the installer to your hard drive from the link in the article below (Desktop is a good place so you can find it).
    #*When the download is complete, exit Firefox (File > Exit)
    #*locate and double-click in the installer you just downloaded, let the install complete.
    #*Restart Firefox and check your plugins again.
    #*'''<u>Download link and more information</u>''': http://support.mozilla.com/en-US/kb/Using+the+Shockwave+plugin+with+Firefox
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use the links below to avoid getting the troublesome "getplus" Adobe Download Manager and other "extras" you may not want
    #**Use Firefox to download and SAVE the installer to your hard drive from the appropriate link below
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link</u>''': ftp://ftp.adobe.com/pub/adobe/reader/
    #***Choose your OS
    #***Choose the latest #.x version (example 9.x, for version 9)
    #***Choose the highest number version listed
    #****NOTE: 10.x is the new Adobe Reader X (Windows and Mac only as of this posting)
    #***Choose your language
    #***Download the file, SAVE it to your hard drive, when complete, close Firefox, click on the installer you just downloaded and let it install.
    #***Windows: choose the .exe file; Mac: choose the .dmg file
    #*Using either of the links below will force you to install the "getPlus" Adobe Download Manager. Also be sure to uncheck the McAfee Scanner if you do not want the link forcibly installed on your desktop
    #**''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #**Also see: https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox (do not use the link on this page for downloading; you may get the troublesome "getplus" Adobe Download Manager (Adobe DLM) and other "extras")
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    #*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

  • Can someone explain to me what are the benefits of compound path when it comes to text?  I can understand one or two lines but a whole paragraph?

    Every year we do a fundraiser to help my job, but my co-worker is getting frustrated.  We receive outside files laid out in Illustrator, but the person who does the file sets all of the text using compound path. These aren't one or two lines of text to be manipulated but whole paragraphs of text.  This person does this every year, and it is time consuming if my co-worker can't manipulate a paragraph without going to each individual layer that has a letter. Is there a way to make these compound paths merge as one without altering the document i.e. make some element disappear. Any kind of help is appreciated.

    ikaika,
    As I (mis)understand it, you should simply ask this outside person to keep all text as Live Type, using a font that you have on your machines (in the exact same version) so there will be no font substitution issue(s).
    That way, you could get the job done without silly waste of time.
    Failing to comply would seem quite uncooperative.
    I presume there is no copyright question onvolved in this.

  • Divide Dashboad pages into two lines

    Hi Experts,
    I am working on 11.1.1.5.0
    I am facing below problem.....
    Lets say you have some 15 pages on a Dashboard and all these pages by default comes on one line.
    I want to divide these pages into two lines with 8 page on 1st line and 7 pages on 2nd line.
    I think this can be achieved by using java script but dont know how to achieve this.
    Could you please help....
    Thanks in Advance.
    KD

    Hi prashanth,
    This we can do with javascripting but the problem is it squeezes the dashboard page and changes the colour of dashboard.So better to go for drop down of page items as you have 15 pages
    Follow this links http://forums.oracle.com/forums/thread.jspa?threadID=1014941&start=0&tstart=0
    http://forums.oracle.com/forums/thread.jspa?messageID=9226234?
    you need to change the javascript as needed,so you can consult any JavaScript guy from your company
    In between your previous posts are not closed by awarding points...please follow rules and this is your previos post
    http://forums.oracle.com/forums/message.jspa?messageID=9296458#9296458
    hope answers your question.
    Cheers,
    KK

  • Prints two lines perfect and then the next line cannot be read.

    Pixma MX882 When printing from computer or copying it prints two lines perfect, then the third line is not clear.  Can see letters are fuzzy (not clear, but can tell it tried to print)  Please help with any suggestions for correcting this problem. I have changed out the ink carts and run maintenance program.  Thanks.  Ross

    Hi rossfwalker,
    We recommend performing an automatic and manual print head alignment on the printer to see if this will resolve the issue. To do this, please follow the steps located here.  Should you still experience difficulty, the printer will require servicing; please call or email us using one of the methods on the Contact Us page for further assistance.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Scanned document has two lines horzonal on the left side of paper

    My Unit is
    HP Officejet 6210 All-in one
    Only when i scan document it shows up with two lines on the left side of paper as it is scanned.
    The first line 2inches from the edge the line is only 1/16 wide all the way cross the paper
    The second line is 4 inches from the edge of paper and is 1/4 inch wide all the way cross the paper.
    I have cleaned the glass and white backer of cover did not change.
    I ran the Hp Print and scan doctor it recommend contact HP customer service.
    The problem is not during normal
    I have inspected the glass and small part of the feed cartiage. I did not know how to remove it to inspect better.
    Can you tell me what is causing the line traces during scanning operation of my machine thank you

    Hi @JamesI 
    Do these horizontal lines appear when you copy too? I ask because copy and scan use the same hardware components, if the issue occurs when you copy too there is indeed an issue with the printer hardware. If the issue does not occur when you copy, the problem is isolated to the software.
    In any case, it seems you have done all of the hardware troubleshooting; Horizontal Lines on a Copy/Scan. If you determine the issue is a software problem with scanning alone, let me know and we can go from there.
    If it is a hardware issue, you can try a couple of things in addition to what you have already done, but if the issue continues, I suggest calling us.
    Do you have the printer connected directly to a wall outlet or is it in a surge protector or power bar? Even if you have been using a surge protector/power bar all this time and you feel it is not the cause, please connect it to a wall outlet just so we can eliminate the power source as the root cause.   Issues when Connected to an Uninterruptible Power Supply/Power Strip/Surge Protector
    In this document you will see, ISSUE: Problems or issues may arise when an HP LaserJet series printer is connected to an uninterruptible power supply (UPS), a power strip, or a surge protector
    ^ This is not limited to Laserjet printers.
    Let's perform a hard reset. To do so, leave the printer on and unplug the power cable for 1 minute. While it is unplugged, hold down the power button on the printer for 10-15 seconds to release any built up power, then after the minute has passed, plug the printer back in.
    If the issue remains unresolved, and you are in Canada or US call 800 474 6836, or you can Contact HP Worldwide.
    I hope this helps.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • Field description in two line in ALV report

    Hi ,
    In ALV report I  want the description for each field to be displayed in two lines . For example
    the description for field matnr is " Material No for grade A " which is displayed in one line . But i want to display it as :  Material No
                                                           for grade A
    in two lines . Is it possible . Please help me out .
    Neetesh

    Hi Neetesh,
      Its not possible to display as you like in 2 lines header for single column. But i can provide the alternative way , it won't good logically. Please try the following logic.
    Let suppose you have 10 fields F1-f10. Each field has the 2 lines header. So take 20fields in your fields catalog ie take 10 dummy fields which are equal lenght of the fields F1-f10. and for the last 10 fields(F11-F20) set the row pos as 2, set the second line header to these field(F11-F20). So you will succed to display the 2 level header for single column. But the problem here is you will get one empty row additional row for each row. Because you have taken (F11-F20) fields are dummy and don't have the data also. This solution will works only in the case of ALV List display not in Grid Display.
      But Before that tell to your customer about this problem , Because I have done the same things when my customer giving important to 2 lines header and he accepeted that also.
    If suppose you have the data in 2 lines for each column then this solution will work fine. Thats what i implemented in my ALV Report.
    Warm Regards,
    Vijay.

  • Unable to find line break between two lines in attachment file.

    Dear all I will be very great full if someone help me out,
    I am trying to send mail through SMTP server with an attachment of oracle report, but I am unable to find line break between two lines, when I down load the attachment from mail and open attach.txt file by double click on it. Next line starts right after previous line ends, it should starts with new line.
    In order to send an attachment file, I am reading source file line by line and put MIME protocol’s attachment instance, contain of source file is being properly written into target file if I open that attachment on cmd prompt.
    Following code may help you to understand the case.
    Thanks in advance.
    My code is as follows:-
    create or replace procedure bec_file_test
    v_subject varchar2, -- Subject of the email
    v_body varchar2, -- Body of the email
    v_from VARCHAR2 default 'XYZ.com', -- sender mail id
    v_to varchar2 default 'XYZ.com', -- Field To of the email
    v_cc varchar2 default 'XYZ.com' -- cc address
    ) is
    -- variable to hold the smtp server connection
    v_smtp_connection utl_smtp.connection;
    -- variable to hold the smtp host name
    v_smtp_host varchar2(100) default 'mail.bec-group.com';
    -- variable to hold the smtp port
    v_smtp_port number default 25;
    -- composite of {CR}{LF} caridge return and line feed.
    CRLF varchar2(2):=CHR(13)||CHR(10);
    cursor pr_rec is
    select requisition_no,line_no,release_no,a.contract,
    a.project_id,substr(a.activity_seq,1,11)ACT_SEQ,
    substr(a.part_no,1,12)PART_NO,
    substr(a.description,1,32)DESCRIPTION,
    substr(a.Bal_qty,1,8) BAL_QTY,
    substr(a.unit_meas,1,5)UOM,
    a.wanted_receipt_date WAN_REC_DT,
    a.latest_order_date LAT_ORD_DT
    from bec_pr_line_rep a
    where a.Bal_qty>0 and a.header_state not in 'Closed'
    and upper(a.state1) like 'RELEASED' and a.contract not in ('U1ENG','ULENG','U1FND','U2FND')
    and a.buyer_code='70306'
    order by a.part_no;
    begin
    declare
    fHandle UTL_FILE.FILE_TYPE;
    v_msg_line varchar2(2000);
    -- v_buffer varchar2(20000);
    --ALTER SYSTEM SET utl_file_dir = 'D:\Database\temp'
    --COMMENT='Temporary change on Dec 14'
    --SCOPE=SPFILE;
    SELECT name, value
    FROM gv$parameter
    WHERE name = 'utl_file_dir';
    --drop directory my_directory
    --CREATE or replace DIRECTORY my_directory AS 'D:\database\temp';
    --GRANT read,write ON DIRECTORY my_directory TO PUBLIC;
    begin ---writing data into a file.
    fHandle := UTL_FILE.FOPEN('MY_DIRECTORY', 'pending_pr_summry.txt', 'w');
    UTL_FILE.put_line(fHandle, ' Pending PR to process (detail report)');
    UTL_FILE.put_line(fHandle,TO_CHAR(SYSDATE,'MM-DD-YY HH:MI:SS AM'));
    UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
    UTL_FILE.put_line(fHandle, 'Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt' );
    UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
    for pr_temp in pr_rec loop
    begin
    v_msg_line:=to_char(rpad(pr_temp.requisition_no,12,' ')||'|'||
    lpad(pr_temp.line_no,3,' ')||'|'||
    lpad(pr_temp.release_no,3,' ')||'|'||
    rpad(pr_temp.contract,7,' ')||'|'||
    lpad(nvl(pr_temp.project_id,' '),7,' ')||'|'||
    lpad(nvl(pr_temp.act_seq,' '),12,' ')||'|'||
    lpad(pr_temp.part_no,12,' ')||'|'||
    rpad(pr_temp.description,35,' ')||'|'||
    lpad(pr_temp.bal_qty,10,' ')||'|'||
    rpad(pr_temp.uom,6,' ')||'|'||
    lpad(pr_temp.wan_rec_dt,14,' ')||'|'||
    lpad(pr_temp.lat_ord_dt,14,' '));
    UTL_FILE.put_line(fHandle,v_msg_line);
    end;
    end loop;
    UTL_FILE.put_line(fHandle, '--------------------------------------------------------------------------------------------------------------------------------------------------');
    UTL_FILE.put_line(fHandle, ' Regards : IFSAPP ( Application owner ) ');
    UTL_FILE.FCLOSE(fHandle); ------------writing into file is successfuly done here!
    --Reading of file starts here containt will be added in attchment file
    fHandle :=UTL_FILE.FOPEN('MY_DIRECTORY','pending_pr_summry.txt','R' );
    -- establish the connection to the smtp server
    v_smtp_connection := utl_smtp.open_connection(v_smtp_host, v_smtp_port); /** OPEN CONNECTION ON THE SERVER **/
    -- perform a handshake with the smtp server
    utl_smtp.helo(v_smtp_connection, v_smtp_host); /** DO THE INITIAL HAND SHAKE **/
    -- set the 'from' address of the message
    utl_smtp.mail(v_smtp_connection, v_from);
    -- add the recipient to the message
    utl_smtp.rcpt(v_smtp_connection, v_to);
    -- send the email
    utl_smtp.open_data(v_smtp_connection);
    v_msg_line:='Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || CRLF ||
    'From: ' || v_from || CRLF ||
    'Subject: ' || v_subject || CRLF ||
    'To: ' || v_to || CRLF ||
    'Cc: ' || v_cc || CRLF ||
    'MIME-Version: 1.0'|| CRLF || -- Use MIME mail standard
    'Content-Type: multipart/mixed;'||CRLF ||
    ' boundary="-----SECBOUND"'||CRLF||
    CRLF ||'-------SECBOUND'|| CRLF ||
    'Content-Type: text/plain;'|| CRLF ||
    'Content-Transfer_Encoding: 7bit'|| CRLF ||
    CRLF ||v_body|| CRLF;     -- Message body
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    v_msg_line:='-------SECBOUND'|| CRLF ||
    'Content-Type: application/octet-stream;'|| CRLF ||
    'Content-Type: text/plain;'|| CRLF ||
    'name="pending_pr_summry.txt"'|| CRLF ||
    'Content-Transfer_Encoding: 8bit'|| CRLF ||
    'Content-Disposition: attachment;'|| CRLF ||
    ' filename="pending_pr_summry.txt"'|| CRLF || CRLF;     -- Content of attachment
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    -- check file is opened
    IF utl_file.is_open(fHandle) THEN
    -- loop lines in the file
    LOOP
    BEGIN -- Content of attachment
    utl_file.get_line(fHandle,v_msg_line);
    v_msg_line:=concat(v_msg_line,CRLF);
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    END IF;
    --end of attachment containt     
    utl_smtp.write_data(v_smtp_connection,v_msg_line);
    UTL_FILE.FCLOSE(fHandle);
    utl_smtp.close_data(v_smtp_connection);
    utl_smtp.quit(v_smtp_connection);
    exception
    when utl_smtp.invalid_operation then
    dbms_output.put_line(' Invalid Operation in Mail attempt using UTL_SMTP.');
    when utl_smtp.transient_error then
    dbms_output.put_line(' Temporary e-mail issue - try again');
    when utl_smtp.permanent_error then
    dbms_output.put_line(' Permanent Error Encountered.');
    when others then
    dbms_output.put_line('Exception: SQLCODE=' || SQLCODE || ' SQLERRM=' || SQLERRM);
    RAISE;
    end;
    end bec_file_test;

    Pending PR to process (detail report)01-17-13 12:43:19 PM--------------------------------------------------------------------------------------------------------------------------------------------------Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt--------------------------------------------------------------------------------------------------------------------------------------------------MAT/250370 | 2| 1|ISCSP | 4977| 100004207| 0104000016|Angle 50 X 50 X 6 IS:2062 Grade |500|kg |30-NOV-2012| 20-nov-2012MAT/250370 | 3| 1|ISCSP | 4977| 100004207| 0105000002|Channel 100 X 50 IS:2062 Grade A | 1000|kg | 30-NOV-2012| 20-nov-2012MAT/250579 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 2991|kg | 13-DEC-2012| 03-dec-2012MAT/250606 | 2| |NMDCJ | 6002| 100005860| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | |1|NMDCJ|6001|100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 1500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 3| 1|NMDCJ | 6002| 100005818| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 3939|kg | 29-DEC-2012| 19-dec-2012MAT/250606 | 4| 1|NMDCJ | 6002| 100005860| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 39000|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 4| 1|NMDCJ | 6001| 100005580| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 2| 1|NMDCJ | 6002| 100005818| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 12183|kg | 29-DEC-2012| 19-dec-2012MAT/250606 | 6| 1|NMDCJ | 6002| 100005860| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 9500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 6| 1|NMDCJ | 6001| 100005580| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 6| 1|NMDCJ | 6002| 100005818| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012MAT/250607 | 7| 1|NMDCJ | 6001| 100005580| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 22000|kg | 29-DEC-2012| 19-dec-2012MAT/250194 | 7| 1|NMDCJ | 6002| 100005818| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 27060|kg | 29-DEC-2012| 19-dec-2012MAT/251138 | 1| 1|NMDCJ | 6002| 100005825| 3501000001|Cement 50 kg | 1|pkt | 25-DEC-2013| 14-dec-2013--------------------------------------------------------------------------------------------------------------------------------------------------
    where as source file is like that:-
    Pending PR to process (detail report)
    01-17-13 12:43:19 PM
    Req.no. li Re Site Prj Id Act seq Part no Description Qty UOM want rec dt lat ord dt
    MAT/250370 | 2| 1|ISCSP | 4977| 100004207| 0104000016|Angle 50 X 50 X 6 IS:2062 Grade | 5500|kg | 30-NOV-2012| 20-nov-2012
    MAT/250370 | 3| 1|ISCSP | 4977| 100004207| 0105000002|Channel 100 X 50 IS:2062 Grade A | 1000|kg | 30-NOV-2012| 20-nov-2012
    MAT/250579 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 2991|kg | 13-DEC-2012| 03-dec-2012
    MAT/250606 | 2| 1|NMDCJ | 6002| 100005860| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 2| 1|NMDCJ | 6001| 100005580| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 1500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 3| 1|NMDCJ | 6002| 100005818| 0109020002|TMT Bar 10 mm Fe 415 IS:1786 | 3939|kg | 29-DEC-2012| 19-dec-2012
    MAT/250606 | 4| 1|NMDCJ | 6002| 100005860| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 39000|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 4| 1|NMDCJ | 6001| 100005580| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 2| 1|NMDCJ | 6002| 100005818| 0109020004|TMT Bar 16 mm Fe 415 IS:1786 | 12183|kg | 29-DEC-2012| 19-dec-2012
    MAT/250606 | 6| 1|NMDCJ | 6002| 100005860| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 9500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 6| 1|NMDCJ | 6001| 100005580| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 4500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 6| 1|NMDCJ | 6002| 100005818| 0109020006|TMT Bar 25 mm Fe 415 IS:1786 | 17500|kg | 29-DEC-2012| 19-dec-2012
    MAT/250607 | 7| 1|NMDCJ | 6001| 100005580| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 22000|kg | 29-DEC-2012| 19-dec-2012
    MAT/250194 | 7| 1|NMDCJ | 6002| 100005818| 0109020008|TMT Bar 32 mm Fe 415 IS:1786 | 27060|kg | 29-DEC-2012| 19-dec-2012
    MAT/251138 | 1| 1|NMDCJ | 6002| 100005825| 3501000001|Cement 50 kg | 1 |pkt | 25-DEC-2013| 14-dec-2013
    Ignore alignment. It is well formatted in source file.

  • SAP Script : to display the material description in two lines

    Hi All,
    I'm working on scripts.
    the material description field is been passed from my driver program ..into the script..
    Ex: &gs_final-maktx& ..
    There r a number of other fields to be displayed ...after this field ....
    Is there any option to split the 'Material description into two lines'?
    Ex: at present it is :
    This is material description
    Requirement is:
    This is material
    description
    I mean that there a number of field berfore and after this field......in the same line
    I need to jst split the materia description ...& make it to appear in two lines.....!!
    Expecting your suggestions....
    Edited by: vidya vidya on Nov 11, 2008 3:17 PM
    Edited by: vidya vidya on Nov 11, 2008 3:20 PM

    FM TEXT_SPLIT ?
    ..but i handled this by code.
    DATA:      zzboldsx(18) TYPE c,
          zzboldsx2(18) TYPE c,
          zzboldsx3(18) TYPE c,
          zzboldsx4(18) TYPE c.
    DATA: i_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE ,
            r_lines TYPE tline,
            v_cnt LIKE sy-tabix.
    CALL FUNCTION 'READ_TEXT'
        EXPORTING
          client                  = sy-mandt
          id                      = stxh-tdid
          language                = stxh-tdspras
          name                    = name
          object                  = stxh-tdobject
        TABLES
          lines                   = i_lines[]
        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.
    * Only 4 lines of Header text supported. Can add if needed
        LOOP AT i_lines INTO r_lines.
          CONDENSE r_lines-tdline NO-GAPS.
          v_cnt = v_cnt + 1.
          CASE v_cnt.
            WHEN 1.
              zzboldsx = r_lines-tdline.
            WHEN 2.
              zzboldsx2 = r_lines-tdline.
            WHEN 3.
              zzboldsx3 = r_lines-tdline.
            WHEN 4.
              zzboldsx4 = r_lines-tdline.
            WHEN OTHERS.
              EXIT.
          ENDCASE.
    *   zzbolDSX =  i_lines-tdline .
        ENDLOOP.

  • Displaying data in Two line in ALV report

    Hi,
    I want to know how to display the data in alv in two lines for Fild name as well as for fild value
    like in below case
    wa_fieldcata-fieldname  = 'WRBTR'.
       wa_fieldcata-seltext_l  = 'AMOUNT IN DOCUMENT CURRENCY'.
       wa_fieldcata-outputlen  = 18.
       wa_fieldcata-DO_SUM     = 'X'.
       APPEND wa_fieldcata TO it_fieldcat.
       CLEAR wa_fieldcata.
    by this on alv COLUMN headig is coming as 'AMOUNT IN DOCUMENT CURRENCY' in one linw  i want to display  'AMOUNT IN '   in first line and then 'DOCUMENT CURRENCY' below that
    'AMOUNT IN
    DOCUMENT CURRENCY' ***
    similarly how to display value of three fidls in one column
    like for a vendor   I have one column  Vandor name in that column i want to display from table LFA1, 
    NAME1
    NAME2
    NAME3
    NAME4,
    in one column only how to do it.
    regards,
    zafar

    Hi,
    Ref . early reply  can u help me how to uset his in ALV code  and can u give some example for this  how to display it in two lines  as my column heading is of 60 characters 5 word i want to display it in two line in one column only  .
    How to use : SLIS_EV_AFTER_LINE_OUTPUT
    to get this.
    or is there any other method.
    regards,
      zafar

  • How to display two-lines strings item

    Hi,
    How can I display list of two-line string items? Each Item in the list should have a phone number and a time. It should look similar to the "dialled numbers" display where each item has an image, and two-line string.
    Is it possible doing it with the high-level API or should I go low-level?
    Thanks in advance
    Imzadi

    use: list.setFitPolicy(Choice.TEXT_WRAP_ON)

  • File adapter-How to set line break in text file-split record into two lines

    Dear Guru's,
    I have to solve following problem with XML (with mulitiple records) to TEXT file scenario using file adapter. I have to output for ever ONE data record in XML always two identical lines in text file. Second line should have a little bit different mapping in few fields like date,... So I did duplicate fileds in my output structure in mapping and need to know how to set line break in the middle and see half of structure in first line and next structure half in second line
    My output structure in mapping is:
    CASHFLOW
    - INTERFACE
    - GESELLSCHAFT
    - ANWENDUNG
    - PRODUKT
    - VERTRAG
    - BETRAG
    - WAEHRUNG
    - DIRECTION
    - BEWEGUNGSTYP
    - FAELLIGKEIT
    - ZINSFESTSTELLUNG
    - ZAHLUNGSTAG
    - RENDITE
    - INTERFACE2
    - GESELLSCHAFT2
    - ANWENDUNG2
    - PRODUKT2
    - VERTRAG2
    - BETRAG2
    - WAEHRUNG2
    - DIRECTION2
    - BEWEGUNGSTYP2
    - FAELLIGKEIT2
    - ZINSFESTSTELLUNG2
    - ZAHLUNGSTAG2
    - RENDITE2
    Question is how can I set on receiving file adapter in Content Conversion Parameters that fields from first structure half INTERFACE...RENDITE should be outputed in one line and fields from second half of structure INTERFACE2...RENDITE2 should start on second line in final text file.
    I'm getting at the moment one line only and I need to know how can set line break so that second line starting with INTERFACE2(CA)...RENDITE2 will start in new line.
    CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000",CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"
    This should be final output:
    CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",2,12,2009-01-28,2009-01-27,2009-01-28,"0.0000000"
    CA,"0100","7","512",20090127010001,-12454762586.6800,"EUR",1,10,2009-01-27,2009-01-27,2009-01-27,"0.0000000"
    My file adapter settings:
    RecordsetStructure=CASHFLOW
    CASHFLOW.fieldNames=INTERFACE,GESELLSCHAFT,ANWENDUNG,PRODUKT,VERTRAG,BETRAG,WAEHRUNG,DIRECTION,BEWEGUNGSTYP,FAELLIGKEIT,ZINSFESTSTELLUNG,ZAHLUNGSTAG,RENDITE
    CASHFLOW.fieldSeparator=,
    CASHFLOW.endSeparator='nl'
    CASHFLOW.fieldNames=INTERFACE2,GESELLSCHAFT2,ANWENDUNG2,PRODUKT2,VERTRAG2,BETRAG2,WAEHRUNG2,DIRECTION2,BEWEGUNGSTYP2,FAELLIGKEIT2,ZINSFESTSTELLUNG2,ZAHLUNGSTAG2,RENDITE2
    CASHFLOW.fieldSeparator=,
    It wont help if I add two identical structures in mapping because in output i would see for multiple entries section with first lines only and after that section with second lines only. And CASHFLOW is one part of more complex mapping ...
    (This is final output structure RecordsetStructure=HEADER,CASHFLOW,CONDITION,REFERENCE,CONTRACT - more sections with different data and all these should have duplicate lines at the end)
    Thanks a lot for any help
    Cheers
    Marian
    Edited by: Marian  Luscon on Jul 14, 2009 11:44 AM

    Hi Ivan,
    right, I did test just for sure.
    Putting constant 'nl' into field CASHFLOW-INTERFACE1 didnt help - still getting one line instead two lines.
    CA ,"0100" ,"7" ,"512" ,20090127GTP101 ,-12454762586.6800 ,"EUR" ,2 ,12 ,2009-01-28 ,2009-01-27 ,2009-01-28 ,"0.0000000" ,'nl' ,"GTP1" ,"7" ,"512" ,20090127GTP101 ,-12454762586.6800 ,"EUR" ,1 ,10 ,2009-01-27 ,2009-01-27 ,2009-01-27 ,"0.0000000"
    So there is still question. Is there any way (mapping,...) how to output always 2 lines in text file for one record in XML. It always does 1 record in mapping structure = 1 line but we need 2 lines ...
    Example:
    Input: 4 records in XML
    Output: 8 lines in final text file ...
    Thanks to you all guys
    Marian

Maybe you are looking for

  • How can I re-set the App Store so the Updates will again appear under the Updates tab?

    Hi, I am running a Macbook Pro (retina). Lately when I launch App Store and click on Updates the software updates for the software on the Macbook do not show up under the Updates tab. However, when I go to the Purchased tab I see there Update buttons

  • ITunes 8.1 calendar error

    hi. i updated to iTunes 8.1. naturally, i was playing around at the new features. when i went to sync my iPhone, i got this: http://s5.tinypic.com/15mnyia.jpg. it happens everytime i sync now. any tips? thanks.

  • Free beer, if you make this work....

    Provided that you come and collect it yourself..... First of all, new to flash, so I have properly made this all wrong First look here What I want to make is a scroller that can scroll movieclips, so I use a scrollPane and adds a empyt MC (a contentH

  • Can't run Connector, Changes the server name

    I am trying to run the Windows 2011 Server Connector on a new PC running 8.1. Never worked with 8.1 before. Connecting on earlier OSs was easy. I am following the same procedure, but the system keeps placing " :65510 " behind the server name. Of cour

  • CRM 2013: Format and C# code to add attachment

    I have created a very simple custom entity. I want to be able to add attachment to this entity record. Now I have 2 questions 1) What kind of field should I create and  how do make it available in the entity form. 2) What would be the simplest C# cod