How to go to a specific line # in java?

Hi,
I have located a keyword in a file using the bufferredreader class (by reading line by line and searching for the keyword).
This method returns the # of the line that contains the keyword. Say this method return 'n'. I need to pass this information to another method and have it skip the first 'n' lines and start reading from the (n+1)th line.
I have not found this capability in the Bufferredreader class nor other classes in Java that I looked at. Do you know of any filereader class that does that?
Note that my intent is to delete the line that contains this keyword. The way I am thinking of right now is to find the line, pass its line # to another method and have that method line (n)th with (n+1)th sequentially to the end of the file. Would you suggest a better way of approaching the problem all together?
Thanks,
parachuter2b

bckrispi is right ! This is a small part of a pretty big server/client program that has to be platform independable as well.
mchan0 :
so this is not useful? rather then have the second program re-read, you >could output the rest of the file to a new file without the first n lines?
java.lang.Object
java.io.Reader
java.io.BufferedReader
readLine
public String readLine()
throws IOExceptionRead a line of text. A line is considered to be terminated >by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return >followed immediately by a linefeed.
Returns:
A String containing the contents of the line, not including any >line-termination characters, or null if the end of the stream has been >reached
Throws:
IOException - If an I/O error occursI need to delete only that one line from the file...so would need to retain the first n-1 lines and (n+1)th till the end of the file.
cotton.m:
Note that my intent is to delete the line that
contains this keyword.
This actually concerns me more than your current problem.Do you mean there's a better way of going about this problem or something else? sorry ! I don't quite get what you mean.

Similar Messages

  • How to reverse the AuC Specific Line Item?

    Hi Gurus,
    I am facing one issue while doing the AuC Reverse. Through T.Code -AIST  i had reverse the AuC line item. but i want to reverse the specific line item.E.g. if there are 10 AuC Assets ( No. 1,2,3.....10)for the same date and want to reverse the 4th and 6th AuC asset line item? how can i reverse this?
    Could you please suggest me to overcome this issue?
    Regards,
    Dhananjay R.

    by mistake raise ....

  • 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.

  • How to put value of specific line number in BDC

    Hi all,
    I am working on a BDC (MI04)which has 3 fields as header:
    Document Number:
    Date:
    Fiscal Year.
    After entering I get a screen having default Material Number, its description and its serial number. There is one field named QTY where I need to push the value through BDC.
    But the issue is that I am not able to reach to that Material Code to push the qty value. I am getting the Material Code and its serial number in the text file from user.
    May some times the given material code in on the NEXT PAGE (P+). So dont know how to go to the next page and push the qty in front of the correct material code..
    Please help. Its very very urgent.
    Thanks in Advance.
    -=Maddu=-

    Try something like
    perform bdc_dynpro      using 'SAPMM07I' '0731'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'ISEG-ERFMG(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=KLA'. " Menu goto/position
    perform bdc_dynpro      using 'SAPMM07I' '1701'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM07I-ZEILE'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENT2'.
    perform bdc_field       using 'RM07I-ZEILE'
                                  '8'. " give the "iseg-zeile" of the record to fill
    perform bdc_dynpro      using 'SAPMM07I' '0731'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'ISEG-ERFMG(01)'. " fill line 1 displayed
    Regards

  • 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.

  • 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

  • How can i read all the lines from a text file in specific places and use the data ?

    string[] lines = File.ReadAllLines(@"c:\wmiclasses\wmiclasses1.txt");
    for (int i = 0; i < lines.Length; i++)
    if (lines[i].StartsWith("ComboBox"))
    And this is how the text file content look like:
    ComboBox Name cmbxOption
    Classes Win32_1394Controller
    Classes Win32_1394ControllerDevice
    ComboBox Name cmbxStorage
    Classes Win32_LogicalFileSecuritySetting
    Classes Win32_TapeDrive
    What i need to do is some things:
    1. Each time the line start with ComboBox then to get only the ComboBox name from the line for example cmbxOption.
       Since i have already this ComboBoxes in my form1 designer i need to identify where the cmbxOption start and end and when the next ComboBox start cmbxStorage.
    2. To get all the lines of the current ComboBox for example this lines belong to cmbxOption:
    Classes Win32_1394Controller
    Classes Win32_1394ControllerDevice
    3. To create from each line a Key and Value for example from the line:
    Classes Win32_1394Controller
    Then the key will be Win32_1394Controller and the value will be only 1394Controller
    Then the second line key Win32_1394ControllerDevice and value only 1394ControllerDevice
    4. To add to the correct belonging ComboBox only the value 1394Controller.
    5. To make that when i select in the ComboBox for example in cmbxOption the item 1394Controller it will act like i selected Win32_1394Controller.
    For example in this event:
    private void cmbxOption_SelectedIndexChanged(object sender, EventArgs e)
    InsertInfo(cmbxOption.SelectedItem.ToString(), ref lstDisplayHardware, chkHardware.Checked);
    In need that the SelectedItem will be Win32_1394Controller but the user will see in the cmbxOption only 1394Controller without the Win32_
    This is the start of the method InsertInfo
    private void InsertInfo(string Key, ref ListView lst, bool DontInsertNull)
    That's why i need that the Key will be Win32_1394Controller but i want that the user will see in the ComboBox only 1394Controller without the Win32_

    Hello,
    Here is a running start on getting specific lines in the case lines starting with ComboBox. I took your data and placed it into a text file named TextFile1.txt in the bin\debug folder. Code below was done in
    a console app.
    using System;
    using System.IO;
    using System.Linq;
    namespace ConsoleApplication1
    internal class Program
    private static void Main(string[] args)
    var result =
    from T in File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TextFile1.txt"))
    .Select((line, index) => new { Line = line, Index = index })
    .Where((s) => s.Line.StartsWith("ComboBox"))
    select T
    ).ToList();
    if (result.Count > 0)
    foreach (var item in result)
    Console.WriteLine("Line: {0} Data: {1}", item.Index, item.Line);
    Console.ReadLine();
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.

  • 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

  • How to read specific line in a file through UNIX shell script..

    Dear Friends,
    I have generated .ldt file under admin/import/US folder through FND_LOAD script for Download the responsibility.
    I registred Shell script (Host concurrent program) in Oracle apps. Now i want to read the file in speciific line which i was generated in admin/import/US folder through unix shell script. Please help me how to read specific line and the i want to replace that which i am going to read the specific line.
    Thanks in advance..
    Regards,
    Velu.

    Hi,
    Thanks for reply,
    My requirement i have to find the specific line in a file and find and replace needed word over there it's should happen programatically. i want to read specific line in a file Once complete find and replace the condition should exists. The loop will go to next file and read the same line in next file also do the same process upto how many files over there.i am doing through UNIX shell script. Please help me out to find the
    Your suggestion is highly appriciated.
    Thanks,
    Velu.

  • 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

  • How to extract specific line from a string

    Hi guys.
    I?m starting to work with java...
    i have the following data inside a string variable:
    0 rows inserted.
    0 rows updated.
    0 rows ignored.
    98 rows marked as deleted.
    0 rows have no country.
    3345 rows have no geo.
    0 rows are invalid.
    what i want to do i to extract the number of rows marked as delete.
    I think that i figured out how to extract the number from this line :"98 rows marked as deleted."
    but how do i get to that line?
    I hope you can Help me. Thanks.

    the string is the result from a Function... this function gets the info from a store procedure...
                   rta = "Results for " + dh.getSource() + " source:\n" +
    dh.getInsertedCount() + " rows inserted.\n" +
    dh.getUpdatedCount() + " rows updated.\n" +
    dh.getIgnoredCount() + " rows ignored.\n" +
                   dh.getDeletedCount() + " rows marked as deleted.\n" +
                   dh.getNoCtryCnt() + " rows have no country.\n" +
                   dh.getNoGeoCnt() + " rows have no geo.\n" +
                   dh.getInvalidCnt() + " rows are invalid.\n";
    i can?t change this function...
    so i need to work with the returned value...
    i what thinking to use the following method to extract te number...
    private int GetNumericValue(string sVal)
    int iFirst, iCharVal, iEnd;
    int iMult = 1, iRet = 0;
    char[] aNumbers = "1234567890".ToCharArray();
    iFirst = sVal.IndexOfAny(aNumbers);
    iEnd = sVal.LastIndexOfAny(aNumbers);
    if (iEnd < 0)
    return 0;
    string subStr = sVal.Substring(iFirst, iEnd - iFirst + 1);
    iEnd = subStr.Length - 1;
    while (subStr.Length > 0)
    iCharVal = int.Parse(subStr[subStr.Length-1].ToString());
    iRet += iMult * iCharVal;
    iMult *= 10;
    if (iEnd <= 0)
    break;
    subStr = subStr.Substring(0, subStr.Length - 1);
    iEnd = subStr.LastIndexOfAny(aNumbers);
    subStr = sVal.Substring(iFirst, iEnd + 1);
    return iRet;
    but i still need the 4rd line to extract the number

  • How to delete the old schedule line release?

    Hello,
    How to delete the old schedule line release in apo?
    Generally GR has to be carry out  schedule line release  in r/3 which reduces the Schdule line release.
    But i do want do GR against old schdule line release instead i want to delete the old schdule line release.
    Please suggest.
    Regards,
    Sunil Patil

    Sunil ,
    /sapapo/cmds_del  is the tcode to deleted sales scheduling agreement confirmations and releases
    /sapapo/display_conf  is the tcode for displaying sls. sch.agr confirmations and releases
    The above two are in the supply chain collaboration menu
    /sappao/cmds_sc02 is the tcode to delete sales scheduling agreements . This tcode is in the application specific master data menu
    Thanks
    Saradha

  • How To Load a Project Budget Line Through API in R12 ?

    Hello
    Could you please let me know how to load the project budget lines through API in R12 system, I am trying with below script but it is not working.
    Could you please let me know if you have any solution.
    =========================================================================================================================================================================
    Script
    DECLARE
    --––variables needed for API standard parameters
       l_api_version_number     NUMBER                                 := 1.0;
       l_commit                 VARCHAR2 (1)                           := 'T';
       l_return_status          VARCHAR2 (1);
       l_init_msg_list          VARCHAR2 (1);
       l_msg_count              NUMBER;
       l_msg_data               VARCHAR2 (2000);
       l_data                   VARCHAR2 (2000);
       l_msg_entity             VARCHAR2 (100);
       l_msg_entity_index       NUMBER;
       l_msg_index              NUMBER;
       l_msg_index_out          NUMBER;
       l_encoded                VARCHAR2 (1);
       i                        NUMBER;
       a                        NUMBER;
    --––variables needed for Oracle Project specific parameters
       l_pm_product_code        VARCHAR2 (100);
       l_pa_project_id          NUMBER;
       l_pm_project_reference   VARCHAR2 (100);
       l_budget_type_code       VARCHAR2 (30);
       l_change_reason_code     VARCHAR2 (30);
       l_description            VARCHAR2 (255);
       l_entry_method_code      VARCHAR2 (30);
       l_resource_list_name     VARCHAR2 (60);
       l_resource_list_id       NUMBER;
       l_budget_lines_in        pa_budget_pub.budget_line_in_tbl_type;
       l_budget_lines_in_rec    pa_budget_pub.budget_line_in_rec_type;
       l_budget_lines_out       pa_budget_pub.budget_line_out_tbl_type;
       l_line_index             NUMBER;
       l_line_return_status     VARCHAR2 (1);
       l_user_id                NUMBER;
       l_responsibility_id      NUMBER;
       API_ERROR                EXCEPTION;
    BEGIN
       -- SET GLOBAL INFO
       SELECT user_id,
              responsibility_id
         INTO l_user_id,
              l_responsibility_id
         FROM pa_user_resp_v
        WHERE user_name = 'RAJU';
       PA_INTERFACE_UTILS_PUB.SET_GLOBAL_INFO (p_api_version_number      => 1.0,
    p_responsibility_id       => l_responsibility_id,
    p_user_id                 => l_user_id,
                                               p_msg_count               => l_msg_count,
    p_msg_data                => l_msg_data,
    p_return_status           => l_return_status
       IF l_return_status != 'S'
       THEN
          RAISE API_ERROR;
       END IF;
    --––PRODUCT RELATED DATA
       l_pm_product_code        := 'GMS';
    --––BUDGET DATA
       l_pa_project_id          := 6271;
       l_pm_project_reference   := NULL;--'ABC';
       l_budget_type_code       := 'FC';
       -- l_change_reason_code := 'INITIAL';
       l_description            := 'New description –> 2';
       l_entry_method_code      := 'PA_TASKLVL_BASELINE';
       l_resource_list_id       := 1001;
    --––BUDGET LINES DATA
       a                := 1;
       FOR i IN 1 .. a
       LOOP
          l_budget_lines_in_rec.pa_task_id := 405156;
          l_budget_lines_in_rec.pm_task_reference       := NULL;
          l_budget_lines_in_rec.resource_alias          := 'Labor';
          l_budget_lines_in_rec.resource_list_member_id := '1034';
          -- l_budget_lines_in_rec.budget_start_date        := '01-Jan-13';
          -- l_budget_lines_in_rec.budget_end_date          := '31-Dec-14';
          -- l_budget_lines_in_rec.period_name          := 'JUL-10FY2011';
          l_budget_lines_in_rec.description             := 'Some Text';
          l_budget_lines_in_rec.quantity := 100.00;
          l_budget_lines_in_rec.raw_cost := 300.00;
          l_budget_lines_in (i)                         := l_budget_lines_in_rec;
       END LOOP;
    --––INIT_BUDGET
       pa_budget_pub.init_budget;
    --––LOAD_BUDGET_LINE
       FOR i IN 1 .. a
       LOOP
          pa_budget_pub.load_budget_line
                            (p_api_version_number           => l_api_version_number,
    p_return_status                => l_return_status,
                             p_pa_task_id                   => l_budget_lines_in (i).pa_task_id,
    p_pm_task_reference            => l_budget_lines_in (i).pm_task_reference,
    p_resource_alias               => l_budget_lines_in (i).resource_alias,
    p_resource_list_member_id      => l_budget_lines_in (i).resource_list_member_id,
    p_budget_start_date            => l_budget_lines_in (i).budget_start_date,
                             p_budget_end_date              => l_budget_lines_in (i).budget_end_date,
    p_period_name                  => l_budget_lines_in (i).period_name,
    p_description                  => l_budget_lines_in (i).description,
                             p_raw_cost                     => l_budget_lines_in (i).raw_cost,
    p_burdened_cost                => l_budget_lines_in (i).burdened_cost,
    p_revenue                      => l_budget_lines_in (i).revenue,
    p_quantity                     => l_budget_lines_in (i).quantity
       END LOOP;
       IF l_return_status != 'S'
       THEN
          RAISE api_error;
       END IF;
    --––EXECUTE_CREATE_DRAFT_BUDGET
        pa_budget_pub.execute_create_draft_budget (p_api_version_number        => l_api_version_number,
    p_msg_count                 => l_msg_count,
    p_msg_data                  => l_msg_data,
    p_return_status             => l_return_status,
    p_pm_product_code           => l_pm_product_code,
                                                  p_pa_project_id             => l_pa_project_id,
    p_pm_project_reference      => l_pm_project_reference,
    p_budget_type_code          => l_budget_type_code,
    p_change_reason_code        => l_change_reason_code,
    p_description               => l_description,
                                                  p_entry_method_code         => l_entry_method_code,
    p_resource_list_name        => l_resource_list_name,
    p_resource_list_id          => l_resource_list_id
       IF l_return_status != 'S'
       THEN
          NULL; --––RAISE API_ERROR;
       END IF;
    --––FETCH_LINE
       FOR l_line_index IN 1 .. pa_budget_pub.g_budget_lines_tbl_count
       LOOP
          pa_budget_pub.fetch_budget_line (p_api_version_number      => l_api_version_number,
    p_return_status           => l_return_status,
    p_line_index              => l_line_index,
    p_line_return_status      => l_line_return_status
          IF l_return_status != 'S' OR l_line_return_status != 'S'
          THEN
             RAISE api_error;
          END IF;
       END LOOP;
    --––CLEAR_BUDGET
       pa_budget_pub.clear_budget;
       IF l_return_status != 'S'
       THEN
          RAISE api_error;
       END IF;
    --––HANDLE EXCEPTIONS
    EXCEPTION
       WHEN api_error
       THEN
          FOR i IN 1 .. l_msg_count
          LOOP
             pa_interface_utils_pub.get_messages (p_msg_data           => l_msg_data,
    p_data               => l_data,
    p_msg_count          => l_msg_count,
    p_msg_index_out      => l_msg_index_out
             DBMS_OUTPUT.put_line ('Error Mesg ' || l_data);
             DBMS_OUTPUT.put_line ('Error Mesg ' || l_msg_data);
          END LOOP;
       WHEN OTHERS
       THEN
          FOR i IN 1 .. l_msg_count
          LOOP
             pa_interface_utils_pub.get_messages (p_msg_data           => l_msg_data,
    p_data               => l_data,
                                                  p_msg_count          => l_msg_count,
    p_msg_index_out      => l_msg_index_out
             DBMS_OUTPUT.put_line ('error mesg ' || l_data);
          END LOOP;
    END;
    =========================================================================================================================================================================

    Not knowing how its embedded...  you will need to get the report instance from the dll and cast it as a ReportDocument object.
    Given the info so far, that is all we can say.
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • 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"

Maybe you are looking for

  • How to configure number of importing mail?

    hi guys,    I'm adding my yahoo mail account into Mac Mail recently, and I have got around 5000 mails in my yahoo account. When I succesffuly added the yahoo account in Mac Mail, the system imports all mails to Mac (starting from very beginining) It

  • What is the keyboard shortcut to open Options window?

    This shortcut used to be Alt+O (Windows), but this is not working anymore! There is no listing of this shortcut even in the FF shortcut help page. Am not able to set it also. How to enable it back?

  • Connectinit

    Hi all, I am trying to pass BoUSER  throgh connectinit for DB2 however not able to perform. the syntax is erroring out in reports. the syntax that  iam passing is Clientid=@variable('BOuser') Any help in creating the syntax Most welcome

  • How to write report output into table

    Hi, I want to get data out from report "RSPARAM" which list all system profile parameters my requirement is that i need to write output of this report to table so can anyone please tell me how should achieve this? is there any FM which read report as

  • Out of application memory when starting iPhoto

    i get a "out of application memory" notification when trying to start iPhoto