How to skip blank line (EOF char) at the end of the file while creating ?

Hi,
In my program I have to create a file in Text mode using OPEN DATASET statement. This file is being sent to a third party system for their processing. I came to know while creating the file using OPEN DATASET, one LF character is inserted end of the file resulting a blank line end of the file. Thus if my internal table contains 5 reocrds, in the created text file I can see 6 lines where last is a blank. My question is how to remove this blank line which is causing issue in the thirdparty system.
Here is the Code I have used.
   TRY.
Write the file in Text Mode
        OPEN DATASET lv_outpf FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
                             WITH SMART LINEFEED
                              MESSAGE lv_msg.
        IF lv_msg IS NOT INITIAL.
          WRITE / lv_msg.
          EXIT.
        ENDIF.
        LOOP AT itab_new INTO st.
          TRANSFER st TO lv_outpf.
        ENDLOOP.
        CLOSE DATASET   lv_outpf.
      CATCH cx_root.                                    "#EC No Handler
    ENDTRY.

an effective way to do it:
open your dataset in binary mode, transfer the records but between each record transfer the LF (or CRLF according to your need)
after the last record you don't transfer the LF

Similar Messages

  • How to skip blank line in FCC

    Hi,
    How to deal with blank rows in FCC for fixed width file?
    I want to ignore these records as they will fail the message in mapping.
    thanks,
    Anirudh.

    Hi
    Look this thread might help u
    Blank line in receiver file adapter content conversion

  • Skipping Blank Lines in text File

    I am working on an assignment in which i have to read from a text file and store the strings individually. The problem i have is that the text file has blank line between each set of strings. So i figured to use "fin.nextLine();" to skip that blank line and continue with storing the values. but i get
    "Exception in thread "main" java.util.NoSuchElementException: No line found
         at java.util.Scanner.nextLine(Unknown Source)
         at processmsg.ProcessMessages.choice1(ProcessMessages.java:68)
         at processmsg.ProcessMessages.main(ProcessMessages.java:25)"
    which is where the fin.nexLine() is at. How can i just skip that blank line?
    System.out.println("Please enter the file location");
              Scanner stdin = new Scanner(System.in);
              String fileName = stdin.nextLine();
              // read the information from the file
              try {
                   Scanner fin = new Scanner(new File(fileName));
                   String tSendName = fin.nextLine();
                   while(tSendName != null)
                        String tRecieveName = fin.nextLine();
                        String tPhoneNumber = fin.nextLine();
                        String tDate = fin.nextLine();
                        String tTime = fin.nextLine();
                        String tStatus = fin.nextLine();
                        String tMessage = fin.nextLine();
                        PhoneMessage phonemessage = new PhoneMessage(tSendName, tRecieveName,
                                  tPhoneNumber, tDate, tTime, tStatus, tMessage);
                        fin.nextLine();
                        tSendName = fin.nextLine();

    don't know if you want the whole code, the whole code is kind of large and spread out over 3 different classes. and yes the text file is standard
    sender
    reciever
    phone number
    date
    time
    status
    message
    sender
    reciever
    phone number
    date
    time
    status
    message
    sender
    reciever
    phone number
    date
    time
    status
    message
    private static void choice()
              // scan the file location from the user
              System.out.println("Please enter the file location");
              Scanner stdin = new Scanner(System.in);
              String fileName = stdin.nextLine();
              // read the information from the file
              try {
                   Scanner fin = new Scanner(new File(fileName));
                   String tSendName = fin.nextLine();
                   while(tSendName != null)
                        String tRecieveName = fin.next();
                        String tPhoneNumber = fin.next();
                        String tDate = fin.nextLine();
                        String tTime = fin.nextLine();
                        String tStatus = fin.nextLine();
                        String tMessage = fin.nextLine();
                        PhoneMessage phonemessage = new PhoneMessage(tSendName, tRecieveName,
                                  tPhoneNumber, tDate, tTime, tStatus, tMessage);
                        // skip blank line between entries
                        fin.nextLine();
                        // test date string for correct format
                        int month = Integer.parseInt(tDate.substring(0,2));
                        int day = Integer.parseInt(tDate.substring(3,5));
                        int year = Integer.parseInt(tDate.substring(6,10));
                        // test time string for correct format
                        int hour = Integer.parseInt(tTime.substring(0,2));
                        int minute = Integer.parseInt(tTime.substring(3,5));
                        int second = Integer.parseInt(tTime.substring(6,8));
                        tSendName = fin.nextLine();
                        msgList.add(phonemessage);
                   fin.close();
              } catch (FileNotFoundException e) {
                   System.out.println("The file " + fileName + " was not found!");
              } catch (java.lang.NumberFormatException e) {
                   System.out.println("The date and/or time is not of the correct format");
         }

  • How to suppress blank line in top and end of portlet

    I created one small report (portlet) however when i execute this one; i remarked there is one blank line in the top
    and another one at the end of the report. How can i eliminate these lines. I need this space to be able to see
    a lot of information in the same page.
    I use portal 3.0.9.2

    After developping a lot of portlet and read a lot of TAR on metalink and a lot of message on OTN i discovered the solution.
    Wnen you create one report with the wizard there is no way to erase the first line ( header ) in the result.
    Second for the last line of the results ( blank line ) ; the problem is with netsacpe 4.75 ( no problem with internet explorer )
    with Netscape you will see one blank line and not with internet explorer ( confirm with Oracle support )
    Anyway in the place of developping one report with the wizard ; you can copy and paste your sql statement of your report
    inside one dynamic page and control all you want.
    I will give you one example than i created; i hope it will help other persons like me
    ( we need to read a lot of thing to do something really simple with portal )
    <HTML>
    <HEAD>
    <style type="text/css">
    <!--
    .TabFontText {
    font-family: Arial, Helvetica;
    font-size: 9pt;
    -->
    </style>
    </HEAD>
    <BODY>
    <ORACLE>
    begin
    htp.p('<table cellspacing=0>');
    for c in ( select '<a TARGET="_blank" HREF="http://'||ssdw_portal.pkg_globl.
    fnc_get_server_port||'/pls/portal30/docs/FOLDER/SSDW_AIDE/'||replace(item.name,
    ' ','+')||'">'||item.display_name||'</a>' filename , to_char(item.updatedate,'dd/mm/yyyy hh24:mi') last_updated
    FROM portal30.wwsbr_all_items item ,
    portal30.wwsbr_all_folders folder
    WHERE folder.name = 'SSDW_AIDE'
    and folder.caid = item.caid
    and folder.id = item.folder_id
    and item.language = 'us'
    and item.name like 'GUIDE%ANG%'
    order by item.name ) loop
    htp.p('<tr>');
    htp.p('<td bgcolor=#CCCCCC width=325>');
    htp.p('<font class="TabFontText" >');
    htp.p(c.filename);
    htp.p('</td>');
    htp.p('</font>');
    htp.p('<td bgcolor=#CCCCCC width=125>');
    htp.p('<font class="TabFontText">');
    htp.p(c.last_updated);
    htp.p('</td>');
    htp.p('</font>');
    htp.p('</tr>');
    end loop;
    htp.p('</table>');
    end;
    </ORACLE>
    </BODY>
    </HTML>
    Marc Fortin
    [email protected]

  • How to remove the blank lines at the end of the JTextArea .

    Hi,
    I need to remove the blank lines in the JTextArea at the end. Suppose i am giving 'A' in the first line and press the enter key two times, after i am giving the 'B' in the third line and press enter key for two times. I need to remove, the last two lines of JTextAreae, . How i can remove these lines?

    String#trim() removes all whitespace from both ends of the String.
    The requirement was to remove line breaks from the end of the String only.
    String#replaceAll with a suitable regex would do the trick. Untested regex for this:text.replaceAll("[\\n\\r]+$", "")db

  • How to insert blank lines in the ALV output.

    Hi Friends,
    Could any body help me out How to insert blank lines in the ALV output.?? Any Code pls...
    Thank you,
    Vikram.C

    hi vikram
    do like this
    In the fieldcatalog table all the fields should be in editable mode
    ie lw_fcat-edit = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    i_callback_user_command = 'USER_COMMAND'
    is_layout = lv_layout
    it_fieldcat = lt_fcat[]
    i_save = 'A'
    is_variant = lv_variant
    TABLES
    t_outtab = lt_license[]
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " display_data
    *& Form user_command
    FORM user_command USING r_ucomm TYPE sy-ucomm
    rs_selfield TYPE slis_selfield.
    CASE r_ucomm.
    WHEN 'ADD'. "
    data: lv_ind type i.
    data: lv_line type i.
    describe table lt_license lines lv_line.
    loop at lt_license into lw_license.
    lv_ind = sy-tabix.
    if lv_ind = lv_line.
    append initial line to lt_license.
    endif.
    endloop.
    ENDCASE.
    ENDFORM. "user_command
    reward points if useful
    Rohan

  • How to add blank line below the table/row whenever there is no data

    Hello Everyone,
    I have a table in my report template like below:-
    Children / Dependents: Name / Comments: Grandchildren: Name / Comments:
    Son John Daughter Smith
    Daughter Laura Son Kevin
    Son Bill None NA
    When i run the report I need to achieve the following conditions:-
    Condition 1: Loop through all rows and whenever there is data in any row in the table...I need to Populate and print it.
    Condition 2: When Loop is ended, when you see there is no data in any row in the table... add a dash line at the end of the table.
    Condition 3: Total no of populated rows + blank dash line <= Max no of rows in DB. And when max no of populated rows in report = max no of rows in DB/UI ... don’t print dash line.
    I want to achieve these conditions. Can you please help me.
    Thanks..Rithesh

    Hello Everyone,
    I have a table in my report template like below:-
    Children / Dependents: Name / Comments: Grandchildren: Name / Comments:
    Son John Daughter Smith
    Daughter Laura Son Kevin
    Son Bill None NA
    When i run the report I need to achieve the following conditions:-
    Condition 1: Loop through all rows and whenever there is data in any row in the table...I need to Populate and print it.
    Condition 2: When Loop is ended, when you see there is no data in any row in the table... add a dash line at the end of the table.
    Condition 3: Total no of populated rows + blank dash line <= Max no of rows in DB. And when max no of populated rows in report = max no of rows in DB/UI ... don’t print dash line.
    I want to achieve these conditions. Can you please help me.
    Thanks..Rithesh

  • How to skip a line like !-- PJG STAG 4700 -- ?

    I am doing a project that requires me to parse a documents.
    The documents have different tags, and main text area between <TEXT> and </TEXT>, here is an example:
    <DOC>
    <DOCNO> FT911-3 </DOCNO>
    <HEADLINE>
    FT 14 MAY 91 / International Company News: Contigas plans DM900m east
    German project
    </HEADLINE>
    <!-- PJG 0012 frnewline -->
    <TEXT>
    CONTIGAS, the German gas group 81 per cent owned by the utility Bayernwerk, said yesterday that it intends to invest DM900m in the next four years.
    </TEXT>
    </DOC>
    Since the main porpuse is to read text body, so I will skip those text between tags except <TEXT></TEXT>.
    I can use switch statement to skip the text between tags, but I can't find a way to skip a line like:
    <!-- PJG 0012 frnewline -->
    any suggestions?

    Let me correct my former statement for jesper1, this is SGML( Standard Generalized Markup Language)
    document, early version for XML, so jesper1 are kind of right.
    For freekee:
    First step:
    /** returns a hashmap of initialized tags
        *  This way we can have more than one tagstring map to the same
        *  tag type.  For example, we might have DOCID and DOCUMENTID both
        *  map to the BEGIN_DOCID tag.
       private HashMap initTags() {
            int NUM_TAGS = 20;
            Integer tagVals[] = new Integer[NUM_TAGS];
            HashMap tags = new HashMap();
            for (int i = 0; i < NUM_TAGS; i++) {
                tagVals[i] = new Integer(i);
            tags.put("<DOC>",             tagVals[0]);
            tags.put("</DOC>",            tagVals[1]);
            tags.put("<PARENT>",          tagVals[2]);
            tags.put("<TITLE>",           tagVals[2]);
            tags.put("<TL>",              tagVals[2]);
            tags.put("<HEADLINE>",        tagVals[2]);
            tags.put("</PARENT>",         tagVals[3]);
            tags.put("</TITLE>",          tagVals[3]);
            tags.put("</TL>",             tagVals[3]);
            tags.put("</HEADLINE>",       tagVals[3]);
            tags.put("<TEXT>",            tagVals[4]);
            tags.put("</TEXT>",           tagVals[5]);
            tags.put("<DOCID>",           tagVals[6]);
            tags.put("<DOCNO>",           tagVals[6]);
            tags.put("</DOCID>",          tagVals[7]);
            tags.put("</DOCNO>",          tagVals[7]);
            tags.put("<DATELINE>",        tagVals[8]);
            tags.put("</DATELINE>",       tagVals[9]);
            return tags;
    second step:
    /* this will read the file of documents, parse them and return a list of document */
      /* objects.  Could be called the document factory since it generates useful       */
      /* document objects that can then be indexed.                                     */
      /* Documents are created when an end of document tag is encountered.              */
      public ArrayList readDocuments() {
          String      dateline     = null;
          String      docName      = null;
          ArrayList   documentList = new ArrayList();
          boolean     done         = false;
          int         documentID   = 0;
          int         length       = 0;
          int         offset       = 0;
          String      title        = null;
          boolean endOfFile = false;
          while (! done) {
              System.out.println("Token --> " + in.sval);
              /* check to see if we hit the end of the file */
              try {
                  if (in.nextToken() == in.TT_EOF) {
                      done = true;
                      endOfFile = true;
                      continue;
                  /* now test for a tag */
                  switch (in.ttype) {
                    // where does "END_DOC" come from?
                    // Since: tags.put("</DOC>", tagVals[1]), so </DOC> is mapped to value 1.
                    // and since in the initialization: private final static int END_DOC = 1;
                    // in.ttype returns a int, like TT_WORD
                 case END_DOC:
                            /* when we hit the end of a document, lets create a new object */
                            /* to store info needed for indexing                           */
                            length = in.currentPosition - offset;
                            Document d = new Document (documentID, docName, title, dateline,
                                             inputFileName, offset, length, distinctTerms);
                            ++documentID;
                            documentList.add(d);
                            break;
                    /* initialize document attributes when we start a new doc */
                    case BEGIN_DOC:
                            System.out.println("Started new document");
                            offset = in.currentPosition;
                            docName = null;
                            dateline = null;
                            title = null;
                            distinctTerms = new HashMap();
                            break;
                 case BEGIN_DOC_NAME:
                         docName = readNoIndex(in, END_DOC_NAME);
                            break;
                 case BEGIN_TITLE:
                            title = readNoIndex(in, END_TITLE);
                            break;
                    case BEGIN_DATELINE:
                            dateline = readNoIndex(in, END_DATELINE);
                            break;
                    case BEGIN_TEXT:
                            readText(in, stopWords);
                            break;
                    /* only time we get a word here is if its outside of any tags */
                    case WORD:
                            break;
                 default: {
                        System.out.println("Unrecognized tag: "+in.sval);
                        System.exit(-1);
              } catch (IOException e) {
                      System.out.println("Exception while reading doc ");
                      e.printStackTrace();
          return documentList;
       }Did I answer your question correctly?

  • Extra Blank line inserted at the end of the target file

    Hi,
    This is File to File senario and target files created with a extra blank line at the end of the file.
    Below is the source file structure and the content.
    <ns0:MT_MOD_FL xmlns:ns0="http://file2file/MES">
       <EMPLOYEE>
          <ID>12</ID>
          <Name>SREENI</Name>
          <Designation>M2</Designation>
       </EMPLOYEE>
       <EMPLOYEE>
          <ID>121</ID>
          <Name>RAJA</Name>
          <Designation>M3</Designation>
       </EMPLOYEE>
    </ns0:MT_MOD_FL>
    Below is the generated target file
    12     SREENI     M2
    121     RAJA     M3
    Here Generated target file suppose to have only two line instead of 3.
    What exactly do i need to change to generate the file with 2 line.
    I am not using any mapping as both source and target message structure are same.
    IN FCC i used only fieldSeparator, even i have not used endSeparator.
    Thanks in Advanace...

    Hi! Raghu,
    Just go through the below Help..documantation
    [http://help.sap.com/saphelp_nw04/helpdata/en/0d/5ab43b274a960de10000000a114084/frameset.htm]
    NameA.endSeparator
    To define an additional string as a separator after the last column in a row, specify it here. The system skips this string when it processes the last column (otherwise the system would treat it as part of the last column).
    NameA.fieldSeparator
    If you make an entry here, the system expects that the structure contains the specified character string (one or more characters) as a separator between the individual columns.
    If you have not made an entry for fieldFixedLengths, this is the only specification to identify the individual columns in a row.
    If you made a specification for fieldFixedLengths, the extra length of the separator is taken into account, but no further consistency checks are performed.
    Regards::
    Amar Srinivas Eli

  • How to find end of the Page in Crystal ? or I need to add one Horizontal line at the end of the page.--- URGENT HELP NEEDED

    Hi friends,
    I need to add one horizontal line  for the detail section at the end of the page.
    I tried to put that line in page footer and i tried with Box also. Both are not properly working. Some space problem is coming.
    Is there any feature to find end of the Page.
    I want report format like this.
    set id  |  set name |  date  Name
      1         x           dddd   vijay
                            dddd   sarathi
                            dddd    reddy
    (End of the page)
    Thanks in advance...
    vijay.

    Do you know how many detail records are showing up per page?
    If you do - you could create a Details B section that is suppressed except for on Record N (where N is a counter, and N is the last Detail record that will show up on a page).
    The Page footer is indeed built so that it will be rendered at the bottom of your physical page of paper.

  • How to add a new line at the end of eTEXT file

    Hi,
    I have modified the RTF template for the R12.1.3 Positive Pay File report (IBYPOS_PAY_en.rtf). Everything is good, except that the bank requires a "T" (Capital T) character in a new line at the end of the text file. Has any of you came across this before? How do I modify the template to achieve this?
    Thank you,
    Sinan Topuz

    I believe this is related to BI Publisher. Any comments would be greatly appreciated.
    Thanks,
    Sinan

  • How can I Read lines of data from a file starting at the end of the file??

    Can anyone help me with how to read lines of data starting from the end of a file instead of the beginning?? I do not want to load the entire file into memory as the files are very rather large. Instead I want to start at the end of the file and read lines backward , until I find the particular data item i am searching for, then stop.
    Can this be done in Java ? I know it can be done in Perl.
    Thanks.

    Thanks for your suggestion about the RandomAccessFile, I did actually thought about that approach , but wasn't sure it would work.
    I do not want to read the file in a sequential forward manner because the files contain large number of lines of data that have already been processed and therefore there is no need to reprocess these lines of data.
    The Unprocessed lines are always at the the end of the file and these are the data lines I am interesting in getting at without having to read the entire file. Therefore, i figure that if I can read the data from the end of the file then this would be much more efficient.

  • IDoc to file - how to delete a blank record at the end of the file.

    Hi,
    My senario is IDoc to file.  I have successfully implemented this using FCC. But when i checked the flat file, it has a blank record at the end of the file( i think PI adds one blank line/record at the end of the file).  Please suggest me What i need to do, to delete the blank record .
    Thanks & regards
    Sreeni

    Kindly Check below.
    Check whether the problem is at mapping level of  adapter level.. to do this count no. of rows/IDOC before mapping and after mapping in IE and no. of rows in the output file.
    Thnx
    Subbu

  • How to highlight a line in a text stream and position the cursor at the end.

    I would like to select a line in a text control data stream, highlight the text, and place the cursor at the end of the line so that the text control can be edited at that point.

    Depends on what you mean by "highlight". If you mean highlight in the sense of when you use the mouse to select text, then you can't do that and then place the cursor at the end, since that would effectively "unhighlight" the text. You need to use a different kind of "highlight", like turning the text bold or something. This KB article talks about highlighting particular characters: How Do I Highlight Particular Characters in a String Control?
    See attached for simple example. Modify as needed.
    Attachments:
    Text Select.vi ‏19 KB

  • Utl_file.utl_raw adds a line feed at the end of the line. How to avoid it.

    utl_file.utl_raw adds a line feed at the end of the line. I have to send some binary files to my vendor and they do not want a line feed at the end of the line.
    When I execute the sample program below, it creates a file with a line feed(chr(10)) at the end of the line. When I do dump in hexa, it shows a character x0A
    How to avoid the line feed at end of line?
    We are using Oracle 9i on unix platform.
    declare
    l_output           utl_file.file_type;
    v_raw      raw(32767);
    v_trlr_rec_code      VARCHAR2(2);
    v_trlr_evnt_title      VARCHAR2(6);
    begin
    l_output := utl_file.fopen( 'RM_MHE_IN_DIR', 'abc.dat', 'w', 14 );
    v_trlr_rec_code      := '99';
    v_trlr_evnt_title      := 'STARTD';
    v_raw := HEXTORAW(v_trlr_rec_code) || utl_raw.cast_to_raw(v_trlr_evnt_title);
    utl_file.put_raw( l_output, v_raw );
    utl_file.fflush( l_output );
    utl_file.fclose( l_output );
    dbms_output.put_line( utl_raw.cast_to_varchar2( v_raw ) );
    EXCEPTION
    WHEN OTHERS THEN
         dbms_output.put_line( sqlerrm );
    end;
    /

    oops, sorry i overlooked the fact that the db is 9i; thanks for pointing it out Solomon.
    Not sure about this, but a workaround could be to remove the "\n" characters at the end of each line using one of the many Unix utilities after the file has been created.
    isotope

Maybe you are looking for