How to send a text file over a LAN?

Hi:
I am working on a program (web app using a servlet), that produces a text file with Key / Value pairs ex) NAME
joe
CITY
los angeles
I want to send the text file over an intranet (LAN) to another pc and store it in the C:\temp directory of the receiving computer.
Is it best to use the Networking package? Any idea on tutorials or code samples to help assist me? (I posted on Servlet Technology forum; nobody answered though...thanks for any thoughts.

one way cud be that u write a program to open a port on the computer u want to store and make that program save on the required directory. then u can send a simple file in byte format over it. but doing this only wud b unsafe as others wud also hav the access. wat u cud do to prevent is to put some kind of password so that first u authenticate to server b4 u pass on the file.
bye
jods

Similar Messages

  • How to send a text file to a printer?

    Hi, I'm in dark on how to send a text file to a printer through Java Stored Procedure.
    Here are what I tried so far (OS: win 2000, Oracle: 817 or 9i2):
    1, Enable DOS command in Java Stored Proc. and try to send PRINT command there:
    public static String Run(String Command){
    try{
    Runtime.getRuntime().exec(Command);
    System.out.println("Command: " + Command);
    return("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    public static void main(String args[]){
    if (args.length == 1)
    Run("print /D:\\\\enterprise\\john " + args[0]);
    else System.out.println("Usage: java OSCommand filename");
    PL/SQL wrapper:
    CREATE OR REPLACE FUNCTION OSCommand_Run(p1 IN VARCHAR2) RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'OSCommand.Run(java.lang.String) return java.lang.String';
    SQL command:
    //print /D:\\machine\printer test.txt
    I loaded the Java Stored Procedure into SYSDBS account, it failed silently, even though piece of code works fine in external JVM.
    2, Use filePrinter:
    public static String print(String printString) {
    try{
    String printerUNC = "\\\\machine\\printer";
    FileWriter fw = new FileWriter(printerUNC);
    PrintWriter pw = new PrintWriter(fw);
    pw.println(printString);
    fw.close();
    return "OK";
    }catch(Exception e){
    e.printStackTrace();
    return "Exception: " + e.getMessage();
    public static void main(String[] args) {
    try{
    String printerUNC = "\\\\machine\\printer";
    String printString = "Hello World";
    FileWriter fw = new FileWriter(printerUNC);
    PrintWriter pw = new PrintWriter(fw);
    pw.println(printString);
    fw.close();
    }catch(Exception e){e.printStackTrace();}
    I loaded it into SYSDBS too, and tried with this:
    SQL> select MY_PRINT.PRINT('HELLO from Oracle') from dual;
    MY_PRINT.PRINT('HELLOFROMORACLE')
    Exception: No such file or directory
    SQL> show user
    USER is "SYS"
    It works in external JVM too.
    What's wrong with this?
    Thanks for any help in advance,
    Charles

    Avi:
    Thanks for your response!
    I put the java code in SYS, 'cause I assume that account has max privilege. If the test is successful, I will move that to some user schema and then to deal with those privilege settings... But I'm unlucky.
    I checked Ask Tom, this is what I got from http://asktom.oracle.com/pls/ask/f?p=4950:8:1619723::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:38012348052,%7Bprinter%7D:
    ... Print file from PL/SQL ...
    If you are using Oracle8i, release 8.1 -- much can be done with Java. java
    would be able to print directly from the server.
    Looks like using Java to print out file is better than PL/SQL. But there's no more hint there! And, no new question can be asked there today either...
    I'm wondering whether we can create a socket to a printer and send the characters there directly... Anyone has experience on this?
    Thanks for all the help in advance,
    Charles

  • How to send a text file as jsp response

    Hi
    I want to send a text file/or other file as jsp response ..How to do it..
    Pls tell me if any body knows about it..
    thanks

    Hmmm im no expert but i think you would have to convert it to a byte array and use OutputStream with the response ... not sure ...like i said, im no expert

  • Strange behaviour sending a text file over sockets

    Hi !
    Im not exactly new to Java. I discovered this behaviour when explaining to a junior.
    I have a simple Server-Client architecture to send a text file. The server sends strings to client. The client checks for the string to become null, and never terminates !
    Server.java
    ServerSocket ss = new ServerSocket(25780);
    Socket s = ss.accept();
    PrintStream ps = new PrintStream(s.getOutputStream());
    BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
    BufferedReader fis = new BufferedReader(
                   new InputStreamReader(
                        new FileInputStream(filename)));
    while((read = fis.readLine()) != null){
         ps.println(read);
    client.java
    Socket s = new Socket(IP,port);
    PrintStream ps = new PrintStream(s.getOutputStream());
    BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
    String read = new String();_
    *while((read = br.readLine())  != null){*_
    System.out.println(read);_
    Can you tell me what mistake I'm making?

    Thank you so much for the reply !
    All blocks are within try-catch. I didn't post the whole code since you would find it inconvenient !
    I tried flushing the stream ! Still doesnt work !
    I guess it might help to post the entire source:
    CLIENT.JAVA
        public static void main(String[] args) {
         try{
             System.out.println("Client");
             int port  = 25780;
             String IP = new String("127.0.0.1");
             Socket s = new Socket(IP,port);
             PrintStream ps = new PrintStream(s.getOutputStream());
             BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
             String command = new String();
             String filename_to_recv = "from_ser.txt";
             command = "GET "+filename_to_recv;
             ps.println(command);
             String received = new String();
             String read;
             while((read = br.readLine()) != null){
              System.out.println(read);
             String filename_to_send = "from_cli.txt";
             System.out.println("recd data from server");
             command = "PUT "+filename_to_send;
             ps.println(command);
             BufferedReader filereader = new BufferedReader(
                                 new InputStreamReader(
                                  new FileInputStream(filename_to_send)));
             String to_send = new String();
             while((to_send = filereader.readLine()) != null){
              ps.println(to_send);
             try{
               Thread.sleep(2000);
             } catch(Exception e){
              System.out.println(""+e);
              e.printStackTrace();
         } catch(Exception e){
             System.out.println(""+e);
             e.printStackTrace();
    SERVER.JAVA
       public static void main(String[] args) {
         try{
             System.out.println("Server");
             ServerSocket ss = new ServerSocket(25780);
             Socket s = ss.accept();
             PrintStream ps = new PrintStream(s.getOutputStream());
             BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
             String command = br.readLine();
             String filename = command.substring(command.indexOf(' ')+1);
             File f = new File(filename);
             BufferedReader fis = new BufferedReader(
                            new InputStreamReader(
                             new FileInputStream(filename)));
             String read;
             while((read = fis.readLine()) != null){
              ps.println(read);
             ps.flush();
             System.out.println("waiting for client data");
             command = br.readLine();
             while((read = br.readLine())  != null){
              System.out.println(read);
         } catch(Exception e){
             System.out.println(""+e);
             e.printStackTrace();
        }

  • How to send a text file attachment through mail in ECC 6.0

    Hi Friends,
    As per the requirement, I need to send a ALV report result as text file attachment to user in ECC 6.0 . I know how to do in 4.6C version. But the same code is not working here in ECC 6.0.
    Generally to get the data in new row in the text file we use below code in 4.6c.
    data: c_value type x value ' 0D '.
    concatenate c_value itab-line into itab-line.
    By using above code, we get each row of the itab in a new line in text file.
    Same code is not working in ECC6.0 as it is not supporting  to concatenate bytes with characters. Getting the error like " field c_value should be diclared as type C or I or N or T or P"
    Even I have used function module NLS_STRING_CONVERT_TO_SYS to convert hexa to char. It is converting the value' 0D' to ' # '. But it is not working.
    Could you please suggest me that how can get each row of itab as a new line in text file in ECC 6.0.
    Itab value:
    abcdefdfldjfñlkdsjfñldsjfdsñljñla
    fdsljfñldskjfldsñkjfñldsjfñldsajñld
    vcxusfcxusfcusafcxusafcusafcdsauc
    Actual result currently coming in text file:
    abcdefdfldjfñlkdsjfñldsjfdsñljñlafdsljfñldskjfldsñkjfñldsjfñldsajñldvcxusfcxusfcusafcxusafcusafcdsauc
    Expected result in text file:
    abcdefdfldjfñlkdsjfñldsjfdsñljñla
    fdsljfñldskjfldsñkjfñldsjfñldsajñld
    vcxusfcxusfcusafcxusafcusafcdsauc
    Please do the needful.
    Thanks
    Kumar

    hi,
    Try this function Module
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1 '
    *example code
    ******* Create Message Body Title and Description****************
      i_objtxt = 'test with pdf-Attachment!'.
      append i_objtxt.
      describe table i_objtxt lines v_lines_txt.
      read table i_objtxt index v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    **** Main Text*****************************
      clear i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      append i_objpack.
    **** Attachment (pdf-Attachment)*************
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smartform'.
      concatenate i_objpack-obj_name i_objpack-doc_type into
    i_objpack-obj_descr separated by '.'.
    *  I_OBJPACK-OBJ_DESCR = 'test'.
      i_objpack-doc_size =  v_lines_bin * 255 .
      append i_objpack.
    * Länge des Attachment ermitteln
      clear i_reclist.
      i_reclist-receiver = 'email address'.
      i_reclist-rec_type = 'U'.
      i_reclist-express = 'X'.
      data: tab_lines like sy-tabix.
      describe table i_objbin lines tab_lines.
      append i_reclist.
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        tables
          packing_list               = i_objpack
          object_header              = wa_objhead
          contents_bin               = i_objbin
          contents_txt               = i_objtxt
          receivers                  = i_reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          others                     = 8.
      if sy-subrc <> 0.
        write:/ 'Error When Sending the File', sy-subrc.
      else.
        write:/ 'Mail sent'.
      endif.

  • How to send a text file or a excel file as an attachment in workflow

    Hi all,
    I would like to send an e-mail containing an attachment in text or excel format in oracle workflow.Can anyone tell me or give me an example as how it can be done.
    My e-mail id is [email protected]
    Thanks in Advance.
    Regards,
    pavan

    Hi,
    I am embedding a CLOB message document attribute to my Notification
    Message Body.
    Everything works fine when I check my notifications in the "workflow worklist"
    i.e. Oracle Apps. <Notifications> tab.
    but the emails are not going to the users and below message is displayed in the
    status monitor. (eventhough it displays below error - I can able to respond the notifications using the worklist and can able to COMPLETE the workflow process
    successfully)
    Please help me to resolve the below error, so that the Same notification which I am able to see using the workflow worklist should be sent to the user in email as embedded text.
    NOTE: there is no problem with the Package XXDB_OKC_CONTRACTS_WF_PKG, as it is not changed and I even verified it before and after this error that this package is indeed in VALID status.
    Workflow Errors: XXDBCAPR, SDA-10314
    Failed Activity Send Approve_Reject Responce Notification
    Activity Type Notice
    Error Name WF_ERROR
    Error Message [WF_ERROR] ERROR_MESSAGE=3835: Error '-20002 - ORA-20002: 2018: Unable to generate the notification XML. Caused by: 2020: Error when getting notification content. Caused by: ORA-04061: existing state of has been invalidated ORA-04061: existing state of package "APPS_FND.XXDB_OKC_CONTRACTS_WF_PKG" has been invalidated ORA-04065: not executed, altered or dropped package "APPS_FND.XXDB_OKC_CONTRACTS_WF_PKG" ORA-06508: PL/SQL: could not find program unit being called Wf_Notification.GetAttrClob(18841, MESSAGE_BODY, text/html) Wf_Notification.oldGetAttrC' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'. ERROR_STACK= WF_MAIL.GetLOBMessage3(18841, WFMAILER, 2020: Error when getting notification content. Caused by: ORA-04061: existing state of has been invalidated ORA-04061: existing state of package "APPS_FND.XXDB_OKC_CONTRACTS_WF_PKG" has been invalidated ORA-04065: not executed, altered or dropped package "APPS_FND.XXDB_OKC_CONTRACTS_WF_PKG" ORA-06508: PL/SQL: could not find program unit being called Wf_Notification.GetAttrClob(18841, MESSAGE_BODY, text/html) Wf_Notification.oldGetAttrClob(18841, MESSAGE_BODY, text/html) WF_NOTIFICATION.GetFullBody(nid => 18841, disptype => text/html) WF_MAIL.GetLOBMessage3(nid => 18841, r_ntf_pref => MAILHTML), Step -> Getting text/html body) WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 18841) WF_XML.Generate(oracle.apps.wf.notification.send, 18841) WF_XML.Generate(oracle.apps.wf.notification.send, 18841) Wf_Event.setMessage(oracle.apps.wf.notification.send, 18841, WF_XML.Generate) Wf_Event.dispatch_internal()
    Error Stack
    thanks,
    Shashi
    NOTE: there is no problem with the Package XXDB_OKC_CONTRACTS_WF_PKG, as it is not changed and I even verified it before and after this error that this package is indeed in VALID status.

  • How to send a text file to printer in Java 1.3.1

    Please don't sujest 1.4. My users run it on 1.3

    I don't guarantee that this works in 1.3 - I really just don't know.
    But what I did the last time I had to print text was
    instantiate a JEditorPane.
    editorPane.setText(text);
    instantiate a DocumentRenderer
    renderer.print(editorPane);

  • How to zip a text file and send as email attachment in SAP version 4.6c?

    Hi Guru,
    How to zip a text file in SAP version 4.6c which doesn't have class CL_ABAP_ZIP?
    Please help.
    Thanks & Regards,
    Ari

    Hi,
    Try this link
    [http://sap.ittoolbox.com/groups/technical-functional/sap-dev/sapr3dev-zip-file-from-sap-1707099?cv=expanded]
    Cheers,
    Surinder

  • Sending EMail "Text-File" from Application Server!

    Hi Experts,
    how can I sending a Text-File from Application Server via Email?
    Is there existing a Function Modul?
    With Kind regards
    Ersin
    Moderator message: sending emails = FAQ, please search before posting.
    Edited by: Thomas Zloch on Nov 25, 2010 4:23 PM

    STF (Search the forum)!  This type of question has been asked...and answered....many times.

  • Sending a text file

    hi
    please can any one tell me if I want to send a text file residing on my mobile to another mobile using SMS how is it possible
    I already hv a j2me application tht can send a text message.
    I want a program tht will send this whole .txt file and the other end receives it as a text file
    thanx
    forumm

    hi
    can I split a text file and reassemble it using j2me
    or I send the text in the file using the usual sms
    and if I need to split the text file please can u give me some reference where I can find information about how to do that
    thanx a ton
    Forum

  • Sending a text file Client/Server problem

    Hi,
    I have two java classes (A.java and B.java). i would like to send the text file (something.txt) from A to B. Can somebody please show me how to do so? I know it is incomplete, but i really need help since im new to this. I dont know how to send and how to accept the file. Here is what i have so far:
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    public class A {
            private static String hostname;                  //host name
            private static final int portA = 1111;           //source port number
            private static int portB;                        //destination port number
            private static ServerSocket s;
            private static Socket socket;
            private static BufferedReader br;    
            String fileName = "something.txt";
            public A () {
            public static void send() {
                    System.out.println("Send method");
                    try {
                        System.out.print("> Enter Hostname: ");
                     hostname = br.readLine();
                     System.out.print("> Enter Port Number: ");
                        portB = Integer.valueOf(br.readLine()).intValue();
                catch(IOException e){}
            public static void main(String args[]) throws IOException {
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    public class B {
            private static String hostname;                  //host name
            private static final int portB = 2222;           //source port number
            private static ServerSocket s;
            private static Socket socket;
            private static BufferedReader br;    
            public B () {
            public static void recieve() {
                 //code to recieve the text file here?
            public static void main(String args[]) throws IOException {
    }I really appriciate any code to help me out. Thanks

    Check out the link shown below:
    http://forum.java.sun.com/thread.jsp?forum=33&thread=66616
    If that doesn't answer your question, search this site for Upload
    ;o)
    V.V.

  • How to attach a text file as an attachment to email message?

    Hello Everybody,
    I have a .csv file, in which details about emp-id, emp-name, e-expenses for Reimbursement and email address are stored.
    My application reads this .csv file, and sends a mail to each employee with his id, salary details in text format. (by changing content type to "text/plain") The code is working fine. But,
    My problem is:
    The message is sent as message body to the end user.
    The end user / the person who receives this mail will not be a technical person. So,
    1) If he trys to take a print out of this e-mail, He get only half of it.(as no. of colums will be more than paper size).
    2) I am finding alignment problem. IF employee name is too big, other columns will shift to right and data will not be exactly under column header. (it is going in zig zag way)
    So, I thought sending text file with all the details as an attachment might do well.
    But, I don't know how to attach a text file to email-message body.
    code
    try
                   {               String s1="";
                                  File f1 = new File(the path);
                                  FileInputStream fstream = new FileInputStream(f1); //new
                                  BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
                                  int count=0;
                                  while((s1=br.readLine())!=null )
                                                 count++;
                                                 //out.println("within while loop "+count);
                                                 StringTokenizer st = new StringTokenizer(s1,",");
                                                 if ((st.hasMoreTokens())&&(count>1))
                                            String a=st.nextToken().trim();
                                                 String b=st.nextToken();
                                                 String c=st.nextToken();
                                                 String d=st.nextToken();
                                                 String e=st.nextToken();
                                                 String f=st.nextToken();
                                                 String g=st.nextToken();
                                                 String h=st.nextToken();
                                                 String i=st.nextToken();
                                                 String j=st.nextToken();
                                                 String k=st.nextToken();
                                                 String l=st.nextToken();
                                                 String m=st.nextToken();
                                                 String n=st.nextToken();
                                                 String o=st.nextToken();
                                                 String p=st.nextToken();
                                                 String q=st.nextToken();
                                                 String mail=st.nextToken();
                                                 String s=st.nextToken();
                                                 //out.println("b="+b+"c="+c+"d="+d+"e="+e+"f="+f+"mail="+mail);
                                                 %>
    <%
                                            String to =mail;
                                                 String from =request.getParameter("fromadd");                                        
                                                 String subject ="Statement of Expenses";
                                                 String smtp ="mail.xxxxxxxxxx.com";
                                                 String message="";                                        
                                                 message=message.concat("EMP ID");
                                                 message=message.concat("     ");
                                                 message=message.concat("Name");
                                                 message=message.concat("          ");
                                                 message=message.concat("Dept No.");
                                                 message=message.concat("     ");
                                                 message=message.concat("Acc No.");
                                                 message=message.concat("     ");
                                                 message=message.concat("*****************************************************************************************");     
                                                 message=message.concat(a);
                                                 message=message.concat("     ");
                                                 message=message.concat(b);
                                                 message=message.concat("          ");
                                                 message=message.concat(c);
                                                 message=message.concat("     ");
                                                 message=message.concat(d);
                                                 Properties props = System.getProperties();
                                                 // Puts the SMTP server name to properties object
                                                 props.put("mail.smtp.host", smtp);
                                                 // Get the default Session using Properties Object
                                                 Session session1 = Session.getDefaultInstance(props, null);
                                                 // Create a New message
                                                 MimeMessage msg = new MimeMessage(session1);
                                                 // Set the From address
                                                 msg.setFrom(new InternetAddress(from));
                                                 // Setting the "To recipients" addresses
                                            msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
                                            /* // Setting the "cc recipients" addresses
                                            msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(cc, false));
                                            // Setting the "Bcc recipients" addresses
                                            msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(bcc, false)); */
                                            // Sets the Subject
                                            msg.setSubject(subject);
                                            // set the meaasge in HTML format
                                            msg.setContent(message,"text/plain");
                                            // Set the Date: header
                                            msg.setSentDate(new java.util.Date());
                                            // Send the message
                                            Transport.send(msg);
                                            // Display Success message
                                            result =result.concat("<tr><td>"+b+"</td>"+"<td>"+to+"</td></tr>");
                                                      }//end of if of hasmore element
                                       }// end of while loop
                        out.println(result);                    
    }catch(Exception e)
                        // If here, then error in sending Mail. Display Error message.
                        result="Unable to send your message";
                        out.println("e="+e);
    Any help will be appreciated.
    Thanks and regards.
    Ashvini

    <html>
    <p>
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText("Your Messages");
    MimeBodyPart mbp2 = new MimeBodyPart();
    FileDataSource fds = new FileDataSource("Your Attachments");
    mbp2.setDataHandler(new DataHandler(fds));
    mbp2.setFileName(fds.getName());
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    msg.setContent(mp);
    msg.saveChanges();
    msg.writeTo(System.out);
    msg.setSubject(subject);
    Transport.send(msg);
    </p>
    <B><U>See you can add above code in your program and see the magic</U></B>
    Bye
    regards--
    Ashish
    </html>

  • Need to send the text file using webservice

    Hi,
    I want to send the text file with contains data through oracle pl/sql using webservice. How can i handle this program?
    Kindly share with your details.
    Thanks in advance,
    Maran

    user8732035 wrote:
    I want to send the text file with contains data through oracle pl/sql using webservice. How can i handle this program?Web services supply XML structured data. Not text files.
    PL/SQL supports web services (XML output) and web procedures (text and binary output).
    You need to clarify your requirements.

  • How to sending simple text in the mail body

    Hi friends,
                 How to send simple text in the mail body through ABAP code
       plz send me the related code and setting for that mail.
      Thanks&Regards,
      Srinivas

    try this...
    FORM send_file_as_email_attachment .
      DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
      DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
      DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
      DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
      DATA : i_body TYPE soli_tab WITH HEADER LINE.
    DATA: it_attach LIKE it_display1 OCCURS 0 WITH HEADER LINE.
      DATA: doc_chng LIKE sodocchgi1.
      DATA: tab_lines LIKE sy-tabix.
      DATA: att_lines TYPE i.
    DATA: lv_lines TYPE i.
      DATA: file TYPE string.
      data: g_datum like sy-datum.
      data: g_datum1(10) type c.
      DATA: len TYPE n.
      LOOP AT it_email.
        CLEAR : objpack,
                objhead,
                objbin,
                objtxt,
                reclist.
        REFRESH: objpack,
                 objhead,
                 objbin,
                 objtxt,
                 reclist.
        g_datum =     sy-datum - 1.
        concatenate g_datum6(2) '.' g_datum4(2) '.' g_datum+0(4) into
        g_datum1.
    doc_chng-obj_descr = 'Aged Stock more than 45 Days'.
        CONCATENATE 'Aged Stock more than 45 Days' '-' it_email-vkbur INTO
        doc_chng-obj_descr.
        CONCATENATE 'Please find enclosed Aged Stock Details ( >45days ) report as on'
        g_datum1
        INTO objtxt-line SEPARATED BY space.
        APPEND objtxt.
        objtxt-line = ' '.
        APPEND objtxt.
        objtxt-line = 'Regards'.
        APPEND objtxt.
        objtxt-line = 'LIS SAP Projects'.
        APPEND objtxt.
        objtxt-line =
        'PS: Pls send feedback for futher improvements to SAP office.'.
        APPEND objtxt.
        DESCRIBE TABLE objtxt LINES tab_lines.
        READ TABLE objtxt INDEX tab_lines.
        doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
       CLEAR objpack-transf_bin.
        objpack-head_start = 1.
        objpack-head_num = 1.
        objpack-body_start = 1.
        objpack-body_num = tab_lines.
        objpack-doc_type = 'TXT'.
       objpack-obj_name = 'Run_prog'.
       objpack-obj_descr = 'Agestock.txt'.
       lv_lines = tab_lines.
        APPEND objpack.
    *CONCATENATE 'Plant'   'Material Number' 'Qty(More than 45days)'
    *'Amount' INTO
           it_display SEPARATED BY space.
           append objbin.
           clear: objbin.
        CLEAR:it_display2.
        REFRESH it_display2.
        it_display2-werks = 'Plant|'.
        it_display2-matnr = 'Material Number'.
        it_display2-qty = '|Qty > 45 days'.
        it_display2-amount = '      |Amount'.
        APPEND it_display2.
        it_display2-werks = ''.
        it_display2-matnr = ''.
        it_display2-qty = ''.
        it_display2-amount = ''.
        APPEND it_display2.
        CLEAR : it_display2.
        sort it_display1 by amount descending.
        LOOP AT it_display1 WHERE werks = it_email-vkbur.
         AT FIRST.
    *CONCATENATE 'Plant    '   'Material Number' 'Qty(More than 45days)'
    *'Amount' INTO
           objbin-line SEPARATED BY space.
           append objbin.
           clear: objbin.
         ENDAT.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
            EXPORTING
              input  = it_display1-matnr
            IMPORTING
              output = it_display1-matnr.
          it_display1-qty = TRUNC( it_display1-qty ).
          MOVE-CORRESPONDING it_display1 TO it_display2.
          APPEND it_display2.
          CLEAR:it_display1,it_display2,objbin.
          CLEAR:it_display1.
        ENDLOOP.
        objbin[] = it_display2[].
        DESCRIBE TABLE objbin LINES tab_lines.
        objhead = 'Suug'.
        APPEND objhead.
        objpack-transf_bin = 'X'.
        objpack-head_start = 3.
        objpack-head_num = 1.
        objpack-body_start = 1.
        objpack-body_num = tab_lines.
        objpack-doc_type = 'RAW'.
        objpack-obj_name = 'Run_prog'.
        objpack-obj_descr = 'Agestock.txt'.
        APPEND objpack.
        reclist-receiver = '[email protected]'.
        reclist-rec_type = 'U'.
        APPEND reclist.
    =====================================================================
        CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
          EXPORTING
            document_data              = doc_chng
            commit_work                = 'X'
          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.
        CLEAR : it_email.
      ENDLOOP.
    ENDFORM.                    "send_mail
    Message was edited by:
            Sugumar Ganesan

  • Detect "end of file" while send n numbers files over a socket?

    Hi!
    I�m trying to find a way to detect "end of file" while send n numbers files over a socket.
    What i'm looking for is how to detect on the client side when the file i�m sending is downloaded.
    Here is the example i�m working on.
    Client side.
    import java.io.*;
    import java.net.*;
    public class fileTransfer {
        private InputStream fromServer;
        public fileTransfer(String fileName) throws FileNotFoundException, IOException {
            Socket socket = new Socket("localhost", 2006);
            fromServer = socket.getInputStream();
            for(int i=0; i<10; i++)
                receive(new File(i+fileName));
        private void receive(File uploadedFile) throws FileNotFoundException, IOException {
            uploadedFile.createNewFile();
            FileOutputStream toFile = new FileOutputStream(uploadedFile);
            byte[] buffer = new byte[4096];
            int bytesRead = 0;
            while ((bytesRead = fromServer.read(buffer)) != -1) {
                toFile.write(buffer, 0, bytesRead);
        public static void main(String[] args) {
            try {
                new fileTransfer("testa.jpg");
            } catch (Exception ex) {ex.printStackTrace();}
    }Server side.
    import java.io.*;
    import java.net.*;
    public class fileTransferSend {
        Socket serv = null;
        OutputStream toClient;
        public fileTransferSend(String fileName) throws FileNotFoundException, IOException {
            StartServer();       
            for(int i =0; i<10; i++)
                send(new File(fileName));
        public void StartServer() throws IOException {
            ServerSocket ssocket = new ServerSocket(2006);
            System.out.println("Waiting for incomming");
            serv = ssocket.accept();
            System.out.println("incomming");
            toClient = serv.getOutputStream();
        private void send(File f) throws FileNotFoundException, IOException {
            if(f.exists() && f.canRead()) {
                FileInputStream fromFile = new FileInputStream(f);
                try {
                    byte[] buffer = new byte[4096]; // 4K
                    int bytesRead = 0;
                    System.out.println("sending: "+f.getName());
                    while ((bytesRead = fromFile.read(buffer)) != -1) {
                        toClient.flush();
                        toClient.write(buffer, 0, bytesRead);
                finally {
                    //toClient.close();
                    fromFile.close();
            } else {
                System.out.println("no files");
        public static void main(String[] args) {
            try {
                new fileTransferSend("test.jpg");
            }catch(Exception e) {e.printStackTrace();}
    I know that the client never reads -1 becuase i doesn�t close the stream.
    Is there anyway to tell the client that the file is downloaded?

    A common (and easy) TCP/IP protocol is to send length, followed by data.
    Because TCP/IP is a stream-oriented protocol, a receiver can never absolutely determine where the first packet ends and the second packet begins. So it is common to send the length of the packet, followed by the packet itself.
    In your case, you could send length of file, followed by file data. It should be fairly easy to obtain file length and send that as a 32-bit (or 64-bit value). Here is an idea (not code) for the receiver:
    receive (4) // where 4 = number bytes to receive
    unsigned length = convert 4 bytes to unsigned integer
    while (length != 0)
    n = receive ( length ) // where n = number bytes actually received, and length = number bytes desired
    Or, you can use the concept of an "Escape" character in the stream. Arbitrarily choose an ESCAPE character of 0x1B (although it could be any 8-bit value). When the receiver detects an ESCAPE char, the next character can be either control or data. So for end of file you might send 0x1B 0x00. If the byte to be sent is 0x1B, then send 0x1B 0x1B. The receiver would look something like this:
    b = read one byte from stream
    if (b == 0x1B)
    b = read one byte from stream
    if (b == 0x00) then end of file
    else place b in buffer
    else
    place b in buffer
    Later.

Maybe you are looking for

  • Font size increases in preview

    I am creating a navigation and the font expands with previewing. I would like to know how I can stop this from happening? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html

  • Why JavaControls are not supported in EJBs?

    It's weird that JCs cannot be used in EJBs in Workshop? Is there any good reason why is it so? Thank you, Miklos

  • How can I get the name of the column in Cursor

    hi, how can i derive the name of the columns in cursor e.g suppose I have a cursor cursor c is select * from emp; c1 c%rowtype. for c1 in c I want to display the name of the column how can I do. i don't remember the name, but i need it to be displaye

  • 10.5 update

    I updated last night after the update finished I received a few errors. The first one was error 7 (windows error 127) iTunes was not correctly installed please reinstall. Then iTunes.exe-Entry point not found. The procedure entry point kCMByteStreamN

  • Disk Permissions Repair

    hi. i have done the Permissions Repair but there are 2 files that cannot be repaired: Attenzione: il documento SUID "System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAg ent" the documet ....... is been modified so it cannot