Write XML in specific line

How to write XML file in specific line or specific value ? i want write selectedLayers[0].opasity OR scale in XML file in specific line (btn2)
XML file (0000.xml)
<xml>
          <btn1>56</btn1>
          <btn2>666</btn2>
          <btn3>23</btn3>
</xml>                                    
Read file
comp = app.project.activeItem
var config = new File ("/g/0000.xml");
                        config.open("r");
               var xmlString = config.read();
                var myXML = new XML(xmlString);
comp.selectedLayers[0].opacity.setValue(parseFloat(myXML.btn1))
               config.close();
and how write in specific line?
config.open("w");
xxx = btn1 = "245"
config.write(xxx)

i try this
function SaveFile() {
config.write("<xml>\n<btn1>"+opacity.value+"</btn1>\n</xml>")
not what I wanted but its work... and if you want array parameter, use this:
config.write("<xml>\n<btn1>"+position.value[0]+","+position.value[1]+"</btn1>\n</xml>")

Similar Messages

  • Write to a specific line in text file

    hi let say text file with five lines
    i need to write it in a specific line example line 3.
    how to do tht,
    thk u

    In Mike's example, you cna change the constant 2 to a control which allows ytou to select which line to write to.
    2 meaning the third position becasue indexing starts at 0. 

  • Writing to a specific line

    How would I write to a specific line?

    Hi All,
    i'm hoping someone can help me here.
    I need to write to a specific line of a file.
    There are two files.
    i find "aString" on line 4 of file 1. this means i write "bString" on line 4 of file 2.
    so far i can identify which line i have to write to but i don't know how to write to a specific line of a file.
    Any help is most appreciated.
    Many Thanks
    Ben

  • Search files for specific lines of data

    Hi all, I have a problem that I hope someone can help me with.
    I need to find a way to search for specific lines of data on a file.
    Here's the setup.... say for example I have 10 files, each filled with log files containing data like the date they were created and also certain information they were monitoring.
    From a Java applet, a user types in information that they want (for example, only lines that were created between 2002/04/04 and 2002/05/05 and only ones tagged with "Caution"). I need a way to grab all of those line from each of the files, without having to open each file, read each line and check for each search request. Instead, I want to simply grab all of the data at once, or at the very least, grab all of the data from the first file, then grab all of the data from the second file etc, without having to search each individual line. (the reason I'm hoping for a command like this is because there will eventually be thousands of files that need to be searched, and opening each one, and then search each line one by one would take too long.
    Sort of like a grep command in Linux. Does Java have a similar command?
    Any information or samples would be greatly appreciated!

    I don't know how much control you have over the files that you have to search.
    Searching XML files would be a lot easier because XPATH queries will work exactly like SQL... The only problem being if your files are not XML at all.
    If you have control over the format of these files you are trying to search, then try XML... else you might have to write a batch utility that runs every N seconds and converts data in these files to XML format files conforming to a specific format and then your applet could query the XML files.
    There will be a small concurrency issue there, though; As there will be at least some time consumed by the thread.

  • Having trouble reading specific lines from a text file and displaying them in a listbox

    I am trying to read specific lines from all of the text files in a folder that are reports. When I run the application I get the information from the first text file and then it returns this error: "A first chance exception of type 'System.ArgumentOutOfRangeException'
    occurred in mscorlib.dll"
    Below is the code from that form. 
    Option Strict On
    Option Infer Off
    Option Explicit On
    Public Class frmInventoryReport
    Public Function ReadLine(ByVal lineNumber As Integer, ByVal lines As List(Of String)) As String
    Dim intTemp As Integer
    intTemp = lineNumber
    Return lines(lineNumber - 1)
    lineNumber = intTemp
    End Function
    Public Function FileMatches(ByVal folderPath As String, ByVal filePattern As String, ByVal phrase As String) As Boolean
    For Each fileName As String In IO.Directory.GetFiles(folderPath, filePattern)
    If fileName.ToLower().Contains(phrase.ToLower()) Then
    Return True
    End If
    Next
    Return False
    End Function
    Private Sub frmInventoryReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim intcase As Integer = 1
    Dim strTemp, strlist, strFile As String
    Dim blnCheck As Boolean = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Do While blnCheck = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
    Dim allLines As List(Of String) = New List(Of String)
    Do While objReader.Peek <> -1
    allLines.Add(objReader.ReadLine())
    Loop
    objReader.Close()
    strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
    lstInventory.Items.Add(strlist)
    intcase += 1
    strTemp = intcase.ToString
    strFile = "Report Q" & intcase.ToString & ".txt"
    blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
    Loop
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim intcase As Integer = 1
    Dim strTemp, strlist, strFile As String
    Dim blnCheck As Boolean = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Do While blnCheck = True
    strFile = "Report Q" & intcase.ToString & ".txt"
    Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
    Dim allLines As List(Of String) = New List(Of String)
    Do While objReader.Peek <> -1
    allLines.Add(objReader.ReadLine())
    Loop
    objReader.Close()
    strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
    lstInventory.Items.Add(strlist)
    intcase += 1
    strTemp = intcase.ToString
    strFile = "Report Q" & intcase.ToString & ".txt"
    blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
    Loop
    End Sub
    End Class
    Sorry I'm just beginning coding and I'm still a noob. Any help is appreciated. Thank you!

    Ok, so if I'm following this correctly you should be able to just loop through all of the files in that folder whose file name matches the pattern and then read the first 22 lines, recording only the first and the last.
    Exactly how you store the animal data probably depends on how you are going to display it and what else you are going to do with it.  Is there anything other than name and cage number that should be associated with each animal?
    You might want to make a dataset with a datatable to describe the animal, or you might write a class, or you might just use something generic like a Tuple.  Here's a simple class example:
    Public Class Animal
    Public Property Name As String
    Public Property Cage As String
    Public Overrides Function ToString() As String
    Return String.Format("{0} - {1}", Name, Cage)
    End Function
    End Class
    With that you can use a routine like the following to loop through all of the files and read each one:
    Dim animals As New List(Of Animal)
    Dim folderPath As String = "E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\"
    For Each filePath As String In System.IO.Directory.GetFiles(folderPath, "Report Q?.txt")
    Using reader As New System.IO.StreamReader(filePath)
    Dim lineIndex As Integer = 0
    Dim currentAnimal As New Animal
    While Not reader.EndOfStream
    Dim line As String = reader.ReadLine
    If lineIndex = 0 Then
    currentAnimal.Name = line
    ElseIf lineIndex = 22 Then
    currentAnimal.Cage = line
    Exit While
    End If
    lineIndex += 1
    End While
    animals.Add(currentAnimal)
    End Using
    Next
    'do something to display the animals list
    Then you might bind the animals list to a ListBox, or loop through the list and populate a ListView.  If you decided to fill a datatable instead of making Animal instances, then you might bind the resulting table to a DataGridView.
    There are lots of options depending on what you want and what all you need to do.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

  • Is there a way to specify text-to-speech to dictate a specific line or..

    Hi guys,
    Is there a way to specify text-to-speech to dictate a specific line or page in a pdf file?
    In fact, it would be cool if text-to-speech highlighted each word that is being spoken through out the document during dictation and you could rewind, pause or fastforward the speech in real-time. Is this feature available? if not, can anyone recommend any other programs that can do this?
    thanx in advance

    Is there a way to specify text-to-speech to dictate a specific line or page in a pdf file?
    Yes!
    With fully modern Cocoa applications (like Safari, Preview, TextEdit, and Mail) you can select the line or page and then from the application menu > Services > Speech > Start Speaking Text
    You can also select and then Control-Click on the selection and then pick Speech > Start Speaking Text from the contextual menu. (Works with Safari, TextEdit, and Mail, but not Preview for PDF.)
    In fact, it would be cool if text-to-speech
    highlighted each word that is being spoken through
    out the document during dictation and you could
    rewind, pause or fastforward the speech in real-time.
    That would be cool. Are you looking for an interface enhancement, or would a talking book reader with these features be acceptable?
    Is this feature available?
    No, but you can get somewhat close to this ideal by using VoiceOver and checking Show Caption Panel.
    if not, can anyone recommend any other programs that can do this?
    I have had fair success with the Text Help Read & Write Aloud products.
    http://www.texthelp.com/rwm.asp?q1=products&q2=rwm
    eMac 1.42   Mac OS X (10.4.6)   I paid the going Windows price for a screen reader and got a free computer!

  • SAPScript: How to INTENSITY in a specific line?

    Dears,
    In my forms i need to intensity the specific line of the window.
    Now I knew use
    /: BOX INTENSITY 10
    to intensity the whole window,           But how to intensity a specific line?
    Thanks a lot.
    Sincerely,
    Julie

    Hi,
    write a BOX statement in the SCRIPT at the position where you want to intensify.
    Suppose your window dimentions are
                                 Left margin: 2 CH
                                 Uppar margin: 10 LN
                                 Width      : 60 CH
                                 Height:  20 LN
    and you want to intensify at
                                 Left margin: 2 CH
                                 Uppar margin: 15 LN
                                 Width      : 60 CH
                                  Height:  1 LN
    write the box statement with above dimensions and intensity.
    Regards,
    Sandeep.

  • Go to a specific line in a report.

    Hi<
    How can i, using the at-line-selection or the at-user-command, scroll to a specific line in a report?
    I've using the scroll statement but nothing have done it.
    imagine a 12 pages report, y want to go to the line 756 no matter in what page is it.

    Hi,
    These is and example that i made.
    If you can make it work, ill be more than thank full.
    Hi,
    These is and example that i made.
    If you can make it work, ill be more than thank full.
    REPORT z_example .                                                     
    DATA: i TYPE i,                                                        
          c TYPE i,                                                        
          s TYPE i.    
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.         
    PARAMETERS:     max_num TYPE i OBLIGATORY.                             
    SELECTION-SCREEN END OF BLOCK one.                                     
    START-OF-SELECTION.                                                    
      SET PF-STATUS 'MENU'.                                                
      i = 0.                                                               
      c = 0.                                                               
      DO max_num TIMES.                                                    
        WRITE: /10 i COLOR 5 HOTSPOT.                                      
        i = i + 1.                                                         
        c = c + 1.                                                         
        IF c = 31.                                                         
          NEW-PAGE.                                                        
          c = 0.                                                           
        ENDIF.                                                             
      ENDDO.        
    *&      Top-of-page                                                    
    TOP-OF-PAGE.                                                           
      PERFORM top_of_page.                                                 
    *&      Top-of-page                                                    
    TOP-OF-PAGE DURING LINE-SELECTION.                                     
      PERFORM top_of_page.                                                 
      PERFORM top_of_page.                                                 
    *&     from Top-of-page                                                
    FORM top_of_page.                                                      
      WRITE: 10 'my example' COLOR 1, 70 'Page:' COLOR 1, sy-pagno COLOR 2.
    ENDFORM.                                                               
    *&   Event AT USER-COMMAND.                                            
    AT USER-COMMAND.                                                       
      CASE sy-ucomm.                                                       
        WHEN 'SELEC'.                                                      
          s = sy-lisel+9(12).                                              
          i = 0.                                                           
          c = 0.                                                           
          DO max_num TIMES.                                                
            IF i = s.                                                      
              WRITE: /10 i COLOR 6.                                        
              s = 0.                                                       
            ELSE.                                                          
              WRITE: /10 i COLOR 5 HOTSPOT.                                
            ENDIF.                                                         
            i = i + 1.                                                     
            c = c + 1.                                                     
            IF c = 31.                                                     
              NEW-PAGE.                                                    
              c = 0.                                                       
            ENDIF.                                                         
          ENDDO.                                                           
      ENDCASE.

  • Writing XML in multiple lines

    Hi,
    I am running into a glitch when i tried to write multiple XMLs into 1 file (each XML on each line).
    I am using XMLWriter and trying to use CompactFormat (in XMLWriter).
    Let me first explain my problem. I am trying to write several XML lines (let's say orders) into 1 file and i want each order to be in a single line. My problem is that all the xml orders are coming in the same line because i am using the compact format.. How can i make each order xml go into different lines in the same file?
                        try
                             OutputFormat format = OutputFormat.createPrettyPrint();
                             format = OutputFormat.createCompactFormat();
                             format.setSuppressDeclaration(true);
                             fileOutputStream = new FileOutputStream("C:\\CODE\\FINAL\\test.txt");
                             xmlWriter = new XMLWriter(fileOutputStream, format);
                        } catch(Exception e)
                             System.out.println("File not found");
                        }After this, i will prepare XML using DOM4J APIs and write that to this file using XMLWriter.
    Please help me how to write into different line..
    Thanks in advance

    One way is to first convert each XML into a string, e.g. via
          * Prints a textual representation of a DOM object into a text string..
          * @param document DOM object to parse.
          * @return String representation of <i>document</i>.
        static public String toString(Document document) {
            String result = null;
            if (document != null) {
                StreamResult strResult = new StreamResult(new StringWriter());
                try {
                    Transformer t = TransformerFactory.newInstance().newTransformer();
                    t.setOutputProperty(OutputKeys.ENCODING, "iso-8859-1");
                    t.setOutputProperty(OutputKeys.INDENT, "yes");
                    t.setOutputProperty(OutputKeys.METHOD, "xml"); //xml, html, text
                    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
                    t.transform(new DOMSource(document.getDocumentElement()), strResult);
                } catch (Exception e) {
                    e.printStackTrace();
                result = strResult.getWriter().toString();
            return result;
        }//toString()then remove all line separators and add the result to the file followed by a line separator.

  • I want to display specific line to be color in alvlist how

    i want to display specific line to be color in alvlist
    i write the code as follows here document type is initial. then that line is to be
    appeared as color line but problem is initially it is appeared correct later i moved to next previous screens  error lines are to be colored where i have to clear 
      loop at it_doclist where blart eq space.
          gt_layout-info_fieldname  = 'COLOR_LINE'.
          it_doclist-color_line = 'C600'.
          modify it_doclist .
          clear:it_doclist.
      endloop.
    please help me exactly
    Thanks
    Ramana reddy

    u r requiremnt is not clear...but any how check this code....
    it has a form for assigning colors....
    rewardif useful
    REPORT zppb001_prd_posting_upload
           NO STANDARD PAGE HEADING LINE-SIZE 255
           MESSAGE-ID zpp.
    INCLUDE bdcrecx1.
    TYPE-POOLS  :slis.
    DATA:   wk_success(5) TYPE c,     "To store the successfull Hits
            wk_failure(5) TYPE c,     "To store the failed Hits
            l_mstring(600),           "To store Message texts
            t_date TYPE zservice_date,"To store Uploaded Date
            wk_lines(5) TYPE c,       "To store No of Records
            lines(5) TYPE c,          "To store No of Records
            wk_len(150) TYPE c,       "To store File path
            wk_alp TYPE i,            "To store path length
            lent TYPE i,              "To store path length
            b(4).                     "To store File extension
    DATA:   alvfld TYPE slis_t_fieldcat_alv WITH HEADER LINE,
            v_events TYPE slis_t_event WITH HEADER LINE,
            wk_events LIKE LINE OF v_events,
            it_list_comments TYPE slis_t_listheader,
            wk_list_comments LIKE LINE OF it_list_comments,
            wk_layout TYPE slis_layout_alv.
    CONSTANTS: c_formname_top_of_page TYPE slis_formname
                                   VALUE 'F_TOP_OF_PAGE'.
    --TO STORE FINAL DATA TO BE POSTED--
    Generated data section with specific formatting - DO NOT CHANGE  ***
    DATA: BEGIN OF record OCCURS 0,
            budat_002(010),
            bktxt_004(025),
            matnr_005(018),
            werks_006(004),
            alort_007(004),
            erfmg_008(017),
          END OF record.
    End generated data section ***
    DATA: BEGIN OF messages OCCURS 0,       "TO STORE FINAL STATUS DISPLAY
           budat_002(010),
           bktxt_004(025),
           matnr_005(018),
           maktx TYPE makt-maktx,
           werks_006(004),
           alort_007(004),
           erfmg_008(017),
           msg_e(400),
           msg_s(600),
           msgtyp TYPE c,
           line_color(4),
          END OF messages.
    DATA: BEGIN OF st_record1 ,
           matnr_005(018),
           werks_006(004),
           budat_002(010),
           bktxt_004(025),
           erfmg_007(017),
           erfmg_008(017),
           alort_007(004),
          END OF st_record1.
    DEFINE alv_macro.
      move : &1 to alvfld-col_pos,
             &2 to alvfld-fieldname,
             &3 to alvfld-seltext_m.
      if &2 = 'MATNR_005' or &2 = 'MAKTX'.
        alvfld-fix_column = 'X'.
      endif.
      append alvfld.clear alvfld.
    END-OF-DEFINITION.
    DATA : record1 LIKE TABLE OF st_record1 WITH HEADER LINE,
           it_excel LIKE TABLE OF alsmex_tabline WITH HEADER LINE,
           messtab1 LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
           it_acc LIKE TABLE OF record WITH HEADER LINE,
           it_rej LIKE TABLE OF record WITH HEADER LINE.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
    PARAMETERS: p_file TYPE localfile OBLIGATORY .
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          static    = 'X'
        CHANGING
          file_name = p_file.
    AT SELECTION-SCREEN ON p_file.
      wk_len = p_file.
      CONDENSE wk_len NO-GAPS.
      lent = STRLEN( wk_len ).
      wk_alp = lent - 4.
      b = wk_len+wk_alp(lent).
      IF ( b NE '.txt' ) AND ( b NE '.xls' ).
        MESSAGE e939.
        CLEAR p_file.
        STOP.
      ENDIF.
    START-OF-SELECTION.
      PERFORM upload_fun.
      PERFORM open_group.
      PERFORM fill_bdc_table.
      PERFORM close_group.
      PERFORM assign_colors.
      PERFORM f_event_build.
      SORT messages BY matnr_005 ASCENDING.
      PERFORM assign_columns.
      PERFORM count.
      IF ctu = 'X'.
        PERFORM alv.
      ENDIF.
      FREE:messages,messtab1,record1.
    END-OF-SELECTION.
    --FORM UPLOAD_FUN--
    FORM upload_fun.
    REFRESH: record1, it_acc, it_rej, record, messages, messtab1, it_excel.
      PERFORM fetch_from_flat_file.
      CLEAR it_excel.
      DESCRIBE TABLE it_excel.
      IF sy-tfill = 0.
        MESSAGE i937. STOP.
      ENDIF.
      LOOP AT it_excel.
        CASE it_excel-col.
          WHEN '0001'. MOVE: it_excel-value TO record1-matnr_005.
          WHEN '0002'. MOVE: it_excel-value TO record1-werks_006.
          WHEN '0003'. MOVE: it_excel-value TO record1-budat_002.
          WHEN '0004'. MOVE: it_excel-value TO record1-bktxt_004.
          WHEN '0005'. MOVE: it_excel-value TO record1-erfmg_007.
          WHEN '0006'. MOVE: it_excel-value TO record1-erfmg_008.
          WHEN '0007'. MOVE: it_excel-value TO record1-alort_007.
        ENDCASE.
        AT END OF row.
          APPEND record1. CLEAR record1.
        ENDAT.
      ENDLOOP.
      DELETE record1 WHERE matnr_005 EQ ' '.
    --DO NOT UPLOAD WHERE PRD QTY = 0--
      DELETE record1 WHERE ( erfmg_007 = 0 OR erfmg_007 = ' ' )
                      AND  ( erfmg_008 = 0 OR erfmg_008 = ' ' ).
      DESCRIBE TABLE record1[].
      IF sy-tfill > 0.
    --MOVE ACCEPTED QTY AND FETCH THE RESPECTIVE STGLOC-**
        LOOP AT record1 WHERE erfmg_007 NE 0 AND erfmg_007 NE ' '.
          MOVE:    record1-budat_002 TO it_acc-budat_002,
                   record1-bktxt_004 TO it_acc-bktxt_004,
                   record1-matnr_005 TO it_acc-matnr_005,
                   record1-werks_006 TO it_acc-werks_006,
                   record1-erfmg_007 TO it_acc-erfmg_008.
          APPEND it_acc. CLEAR: it_acc,record1.
        ENDLOOP.
    --MOVE ELPRO FOR THE ACCEPTED ENTRIES--
        LOOP AT it_acc.
          SELECT SINGLE elpro INTO it_acc-alort_007
                                            FROM mkal CLIENT SPECIFIED
                                            WHERE mandt = sy-mandt
                                            AND matnr = it_acc-matnr_005
                                            AND werks = it_acc-werks_006.
          MODIFY it_acc TRANSPORTING alort_007. CLEAR: it_acc.
        ENDLOOP.
    --MOVE PRD QTY FOR REJECTED QTY--
        LOOP AT record1 WHERE erfmg_008 NE 0 AND erfmg_008 NE ' '.
          MOVE: record1-budat_002 TO it_rej-budat_002,
                record1-bktxt_004 TO it_rej-bktxt_004,
                record1-matnr_005 TO it_rej-matnr_005,
                record1-werks_006 TO it_rej-werks_006,
                record1-erfmg_008 TO it_rej-erfmg_008,
                record1-alort_007 TO it_rej-alort_007.
          APPEND it_rej. CLEAR: it_rej, record1.
        ENDLOOP.
    --MOVE ACCEPTED AND REJECTED READINGS TO FINAL TABLE
        APPEND LINES OF it_acc TO record. APPEND LINES OF it_rej TO record.
        FREE : it_rej, it_acc, record1.
      ELSE.
        MESSAGE i937.
        STOP.
      ENDIF.
    ENDFORM.                    " UPLOAD_FUN
    --FORM fill_bdc_table--
    FORM fill_bdc_table.
      IF NOT record[] IS INITIAL.
        LOOP AT record.
          PERFORM bdc_dynpro USING 'SAPLBARM' '0800'.
          PERFORM bdc_field  USING 'BDC_CURSOR' 'RM61B-BKTXT'.
          PERFORM bdc_field  USING 'BDC_OKCODE' '=ISTDA'.
          PERFORM bdc_field  USING 'RM61B-BUDAT' record-budat_002.
          PERFORM bdc_field  USING 'RM61B-BKTXT' record-bktxt_004.
          PERFORM bdc_field  USING 'RM61B-MATNR' record-matnr_005.
          PERFORM bdc_field  USING 'RM61B-WERKS' record-werks_006.
          PERFORM bdc_field  USING 'RM61B-ALORT' record-alort_007.
          PERFORM bdc_field  USING 'RM61B-ERFMG' record-erfmg_008.
          PERFORM bdc_dynpro USING 'SAPLCOWB' '0130'.
          PERFORM bdc_field  USING 'BDC_OKCODE' '=WEIT'.
          PERFORM bdc_field  USING 'BDC_CURSOR' 'G_COWB_HEADER-MNGTXT'.
          PERFORM bdc_transaction USING 'MFBF'.
          CLEAR messtab.
          messtab1[] = messtab[].
          LOOP AT messtab1 WHERE msgtyp = 'S' OR msgtyp = 'E'.
            SELECT SINGLE * FROM t100 WHERE sprsl = messtab1-msgspra
                                      AND   arbgb = messtab1-msgid
                                      AND   msgnr = messtab1-msgnr.
            IF sy-subrc = 0.
              l_mstring = t100-text.
              PERFORM store_messages.
              CLEAR l_mstring.
            ENDIF.
          ENDLOOP.
          MOVE-CORRESPONDING record TO messages.
         SELECT SINGLE maktx INTO messages-maktx FROM makt CLIENT SPECIFIED
                                                 WHERE mandt = sy-mandt
                                              AND matnr = messages-matnr_005
                                              AND spras = 'EN'.
          APPEND messages.
          CLEAR: messages, messtab1. REFRESH messtab1.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "fill_bdc_table
    --FORM assign_columns--
    FORM assign_columns .
      REFRESH alvfld.
      alv_macro '1' 'MATNR_005' 'PART NO'.
      alv_macro '2' 'MAKTX' 'DESCRIPTION'.
      alv_macro '3' 'WERKS_006' 'PLANT'.
      alv_macro '4' 'BUDAT_002' 'POSTING DATE'.
      alv_macro '5' 'BKTXT_004' 'SHIFT'.
      alv_macro '6' 'ERFMG_008' 'QUANTITY'.
      alv_macro '7' 'ALORT_007' 'STGLOC'.
      alv_macro '8' 'MSG_E' 'ERRORS DUE TO'.
      alv_macro '9' 'MSG_S' 'STATUS'.
    ENDFORM.                    " assign_columns
    --FORM f_event_build--
    FORM f_event_build .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = v_events[].
      READ TABLE v_events WITH KEY name = slis_ev_top_of_page
                                               INTO wk_events.
      wk_layout-info_fieldname = 'LINE_COLOR'.
      wk_layout-colwidth_optimize    = 'X'.
      IF sy-subrc = 0.
        MOVE c_formname_top_of_page TO wk_events-form.
        MODIFY v_events FROM wk_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " f_event_build
    --FORM f_top_of_page--
    FORM f_top_of_page.
      WRITE sy-datum TO t_date.
      CLEAR: it_list_comments[].
      wk_list_comments-typ  = 'H'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
    CONCATENATE 'UPLOADED STATUS FOR PRODUCTION POSTING ON - ' t_date INTO
                                 wk_list_comments-info SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      DESCRIBE TABLE messages LINES wk_lines.
      lines = wk_lines.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      CONCATENATE 'Total No of Hits:' lines INTO wk_list_comments-info
                                                      SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      CONCATENATE 'Successfull Hits:' wk_success INTO
                wk_list_comments-info SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      CONCATENATE '    Failed Hits:' '   ' wk_failure INTO
                              wk_list_comments-info
                              SEPARATED BY space.
      APPEND wk_list_comments TO it_list_comments.
      CLEAR wk_list_comments.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'ENJOYSAP_LOGO'
          it_list_commentary = it_list_comments.
    ENDFORM.                    "F_TOP_OF_PAGE
    --FORM assign_colors--
    FORM assign_colors .
      LOOP AT messages.
        CASE messages-msgtyp.
          WHEN 'E'.
            messages-line_color = 'C601'.
          WHEN 'S'.
            messages-line_color = 'C501'.
        ENDCASE.
        MODIFY messages TRANSPORTING line_color.
      ENDLOOP.
    ENDFORM.                    " assign_colors
    --FORM COUNT--
    FORM count .
      CLEAR: wk_failure, wk_success.
      LOOP AT messages.
        CASE messages-msgtyp.
          WHEN 'E'.
            ADD 1 TO wk_failure.
          WHEN 'S'.
            ADD 1 TO wk_success.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    " COUNT
    --FORM ALV--
    FORM alv .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          is_layout          = wk_layout
          it_fieldcat        = alvfld[]
          it_events          = v_events[]
        TABLES
          t_outtab           = messages
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
    ENDFORM.                    " ALV
    --FETCH_FROM_FLAT_FILE--
    FORM fetch_from_flat_file .
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1 "From 1st Column
          i_begin_row             = 2 "From 2nd row
          i_end_col               = 7 "Till 7th Column
          i_end_row               = 65000 "Till Row
        TABLES
          intern                  = it_excel
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
    ENDFORM.                    " FETCH_FROM_FLAT_FILE
    --FORM STORE_MESSAGES--
    FORM store_messages.
      IF l_mstring CS '&1'.
        REPLACE '&1' WITH messtab1-msgv1 INTO l_mstring.
        REPLACE '&2' WITH messtab1-msgv2 INTO l_mstring.
        REPLACE '&3' WITH messtab1-msgv3 INTO l_mstring.
        REPLACE '&4' WITH messtab1-msgv4 INTO l_mstring.
      ELSE.
        REPLACE '&' WITH messtab1-msgv1 INTO l_mstring.
        REPLACE '&' WITH messtab1-msgv2 INTO l_mstring.
        REPLACE '&' WITH messtab1-msgv3 INTO l_mstring.
        REPLACE '&' WITH messtab1-msgv4 INTO l_mstring.
      ENDIF.
      CONDENSE l_mstring.
      IF messtab1-msgtyp = 'E'.
    CONCATENATE messages-msg_s l_mstring INTO l_mstring SEPARATED BY space.
        MOVE l_mstring TO messages-msg_e.
        MOVE 'E' TO messages-msgtyp.
        MOVE 'Document Not Posted' TO messages-msg_s.
      ELSEIF messtab1-msgtyp = 'S'.
    CONCATENATE messages-msg_s l_mstring INTO l_mstring SEPARATED BY space.
        MOVE l_mstring TO messages-msg_s.
        MOVE 'S' TO messages-msgtyp.
      ENDIF.
    ENDFORM.                    " store_messages

  • Inserting text at a specific line number.

    Hello,
    My need is to insert specific text at a line number to be determined at run time. I know how to write to new files and append to existing ones, but I have not been able to find any documentation displaying how to traverse to a specific line in a text file. More specifically, of course I know how to use looping constructs, but I have seen no file I/O classes with a "skip line" method to get to my insertion point.
    Thank you.

    depending on the size of the files read them into a buffer use a loop to get to a specific point and write back to file.*
    Note I am sure there are many better ways to do this but this was the first thing that came to mind that would be easy for a new person to get.

  • Append text to a specific line number?

    How/can you append text to a specific line number?
    Thanks!

    1) read file, store each line seperately in a List or something
    2) append the text to the specific line
    3) write out all the lines back to the file
    You may be able to do something with RandomAccessFile as an alternative.

  • Utl_file.putline  - platform specific line termination character

    PUT_LINE terminates the line with the platform-specific line terminator character or characters.
    But the porblem is this.
    The file generator application can run in different platform,and hence it means I can have different line termination character.Is there anyway I can force it to generate Unix only line termination character (line termination char in Unix I guess is \n) .
    In short programatically I want to control it.
    I looked at UTL_FILE.PUTLINE but it doesnt have any option to control the line termination char.
    Help.

    here is the example, i am on HP UNIX
    SQL> DECLARE
      2     l_text   VARCHAR2 (32767);
      3     v_file   UTL_FILE.FILE_TYPE;
      4  BEGIN
      5   -- OPEN FILE to write
      6     v_file :=  UTL_FILE.FOPEN (LOCATION          => 'NOTIFICATION',
      7                        filename          => 'Test.txt',
      8                        open_mode         => 'w',
      9                        max_linesize      => 32767
    10                       );
    11     UTL_FILE.PUT(v_file,'Hello' || CHR(10));
    12 
    13     UTL_FILE.PUT(v_file,'how are you' || CHR(10));
    14 
    15     UTL_FILE.PUT(v_file,'I am fine' || CHR(10));
    16     UTL_FILE.FCLOSE (v_file);
    17    ---- open file to read
    18    v_file := UTL_FILE.FOPEN (LOCATION          => 'NOTIFICATION',
    19                        filename          => 'Test.txt',
    20                        open_mode         => 'r'
    21                       
    22                       );
    23     BEGIN
    24        LOOP
    25           UTL_FILE.GET_LINE (v_file, l_text, 32767);
    26           DBMS_OUTPUT.PUT_LINE (l_text);
    27        END LOOP;
    28     EXCEPTION
    29        WHEN NO_DATA_FOUND
    30        THEN
    31           NULL;
    32     END;
    33      -- READ LAST LINE
    34    -- DBMS_OUTPUT.PUT_LINE ('Last Line : |' || l_text || '|');
    35     UTL_FILE.FCLOSE (v_file);
    36  EXCEPTION
    37     WHEN OTHERS
    38     THEN
    39        UTL_FILE.FCLOSE (v_file);
    40  END;
    41  /
    Hello
    how are you
    I am fine
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2     l_text   VARCHAR2 (32767);
      3     v_file   UTL_FILE.FILE_TYPE;
      4  BEGIN
      5   -- OPEN FILE to write
      6     v_file :=  UTL_FILE.FOPEN (LOCATION          => 'NOTIFICATION',
      7                        filename          => 'Test.txt',
      8                        open_mode         => 'w',
      9                        max_linesize      => 32767
    10                       );
    11     UTL_FILE.PUT(v_file,'Hello');
    12     UTL_FILE.PUT(v_file,'how are you' );
    13     UTL_FILE.PUT(v_file,'I am fine' );
    14     UTL_FILE.FCLOSE (v_file);
    15    ---- open file to read
    16    v_file := UTL_FILE.FOPEN (LOCATION          => 'NOTIFICATION',
    17                        filename          => 'Test.txt',
    18                        open_mode         => 'r'
    19                       );
    20     BEGIN
    21        LOOP
    22           UTL_FILE.GET_LINE (v_file, l_text, 32767);
    23           DBMS_OUTPUT.PUT_LINE (l_text);
    24        END LOOP;
    25     EXCEPTION
    26        WHEN NO_DATA_FOUND
    27        THEN
    28           NULL;
    29     END;
    30      -- READ LAST LINE
    31    -- DBMS_OUTPUT.PUT_LINE ('Last Line : |' || l_text || '|');
    32     UTL_FILE.FCLOSE (v_file);
    33  EXCEPTION
    34     WHEN OTHERS
    35     THEN
    36        UTL_FILE.FCLOSE (v_file);
    37* END;
    38  /
    Hellohow are youI am fine
    PL/SQL procedure successfully completed.

  • How to read a specific line of a .dat file?

    can we read a specific line of a .dat file, if so, how?
    i have this .dat files for each customer, which contain their name on the first line, their id on the second line
    and a list of items and an item id between each item.
    John Doe
    455689
    milk
    1
    orange
    9
    Here is what I am trying to do, please correct me
    //list out .dat file in dir
    File customer_dir = new File ("Customer")
    if (customer_dir.isDirectory())
    String[] listofdat=dir.list();
    for (int i=0;i<listofdat.length();i++)
    Scanner dat_read = new Scanner (new File listfodat);
    dat_read.nextLine();
    if (dat_read.nextLine().equals("455689")) <--is this okay?

    bibiancheng wrote:
    would you please explain to me what
    String[] tokens = line.trim().split("\\s*,\\s*")"\\s*,\\s*" is a regex where \\s means whitespace and the * means "any number of".
    so \\s* means that it will grab all the whitespace if there is any.
    trim() removes white space from the beginning and end of the string.
    dont put a comma in the name.
    spaces allowed: "jane doe, 12-14-09, 428438, 6, 388473, 7, 187374, 3"
    it was just a recommendation. breaking it into separate lines would be fine.

  • Editable ALV - how to throw an error message for a specific line & field

    Hi all,
    I've implemented an editable ALV and also the ON_DATA_CHECK event to check the values, entered in the ALV. So this works fine and I can check the values.
    But now, I want to throw an error message corresponding to the field in the ALV, where the error occured.
    How can I throw this error message corresponding to a specific line/field in the ALV?
    I was using REPORT_ATTRIBUTE_ERROR_MESSAGE and REPORT_ELEMENT_ERROR_MESSAGE but without success.
    I'm also using a loop over the "CHANGES" in the ALV and within this loop, I use
    elem_alv = node_alv->get_element( index = <change>-element_index ) 
    to get the element for the message.
    CALL METHOD lo_message_manager->REPORT_ELEMENT_ERROR_MESSAGE
      EXPORTING
        MESSAGE_TEXT              = 'my message'
        ELEMENT                   = elem_alv
    *    ATTRIBUTES                =
    *    PARAMS                    =
    *    MSG_USER_DATA             =
    *    IS_PERMANENT              = ABAP_FALSE
    *    SCOPE_PERMANENT_MSG       = CO_MSG_SCOPE_CTXT_ELEMENT
    *    MSG_INDEX                 =
    *    CANCEL_NAVIGATION         =
    *    IS_VALIDATION_INDEPENDENT = ABAP_FALSE.
    2.) is it right, that for an editable ALV, I can't use the WDDOBEFOREACTION to do the checks?
    If I try to use this, I can't get the values of my ALV table to check it.
    Thanks,
    Andreas

    Hi Andreas,
    I have tried to replicate your problem and I am getting the desired output. I have a row by name TEMP_NEW in my ALV and I want to throw an error message whenever the user enters a value of 4 for that particular field. Please find my coding as below. The important thing is where we perform the actual comparison between the r_value and 4. r_value is defined in SALV_WD_S_TABLE_MOD_CELL as reference to type DATA. So suppose the user enters a value of say 3 in the TEMP_NEW field of the ALV then r_value would contain 3 but if you observe its type in debugging mode it would be as TYPE REF TO I and not TYPE I. So you cannot directly say something like:
    "if ls_modified_cells-r_value = 3" as this would lead to a syntax error. Define a field-symbol say <temp> and then use it to get the actual value into it by saying like:
    ASSIGN ls_modified_cells-r_value->* TO <temp>.
    Then you can use this <temp> for comparison in your IF statement like:
    IF  <temp> = 3.
    Find the entire coding as below:
    METHOD check_data.
      DATA: lr_node TYPE REF TO if_wd_context_node,
            lr_element TYPE REF TO if_wd_context_element,
            ls_modified_cells TYPE salv_wd_s_table_mod_cell.
      FIELD-SYMBOLS <temp> TYPE data.
    " get message manager
      DATA lo_api_controller     TYPE REF TO if_wd_controller.
      DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
      lo_api_controller ?= wd_this->wd_get_api( ).
      CALL METHOD lo_api_controller->get_message_manager
        RECEIVING
          message_manager = lo_message_manager.
      lr_node = wd_context->get_child_node( name = 'NODE' ).
      LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
        lr_element = lr_node->get_element( index = ls_modified_cells-index ).
        IF ls_modified_cells-attribute = 'TEMP_NEW'.
    " Get the value extracted into the field symbol from the reference variable
          ASSIGN ls_modified_cells-r_value->* TO <temp>.
    " Use the value present in this field-symbol for your comparison
          IF  <temp> = 4.
    " report message
            CALL METHOD lo_message_manager->report_attribute_error_message
              EXPORTING
                message_text   = 'Sample message text'
                element        = lr_element
                attribute_name = ls_modified_cells-attribute.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDMETHOD.
    Hope this helps resolve your problem.
    Regards,
    Uday

Maybe you are looking for

  • Ipod not recognized by itunes, why?

    I got a new Ipod and it is not recognized by Itunes. I have reinstalled itunes. I have tried to reset the ipod. It also does not show up on Windows Explorer. I tried changing things in the MSCONFIG file and it still did not work. The USB ports work a

  • A GUI problem when using sockets

    I have a problem with Client.java. it creates a socket to connect to a serversocket. I do this through the method "runClient()" . the problem is that if I call runClient from an actionlistener add to a button. here the graphics of the window will dis

  • IDOCs Problem

    I am working on a custom program that will generate the list of all the idocs that have got errors in it and then we will fix the error and within the same program it will reprocess the idoc, now when I run this program and when I got the list of all

  • What to do if I have in message monitoring

    What to do if I have in message monitoring for   messages of : "Engine": "Integration Engine" status "cancelled with error". What is (could be the error) and what steps should be done

  • Creative Cloud App Install Issues...

    (CC subscriber) Installed new CC app, but Home and Apps menus only display blank window with spinning "wait" icon...forever! Files menu works, Fonts menu works, but Behance menu displays "404"