"Premature end of file" when reading in a GZIP file!

Hello i'm trying to figure out what may be causing a "Premature end of file" when reading in a GZIP file!
Basically, what i'm trying to do is read a GZIP file, create an XML file in GZIP format and then validate the GZIPed XML file using the SAX validator and this process works fine for LOW volume data, but for HIGH volume data it seems to have several problems. One problem i was getting was 'Corrupt GZIP trailer', which seems to be a known bug, used an override here and it's ok, and now i'm getting the 'Premature end of file error'.
Here is the error report, see <<<<<<<<<!
START: Wed Aug 03 12:03:41 EDT 2005
Runparms :
host: ....
port: ....
sid: ....
usr: ....
site: ....
val_type: HVPEZ -- previously HVPEX, reason, reading zip file (.gz)
dbo: NULL
ddl: /home/......../HLPVAL/DAT/hlp_ddl_file
table: ......
db_name: NULL
dat_file: /..../...../....../xxxxxxx1.dat.gz
xsd: /home/....../....../XSD/xxxxxxx1.xsd
sql: NULL
debug: NULL
sql query null
pid: 11751
xml: /home/.........../...../XML/xxxxxx1.dat_HVPEZ_xml.gz
rep: /home/.........../...../XML/xxxxxx1.dat_HVPEZ.valrep
fatalError:
setValidity:
Error number : 1
Error starts on line number : 1302706816
Error starts on column position: 8
Error text is : org.xml.sax.SAXParseException: Premature end of file. <<<<<<<<<<<
org.xml.sax.SAXParseException: Premature end of file.
Here i'm reading in a GZIPed file, i then generate the XML and write out another GZIPed file, see <<<<<<<<<<:
       try {
        GZIPOutputStream     gz = new GZIPOutputStream(new FileOutputStream(xp.xml_file));  >>>>>>>> out GZIPed
        PrintWriter        outf = new PrintWriter (gz);
        GZIPInputStream      in = new GZIPInputStream(new FileInputStream(xp.dat_file),4096); <<<<<< in GZIPed
        byte[] buf = new byte[4096];int len=0; String[] sa = new String[NUM_COLS]; int bj=0; char[] ca=new char[1500];
        while ((len = in.read(buf)) > 0)
            String hrec = new String();
            for (int b=0;b<len;b++)
                 Byte byt=new Byte(buf); int bi=byt.intValue(); char c=(char)bi; ca[bj]=c;
if (c == '\n')
hrec=new String(ca); hrec=hrec.trim();
for (int k=0;k<1500;k++) ca [k]=' ';
int prevj=0; j=0;int fcnt=0;
for (int w=0; w<hrec.length(); w++)
if (hrec.charAt(w)=='|')
sa[j]=hrec.substring(prevj,w);fcnt++;
j++; prevj=w+1;
sa[j]=hrec.substring(prevj,hrec.length());fcnt++; bj=-1;
for (int i = 0; i < NUM_COLS; i++)
if (i>(sa.length-1)) { sToken = new String(); } else { sToken = sa[i]; }
if (sToken.indexOf('<')>-1 || sToken.indexOf('>')>-1 || sToken.indexOf('"')>-1 ||
sToken.indexOf('&')>-1 )
String sToken2 = new String();
sToken2 = normalize(sToken);
sToken = sToken2;
outf.write(" <"+_columnNames[i]+">"+sToken+"</"+_columnNames[i]+">"+"\n");
outf.write(" </"+FILE_NAME+">"+"\n");
bj++;
outf.write("</hlp_data>"+"\n");
outf.flush(); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< here if tried every combination of close command ect.
outf.close();
gz.finish();
gz.close();
in.close();
Here i'm reading the GZIPed file from the previous program and this is where the 'Premature end of file' error is occurring. Notice that i'm using an extended class Called WorkingGZIPInputStream, this is to bypass the error message 'Corrupt GZIP trailer' message that seems to occur when processing high volume files, here's a previous link on issue:
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=011624
       HlpValSax1  sx = new HlpValSax1();
       SAXParser   sp = sx.getParser(xp.xsd_file);
       if (
              xp.val_type.substring(0,5).equals("HVPEZ")
           || xp.val_type.substring(0,5).equals("HVPEX")
           || xp.val_type.substring(0,5).equals("HVOEX")
           WorkingGZIPInputStream is = new WorkingGZIPInputStream(new FileInputStream(xp.xml_file),4096); <<<<<<<<<<
           sp.parse(is,dh);
       else
          File file      = new File(xp.xml_file);
          InputStream is2 = new FileInputStream(file);
          sp.parse(is2,dh);
     catch (FileNotFoundException nf) {System.out.println(nf);}
     catch (SAXException sa)          {System.out.println(sa);}
     catch (IOException  io)          {System.out.println(io);}

Turns out things were not exactly the same. When I had done it from disk I would always create a new InputStream when reading the resource, when doing it from the Jar I was reusing it.

Similar Messages

  • Is there a way to control the quality of my pdf file when exporting from a .pse file?

    Is there a way to control the quality of my pdf file when exporting from a .pse file?
    Hi,
    I have 2 pages in all in a .PSE file.
    When I try to export it as .PDF, the quality is very poor. I cannot change it to a better quality.
    Please advise how I can export the file so that i can have better quality.

    Rik Ramsay wrote:
    To expand a little on what Jongware said, normally choosing vector over bitmap will decrease the filesize. If the vector art is very complex though, this will not be true.
    Yup, a logo as bitmap takes up more space than the same as a vector -- unless the vector image is bitmap heavy (think Drop Shadow, Outline Glow; these are actually bitmap effects).
    Also, check your PDF version. "Older" versions do not support live transparency, the latest do. Then again, you cannot use live transparency if you suspect your viewers may be using Mac OS X, because Apple's own PDF viewer sucks big time.

  • Why does a mail-merge in MS Publisher split into multiple files when printed as a pdf file?

    Why does a mail-merge in MS Publisher split into multiple files when printed as a pdf file?

    'Cuz that's what mail merges do.  They create multiple documents based on the parent doc and all the names/addresses in your data tables.
    Perhaps if you describe exactly what you're trying to do & why you need PDF, we can point you to relevant tutorials.
    Nancy O.

  • In Creative Cloud files when I update my INDD file all my sharers lose access to the updated

    In Creative Cloud files when I update my INDD file and export the pdf file all the share links are lost . All my sharers lose access to the updated file. This does not happen at dropbox where when I update a file the share links still work. This is a real nuisance as I want to up date files and keep the link open. Is there a workaround?

    I just had similar experience where I lost links to my files in creative cloud.  There was an update to creative cloud today and my creative cloud on PC was replaced with a new one.  I went to my User Account and found two Creative Cloud Accounts: "Creative Cloud" and "Creative Cloud (unknown)".  The "Creative Cloud (unknown)" is where I found my linked files.  Check to see if you now have two creative accounts on your PC.  This may be the reason????
    I am currently copying and pasting all my files into the current "Creative Cloud" from the "Creative Cloud (unknown)".   I am only focusing on 1 InDesign Doc I have due to tomorrow and had to manually reset all the links to it.  If I have to manually restore all links to my files saved in Creative Cloud--I will blow a gasket on Monday! All PDF files (interactive ones especially) I have saved have lost their links--I don't even want to look at or deal with right now.

  • How to fix file when it says, "Cannot open file " ". Adobe Indesign does not support the file format, a plug-in that supports the file may be missing, or file may be open in another application." It worked one second, I saved and closed the file, then tri

    How to fix file when it says, "Cannot open file " ". Adobe Indesign does not support the file format, a plug-in that supports the file may be missing, or file may be open in another application." It worked one second, I saved and closed the file, then tried to reopen and now it won't work. I am using Adobe InDesign CS5. It is the only version on my comp. I have tried opening on another comp & copying the file – same error comes up. PLEASE HELP

    First check the version of the document with Jongware's script "Identify.jsx" (ExtendScript/JavaScript).
    You can find it here:
    [Ann] Identify Your InDesign File
    If it is CS 5.5 or above, you need someone to open it in the version the script says and export an IDML representation from that. Another way would be to install a 30days version of CS6 or above (CC) and do it yourself.
    In regards of the script showing a result for InDesign files higher than CS6:
    CS7 = CC v9
    CS8 = CC v10 = CC-2014 or CC2014.1
    Uwe

  • Getting repeated values when reading from a text file.

    I need to read from a text file. When the token encounters a particular word (command) I need to read the next line and perform some actions. However, this part is working but it is repeating the values again and again until it encounters the next particular word (command). Hope that someone will help me out, as always when I posted a problem in these forums.
    SetOperations class - contains the set methods
    // Imported packages.========================================================
    import java.util.Vector;
    import java.util.Iterator;
    // Public class SetOperations.===============================================
    public class SetOperations
         // Instance variables.===================================================
         private Vector v = null; // Creates new instance of vector.
         protected int memberCount;
         // Constructor.==========================================================
         public SetOperations()
              v = new Vector();
         } // end constructor.
         // Method isMember.======================================================
         * Checks whether the element is already a member of the set.
         * @return True if Vector v contains Object member.
         public boolean isMember(Object member)
              if (member != null) // only if Object member is not null.
                   return v.contains(member); // returns true if vector already contains member.
              else
                   return false; // returns false if vector does not contain member.
         } // end public boolean isMember(Object member).
         // Method addMember.=====================================================
         * Adds a member to the set.
         * @return Adds Object member to Vector v.
         public void addMember(Object member)
              //if (! v.contains(member)) // only if element is not already a member.
              if (isMember(member) == false) // only if element is not already a member.
                   v.add(member); // adds a member.
         } // end public void addMember(Object member).
         // Method countMember.===================================================
         * Returns the number of members present in the vector.
         * @return Number of elements present in the vector.
         public int countMember()
              return v.size();
         } // end public int countMember().
         // Method isSetEmpty.====================================================
         * Returns true if set is empty.
         * @return True if no elements are present in Vector v.
         public boolean isSetEmpty()
              return v.size() == 0; // returns 0 if no elements are present in the vector.
         } // end of public boolean isSetEmpty().
         // Method printMember.===================================================
         * Displays member/s of the set.
         * @return Prints element/s present in the vector.
         public void printMember()
              for (int i = 0; i < v.size(); i++) // iterates through present members.
                   System.out.println("[" + i + "] " + v.get(i)); // displays member/s present in the vector.
         } // end of public void printMember().
    } // end public class SetOperations.
    SetTextLauncher class - reads from a text file and implements the set operations
    // Imported packages.========================================================
    import java.util.*;
    import java.io.*;
    // Public class SetTestLauncher.=============================================
    public class SetTestLauncher
         // Main method public static void main(String args[]).===================
         public static void main(String args[])
              displayFile("test.txt"); // outputs result from text file.
         // method to display a file on screen
         public static void displayFile (String textFile)
              // Instance variables.===============================================
              // Creates new instances of SetOperations.
              SetOperations setA = new SetOperations();
              SetOperations setB = new SetOperations();
              SetOperations setC = new SetOperations();
              SetOperations setD = new SetOperations();
              SetOperations setE = new SetOperations();
              // Initialisation.
              String line = "", nextLine = "";
              FileReader fr = null;
              try
                   // Opens the file with the FileReader data sink stream.
                   fr = new FileReader(textFile);
                   // Converts the FileReader input stream with the BufferedReader processing stream.
                   BufferedReader br = new BufferedReader(fr);
                   // Iterates through text file reading lines until end of text lines.
                   while (line != null)
                        line = br.readLine(); // reads one line at a time.
                        if(line == null) break; // when the line is null break the loop.
                        // Creates a new instace of StringTokenizer.
                        StringTokenizer st = new StringTokenizer(line);
                        // Loops until there are no more tokens.
                        while (st.hasMoreTokens())
                             String token = st.nextToken(); // reads next token.
                             // Only if the token encounters the String "membera".
                             if(token.equals("membera"))
                                  nextLine = br.readLine(); // gets next line.
                                  setA.addMember(nextLine); // adds a member to the set.
                                  // Displays members present in the set if vector is not empty.
                                  if (! setA.isSetEmpty())
                                       setA.printMember(); // print members present.
                                  // Displays the number of member/s present in the vector.
                                  System.out.println("Number of set members: " + setA.countMember());
              // Catches and displays exceptions.
              catch (FileNotFoundException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              catch (IOException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              finally
                   try
                        // if file is found
                        if (fr != null)
                             // close file
                             fr.close();
                   catch (IOException exp)
                        exp.printStackTrace();
         } // end public static void main(String args[]).
    } // end public class SetTestLauncher.

    Thanks for your interest. Please ignore SetOperations class, it is just the class containing the methods and it works correctly since I checked it without reading from a text file. I marked the part where I think lies my problem in class SetTestOperations.
    The information in the text file is as follows:
    membera
    Hillman
    membera
    Skoda
    membera
    Honda
    membera
    Toyota
    and the result is:
    [0] Hillman
    Number of set members: 1
    [0] Hillman
    [1] Skoda
    Number of set members: 2
    [0] Hillman
    [1] Skoda
    [2] Honda
    Number of set members: 3
    [0] Hillman
    [1] Skoda
    [2] Honda
    [3] Toyota
    Number of set members: 4
    instead of just one set:
    [0] Hillman
    [1] Skoda
    [2] Honda
    [3] Toyota
    Number of set members: 4
    Hope it is easier to understand like this.
    Regards
    Marco
    I need to read from a text file. When the token
    encounters a particular word (command) I need to read
    the next line and perform some actions. However, this
    part is working but it is repeating the values again
    and again until it encounters the next particular
    word (command). Hope that someone will help me out,
    as always when I posted a problem in these forums.
    SetOperations class - contains the set
    methods
    // Imported
    packages.=============================================
    ===========
    import java.util.Vector;
    import java.util.Iterator;
    // Public class
    SetOperations.========================================
    =======
    public class SetOperations
    // Instance
    e
    variables.============================================
    =======
    private Vector v = null; // Creates new instance of
    f vector.
         protected int memberCount;
    Constructor.==========================================
    ================
         public SetOperations()
              v = new Vector();
         } // end constructor.
    // Method
    d
    isMember.=============================================
    =========
    * Checks whether the element is already a member of
    f the set.
         * @return True if Vector v contains Object member.
         public boolean isMember(Object member)
    if (member != null) // only if Object member is not
    ot null.
    return v.contains(member); // returns true if
    if vector already contains member.
              else
    return false; // returns false if vector does not
    not contain member.
         } // end public boolean isMember(Object member).
    // Method
    d
    addMember.============================================
    =========
         * Adds a member to the set.
         * @return Adds Object member to Vector v.
         public void addMember(Object member)
    //if (! v.contains(member)) // only if element is
    is not already a member.
    if (isMember(member) == false) // only if element
    nt is not already a member.
                   v.add(member); // adds a member.
         } // end public void addMember(Object member).
    // Method
    d
    countMember.==========================================
    =========
    * Returns the number of members present in the
    e vector.
         * @return Number of elements present in the vector.
         public int countMember()
              return v.size();
         } // end public int countMember().
    // Method
    d
    isSetEmpty.===========================================
    =========
         * Returns true if set is empty.
    * @return True if no elements are present in Vector
    r v.
         public boolean isSetEmpty()
    return v.size() == 0; // returns 0 if no elements
    ts are present in the vector.
         } // end of public boolean isSetEmpty().
    // Method
    d
    printMember.==========================================
    =========
         * Displays member/s of the set.
         * @return Prints element/s present in the vector.
         public void printMember()
    for (int i = 0; i < v.size(); i++) // iterates
    es through present members.
    System.out.println("[" + i + "] " + v.get(i)); //
    // displays member/s present in the vector.
         } // end of public void printMember().
    } // end public class SetOperations.
    SetTextLauncher class - reads from a text file
    and implements the set operations
    // Imported
    packages.=============================================
    ===========
    import java.util.*;
    import java.io.*;
    // Public class
    SetTestLauncher.======================================
    =======
    public class SetTestLauncher
    // Main method public static void main(String
    g args[]).===================
         public static void main(String args[])
    displayFile("test.txt"); // outputs result from
    om text file.
         // method to display a file on screen
         public static void displayFile (String textFile)
    // Instance
    ce
    variables.============================================
    ===
              // Creates new instances of SetOperations.
              SetOperations setA = new SetOperations();
              // Initialisation.
              String line = "", nextLine = "";
              FileReader fr = null;
              try
    // Opens the file with the FileReader data sink
    ink stream.
                   fr = new FileReader(textFile);
    // Converts the FileReader input stream with the
    the BufferedReader processing stream.
                   BufferedReader br = new BufferedReader(fr);
    // Iterates through text file reading lines until
    til end of text lines.
                   while (line != null)
    line = br.readLine(); // reads one line at a
    at a time.
    if(line == null) break; // when the line is null
    null break the loop.
                        // Creates a new instace of StringTokenizer.
                        StringTokenizer st = new StringTokenizer(line);
                        // Loops until there are no more tokens.
                        while (st.hasMoreTokens())
    String token = st.nextToken(); // reads next
    next token.
    // Only if the token encounters the String
    tring "membera".
                             if(token.equals("membera"))
                                  // *****THE PROBLEM LIES HERE....I GUESS
    // need to read the next line after encountering the word membera in text file
    nextLine = br.readLine(); // gets next line.
    setA.addMember(nextLine); // adds a member to
    ber to the set.
    // Displays members present in the set if
    set if vector is not empty.
                                  if (! setA.isSetEmpty())
                                       setA.printMember(); // print members present.
    // Displays the number of member/s present in
    ent in the vector.
    System.out.println("Number of set members: " +
    s: " + setA.countMember());
              // Catches and displays exceptions.
              catch (FileNotFoundException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              catch (IOException exp)
                   System.out.println(exp.getMessage());
                   exp.printStackTrace();
              finally
                   try
                        // if file is found
                        if (fr != null)
                             // close file
                             fr.close();
                   catch (IOException exp)
                        exp.printStackTrace();
         } // end public static void main(String args[]).
    } // end public class SetTestLauncher.

  • Error when reading back a binary file

    Hello,
    I am writing out a binary file consisting of U32 arrays, packed strings, and clusters. I get error 116 when reading back. As long as I am synchronized on the correct data position why should LV care what I write to the file? In the example I write a simple 16 element array and a time stamp cluster. When reading back the array I get the error. What is the correct way to do mixed structures? Thanks.
    Attachments:
    file write.PNG ‏44 KB

    David,
    You can solve the problem in various ways. The easiest might be to modify the writer VI by wiring a True constant into the "header (F)" input of your first Write File node. That forces LabVIEW to include a four-byte header that specifies the length of the array you are writing.
    When you wire up the reader code the way you did, the length of the array you wire to the "byte stream type " input is irrelevant; by wiring nothing into the "count" input, you are implicitly telling LabVIEW to look for a header to determine the length of the array you are asking it to read. Because you didn't write any header, LabVIEW is interpreting the first four bytes of the array itself as a length. That length doesn't match the actual amount of data present in the datafile, so LabVIEW generates your error.
    An alternative solution would be to leave the writer unchanged and modify the reader VI: wire an I32 constant into "byte stream type" and wire a 16 into "count". The choice depends on what you prefer and whether or not these binary files need to be compatible with some other program or not.
    Another aside: you can dispense with your case that checks whether the datafile already exists. Just change the function input of the Open/Create/Replace to "create or replace" and wire a False constant into its "advisory dialog" input.
    Hope that's clear,
    John

  • How to send a picture in pdf file when it is in jpeg file

    how do I send an attachment in PDF file when it is now in jpeg file. I want to send this attachment in an email.

    Hi,
    Please convert your JPEG files to PDF file using "Convert to PDF" tool at https://createpdf.acrobat.com/signin.html or Adobe Reader X or Reader XI(using Tools >CreatePDF).
    After converting the file please download it to your computer then attach it in your email.
    Thank you.
    Hisami

  • File adapter  reading and writing large files

    Hi we are getting error when trying to process large files using file adapters. files of size 80 to 100 MB. we need to read the inbound files and write them to another folder in another server. the error we are getting is out of memory. gracias

    Hi,
    Use the asynchronous process or a checkpoint(); to see your instance before it time-out.
    --Khaleel                                                                                                                                                                                                                           

  • Can RandomAccessFile directly read a Zip/Gzip file without unzip

    Hi;
    Is it possible using RandomAccessFile to process (read/write) a Zip or Gzip file directly without unzipping the file?
    Thanks,
    Fred

    Is it possible using RandomAccessFile to process ...Sure.
    Of course I can't see any useful way that you could do anything with the binary data unless you fully understand the entire structure of a zip file. And to get to the real data you are going to have to uncompress it anyways. And that means you will need the algorithms.

  • Blank Lines at end of file when using Variable Substitution in File Adapter

    Hi all,
    I'm using variable substitution in a File Adapter, it's refers an element of message, like:
    filename    payload:MESSAGE_INTERFACE,1,FILENAME,1
    The variable substitution is working right, but it's append a BLANK LINE at end of file.
    Anyone knows how to solve this problem ?
    Thanks in advance.

    Hi Regis,
    I suppose you're using content conversion?
    if so try adding
    <b>endSeparator</b> = '0'
    to your last element
    this will delete the default line break at the end
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a>

  • Play sound in specified duration and desired file when reading data with VISA functions ?

    Hi.
    I read data with VISA read function and then I use functions like multiple for showing data on Chart. every thing is OK.
    now I want play a specified sound (like a 3s song in my desired folder) when signal amplitude cross over from specified value. then after desired time, it will be wait for new cross over from specified value and this procedure repeat again until I stop the program. 
    Data comes from MCU and it doesn't stop when system play sound and when system play sound, incoming data for this part (play sound) will be ignore them until specified expired.
    I use this VI for reading data and mentioned part which is sound part is empty and I don't know what I must done ?
    altougth I use another while loop for sound apart because I want save CPU time.
    Thanks.
    Solved!
    Go to Solution.

    I would recommend making the data type of the notifier a cluster that contains a path and a numeric (double).  The path tells the player which file to play.  The numeric is the duration.
    Now for a slightly complicated, but really neat, way to stop your second loop.  Do not use a second notifier.  Instead, send the normal notification but use Not A Path for the path in the cluster.  Your second loop can do a check for the Not A Path and stop when that is recieved.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Error when reading a pdf attachment file in sap inbox

    Hi all,
    I have created a RFC which sends mail from an external user to my sap inbox with attachment.
    the problem is with the PDF attachment where when i received the mail in my sap inbox in sbwp, it says that there is an error that it wasnt correctly decode.
    I used the class cl_document_bcs...
    and used the method add_attachment...
    would plz help me out

    this is my code
    FUNCTION ZMAIL_READ.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(SUBJECT) TYPE  SO_OBJ_DES
    *"     VALUE(TEXT) TYPE  STRING
    *"     VALUE(SENDER) TYPE  ADR6-SMTP_ADDR
    *"     VALUE(RECEIVER) TYPE  ADR6-SMTP_ADDR
    *"     VALUE(ATTACHMENTS) TYPE  Z_T_XATTACH OPTIONAL
    *"  EXPORTING
    *"     VALUE(MESSAGE) TYPE  STRING
    DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
          lo_bcs_send_request TYPE REF TO cl_bcs,
          l_send type ADR6-SMTP_ADDR ,
          l_rec type  ADR6-SMTP_ADDR .
    data: it_text type table of soli,
          wa_text type soli.
    DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
    DATA: lv_recipient_uid TYPE uname,
          lv_recipient_mail TYPE adr6-smtp_addr.
    data: lo_message type ref to cx_send_req_bcs value is initial,
          text_val type string.
    data: it_userlist type table of BAPIUSNAME,
          wa_userlist type BAPIUSNAME.
    data: it_selection_range type table of BAPIUSSRGE,
          wa_selection_range type BAPIUSSRGE.
    data: wa_attachment TYPE ZXATTACH,
          attachment_sub type SO_OBJ_DES.
    DATA: xstr type xstring,
          str TYPE string,
          str1 type string,
          it_str2 type table of soli,
          wa_STR2 TYPE SOLI.
    DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
          wa_solix type solix,
          it_solix type table of solix,
          wa_soli type soli,
          it_soli type table of soli.
    data result TYPE boolean.
    data: i_ext(10) type c,
          i_type type soodk-objtp.
    wa_text-line = text.
    append wa_text to it_text.
    CLASS cl_bcs DEFINITION LOAD.
    try.
    lo_send_request = cl_bcs=>create_persistent( ).
    catch cx_send_req_bcs.
    endtry.
    * Message body and subject
    data: lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
    try.
    lo_document = cl_document_bcs=>create_document(
         i_type = 'RAW'
         i_text =  it_text
         i_subject = subject ).
    catch cx_send_req_bcs.
    catch cx_document_bcs.
    catch cx_address_bcs.
    endtry.
    loop at attachments into wa_attachment.
    attachment_sub = wa_attachment-file_name.
    it_str2 = wa_attachment-attach.
    loop at it_str2 into wa_str2.
      str1 = wa_str2-line.
    try.
    CALL FUNCTION 'SSFC_BASE64_DECODE'
      EXPORTING
        B64DATA                        = str1
    *   B64LENG                        =
    *   B_CHECK                        =
      IMPORTING
        BINDATA                        = xstr
    * EXCEPTIONS
    *   SSF_KRN_ERROR                  = 1
    *   SSF_KRN_NOOP                   = 2
    *   SSF_KRN_NOMEMORY               = 3
    *   SSF_KRN_OPINV                  = 4
    *   SSF_KRN_INPUT_DATA_ERROR       = 5
    *   SSF_KRN_INVALID_PAR            = 6
    *   SSF_KRN_INVALID_PARLEN         = 7
    *   OTHERS                         = 8
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    catch cx_sy_dyn_call_illegal_type.
    endtry.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
          EXPORTING
            INPUT       = xstr
            ENCODING    = 'UTF-8'
    *        REPLACEMENT = '?'
    *        IGNORE_CERR = ABAP_TRUE
          RECEIVING
            CONV        = loc_CONV.
    TRY.
        CALL METHOD LOC_CONV->READ
          IMPORTING
            DATA = STR.
    CATCH CX_SY_CONVERSION_CODEPAGE.
    CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
    CATCH CX_PARAMETER_INVALID_TYPE.
    CATCH CX_PARAMETER_INVALID_RANGE.
    ENDTRY.
    wa_solix-line = xstr.
    append wa_solix to it_solix.
    wa_soli-line = str.
    append wa_soli to it_soli.
    endloop.
    try.
    CALL FUNCTION 'SA_KW_RFC_FILENAME_EXT_GET'
      EXPORTING
       AREA            = 'IWBSOLAR'
        MIMETYPE        = wa_attachment-type
    IMPORTING
       EXTENSION       = i_ext
    catch cx_sy_dyn_call_illegal_type.
    endtry.
    i_type = i_ext.
    if i_ext <> 'pdf'.
    try.
      lo_document->add_attachment(
      EXPORTING
        i_attachment_type = i_type
        i_attachment_subject = attachment_sub
        i_att_content_hex = it_solix ).
           CATCH cx_document_bcs.
    endtry.
    clear wa_solix.
    refresh it_solix.
    else.
    TRY.
      CALL METHOD LO_DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE     = i_type
          I_ATTACHMENT_SUBJECT  = attachment_sub
    *      I_ATTACHMENT_SIZE     =
    *      I_ATTACHMENT_LANGUAGE = SPACE
          I_ATT_CONTENT_TEXT    = it_soli
    *      I_ATT_CONTENT_HEX     =
    *      I_ATTACHMENT_HEADER   =
       CATCH CX_DOCUMENT_BCS .
      ENDTRY.
    ENDIF.
    endloop.
    try.
    lo_send_request->set_document( lo_document ).
    CATCH cx_send_req_bcs.
    endtry.
    wa_selection_range-PARAMETER = 'address'.
    wa_selection_range-field = 'e_mail'.
    wa_selection_range-sign = 'I'.
    wa_selection_range-option = 'EQ'.
    wa_selection_range-low = receiver.
    append wa_selection_range to it_selection_range.
    try.
    CALL FUNCTION 'BAPI_USER_GETLIST'
    * EXPORTING
    *   MAX_ROWS              = 0
    *   WITH_USERNAME         = ' '
    * IMPORTING
    *   ROWS                  =
    TABLES
        SELECTION_RANGE       = it_selection_range
    *   SELECTION_EXP         =
        USERLIST              = it_userlist
    *   RETURN                =
    catch cx_sy_dyn_call_illegal_type.
    endtry.
    read table it_userlist into wa_userlist index 1.
    try.
      lo_sender = cl_cam_address_bcs=>create_internet_address( sender ).
      lo_send_request->set_sender(
         EXPORTING
         i_sender = lo_sender ).
    catch cx_send_req_bcs.
    catch cx_document_bcs.
    catch cx_address_bcs.
      return.
    endtry.
    try.
        lo_recipient = cl_sapuser_bcs=>create( wa_userlist-USERNAME ).
        lo_send_request->add_recipient(
           EXPORTING
             i_recipient = lo_recipient ).
    *         i_express = 'X' ).
      catch cx_send_req_bcs.
      catch cx_document_bcs.
      catch cx_address_bcs.
    endtry.
    try.
    ** Send email
         LO_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
         lo_send_request->send( EXPORTING
         i_with_error_screen = ' '
         RECEIVING
         result = result ).
         COMMIT WORK.
    CATCH CX_DOCUMENT_BCS.
    CATCH CX_SEND_REQ_BCS INTO lo_message.
    CATCH CX_ADDRESS_BCS.
    text_val = lo_message->IF_MESSAGE~GET_TEXT( ).
    endtry.
    if result = 'X'.
      message = 'E-Mail sent'.
    else.
      message = 'E-Mail not sent'.
    endif.
    ENDFUNCTION.

  • Preserving CDATA when reading then writing XML files

    Hi All,
    I have some source XML that needs to have an update applied and then written back out into a new directory. This all works fine except some of the other elements have values with CDATA around them in the input file and on the output file the CDATA is replaced and the characters substituted ie: turned in &amp;
    This is (I guess) default behaviour but I would like the CDATA preserved and writing out into the new XML file.
    How can I do this ?
    Regards,
    Steve

    Found the answer :
            DOMParser dp = new DOMParser();
            dp.retainCDATASection(true);
            dp.parse(xmlFile);
            xmlDoc = (XMLDocument)dp.getDocument();

  • How do I stop Dreamweaver from updating the Test server copy of a file when I open the local file?

    The subject says it all. Every time I open a file, Dreamweaver connects to the testing server and uploads the local file to the test server.
    I want to stop this behaviour.  It's annoying!

    My testing server is IIS running on my local machine.
    The "local" copy of the file is actually on a remote share.  I have the test server copy open in Notepad++.  The two files are identical save for on extra line in the copy on the testing server.  When I open the "local" copy in Dreamweaver, it shows me that some file activity is being done, and then Notepad++ tells me the file has changed and do I want to reload it.  If I do, that extra line vanishes.
    When I check the file activity log, it shows that the file activity is complete.
    I haven't mentioned the production server because it doesn't seem to be affected, but we do have one.

Maybe you are looking for