Looping and moving correct lines from WTAB to ITAB

I have made the following declaration for my 2 internal tables.
DATA: BEGIN OF ITAB OCCURS 0,
      EBELN LIKE EKKO-EBELN,  "Purchasing Document Number
      EBELP LIKE EKPO-EBELP,  "Item Number of Purchasing Document
      EINDT LIKE EKET-EINDT,  "Item delivery date
      BUDAT LIKE EKBE-BUDAT,  "Posting Date in the Document
      LFBNR LIKE EKBE-LFBNR,  "Document No. of a Reference Document
      BELNR LIKE EKBE-BELNR,  "Number of Material Document
      BWART LIKE EKBE-BWART,  "Movement Type
      ELIKZ LIKE EKBE-ELIKZ,  "Delivery Completed Indicator
      MENGE LIKE EKET-MENGE,  "Scheduled quantity
      END OF ITAB.
DATA: BEGIN OF WTAB OCCURS 0,
      EBELN LIKE EKBE-EBELN,  "Purchasing Document Number
      EBELP LIKE EKBE-EBELP,  "Item Number of Purchasing Document
      BUDAT LIKE EKBE-BUDAT,  "Posting Date in the Document
      LFBNR LIKE EKBE-LFBNR,  "Document No. of a Reference Document
      BELNR LIKE EKBE-BELNR,  "Number of Material Document
      BWART LIKE EKBE-BWART,  "Movement Type
      ELIKZ LIKE EKBE-ELIKZ,  "Delivery Completed Indicator
      MENGE LIKE EKBE-MENGE,  "Quantity (Delivered)
      END OF WTAB.
I did a SELECT statement for table ITAB to append the fields of EBELN, EBELP and EINDT. Then i did another SELECT statement for table WTAB (using FOR ALL ENTRIES OF ITAB) for fields EBELN, EBELP, BUDAT, BWART, LRBNR and BELNR. Later, i did a loop in WTAB to move fields BUDAT, LFBNR and BELNR into table ITAB that corresponds to the EBELN and EBELP of ITAB, which looks something like this:
LOOP AT WTAB.
MOVE WTAB-BUDAT TO ITAB-BUDAT.
MOVE WTAB-LFBNR TO ITAB-LFBNR.
MOVE WTAB-BELNR TO ITAB-BELNR.
MOVE WTAB-BWART TO ITAB-BWART.
MODIFY ITAB TRANSPORTING BUDAT LFBNR BELNR BWART
  WHERE EBELN = WTAB-EBELN AND
        EBELP = WTAB-EBELP.
ENDLOOP.
I now need to ensure that the right line from WTAB (assume that in table WTAB will contain several lines for a particular EBELN) is moved to table ITAB (corresponding to the same EBELN and EBELP) based on several conditions:
1. If the sum of all WTAB-MENGE (Ex: 5-2+3 = 5 or 5-2-1 = 2) of an EBELN is LE to ITAB-MENGE (Ex: 5), only the WTAB line containing the earliest BUDAT (provided BWART = '101' or '122') is selected and moved into ITAB.
2. If the sum of all WTAB-MENGE (Ex: 5-3-2 = 0 or NULL value from the beginning) of an EBELN is 0 or blank, no line is selected to move to ITAB.
I was able to do logic that fulfill the first condition but i am unable to solve condition 2, because no matter what i do, a date (BUDAT) from WTAB still gets selected and moved to ITAB, although by right, no lines from WTAB should have been selected.
I can post the logic i used to fulfill condition 1 if you guys need to have a look at it.
Anybody could give me some hints?
I really need this urgently, i have to transport by the end of the week.

Ignore the earlier code i wrote, copied an older version of the code i written. Here's the one i am using now:
LOOP AT WTAB.
  AT NEW MENGE.
*--> Change value of movement type 102 and 122 to negative
    IF WTAB-BWART = '102' OR WTAB-BWART = '122'.
      COMPUTE NEGATIVE_VALUE = WTAB-MENGE * -1.
      MOVE NEGATIVE_VALUE TO WTAB-V_MENGE.
    ELSE.
      MOVE WTAB-MENGE TO WTAB-V_MENGE.
    ENDIF.
      ADD WTAB-V_MENGE TO SUM_MENGE.
  ENDAT.
ENDLOOP.
However, there is a flaw in the codes above. Since i'm using AT NEW MENGE...ENDAT statement, what would happen if the next value in MENGE is the same as the previous one (although they are of the same EBELN)? It wouldn't be taken into account, am i right in this?
As you have seen, i declared an extra field within WTAB as V_MENGE TYPE I and another 2 more field:
DATA: SUM_MENGE TYPE I.
DATA: NEGATIVE_VALUE TYPE I.

Similar Messages

  • I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library.

    I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library. 
    I don't see anything in Help that shows when you already have transfered all the files over.  Why would it want to erase and sync when I already have all the music folder copied over?  I didn't have an issue when I had another technician copy from one laptop to another.  Home sharing is also on but not being recognized.

    I suspect you only migrated the media folder instead of the complete working library. Either review the transfer process and copy over the entire iTunes folder from your old profile's music folder or see Recovering your iTunes library from your iPod or iOS device.
    tt2

  • Looping and setting cfset values (from a query)

    Stuck on how to get this to work.
    How would I go about looping and setting these values instead
    of doing them individually?
    The query this <cfset> references works fine and will
    work but repeats...
    <cfset ans1 = (qryGetPcts1.q1Ct / qryGetCounts.qID2) *
    100>
    <cfset ans2 = (qryGetPcts2.q2Ct / qryGetCounts.qID2) *
    100>
    <cfset ans3 = (qryGetPcts3.q3Ct / qryGetCounts.qID2) *
    100>
    <cfset ans4 = (qryGetPcts4.q4Ct / qryGetCounts.qID2) *
    100>
    <cfset ans5 = (qryGetPcts5.q5Ct / qryGetCounts.qID2) *
    100>
    So I'd like to loop and set them all instead...
    <cfloop index="i" from="1" to="27">
    <cfset ans#i# = (qryGetPcts#i#.q#i#Ct /
    qryGetCounts.qID2) * 100>
    </cfloop>
    But it's responding with this...
    Invalid CFML construct found on line 196 at column 19.
    ColdFusion was looking at the following text:
    I'm sure I'm missing something simple b/c this must be
    possible? Can I use a cfset in a loop?
    Help is appreciated

    In the main everything is in CF is in a struct. Armed with
    this information you use array notation to help you.
    <cfloop index="iCount" from="1" to="27">
    <cfset variables["ans" & iCount] =
    (variables["qryGetPcts" & iCount]["q" & iCount & "Ct"]
    / qryGetCounts.qID2) * 100>
    </cfloop>

  • How to select and read #define lines from a code file

    Hi,
    I would like to read a .m file
    and select the lines which begins with '#define PL-KEY', like
    {quote}
    #define PL-KEYTAG TAG_values
    #define PL-KEYGROUP GROUP_value
    #define PL-KEYINFO "INFO_ValueTxtMax120Char" // could be max 120 char
    ..... more PL-KEY keys
    {quote}
    and put the rest of that line until a '//' or '/*' , like
    {quote}
    TAG TAG_values
    GROUP GROUP_value
    INFO "INFO_ValueTxtMax120Char"
    {quote}
    into something like a list where my code above will loop through.
    I thought using something like
    cat "path/to/code.h" | while read line
    do
    #... what do I have to with "$line" ...
    if [[ "$line" == #define PL-KEY* ]] ; then
    # yes then... then what????
    done
    any suggestions?? I noticed today, I am still no shell expert
    Thanks again

    I can't help much with PlistBuddy, as I just recently found out about it myself.
    But for the code, here are some adjustments based on your comments.
    I stuck with shell scripting because you seem to be more comfortable with shell scripting, vs awk or perl.
    #!/usr/bin/env bash
    while read lb_def rest
    do
    if [[ "$lb_def" = #define && "$rest" = PL_KEY* ]]; then
    rest=${rest#PL_KEY}
    echo "${rest%/[/]}"
    fi
    if [[ "$lb_def" = # && "$rest" = define PL_KEY* ]]; then
    rest=${rest#define }
    rest=${rest#PL_KEY}
    echo "${rest%/[/]}"
    fi
    done </path/to/code.h
    If PL_KEY has stuff in front if it, like one of your posts where it was kPL_KEY, then you could modify the uses of PL_KEY to include the 'k', or you could wildcard it. If a single character, then
    if [[ "$lb_def" = #define && "$rest" = ?PL_KEY* ]]; then
    rest=${rest#?PL_KEY}
    If multiple characters could prefix PL_KEY, then you can use the multi-character wildcard
    if [[ "$lb_def" = #define && "$rest" = PL_KEY ]]; then
    rest=${rest#*PL_KEY}
    If you are worried, that PL_KEY might exist in the comment, then you could strip the comment before doing the tests
    #!/usr/bin/env bash
    while read lb_def rest
    do
    rest=${rest%/[/]} # remove comments.
    if [[ "$lb_def" = #define && "$rest" = PL_KEY ]]; then
    rest=${rest#*PL_KEY}
    echo "${rest}"
    fi
    if [[ "$lb_def" = # && "$rest" = define PL_KEY ]]; then
    rest=${rest#define }
    rest=${rest#*PL_KEY}
    echo "${rest}"
    fi
    done </path/to/code.h
    Is that better?
    Message was edited by: BobHarris

  • HT1296 I just bought a new MacBook Pro and moved data over from my old MacBook Pro.   Everything seemed fine at first but Outlook 2011 for Mac will not run.  It just flashes the Outlook logo briefly and then closes.  Help!

    Everything seemed to work fine after moving everything over from my old MacBook Pro at first but I cannot run Outlook 2011 for Mac.  The logo displays briefly and then the app closes.  It never really even gets anything loaded other than the little logo.

    Try removing and reinstalling Outlook
    Next try posting in a more appropriate forum. this is the iPod touch forum

  • Questions on Analyzer Upgrade and Moving Analyzer Reports from Development to Production

    Hi,We run Analyzer 5.0.3. We are planning to go to Analyzer 7.2. Did any body go thru this upgrade? If so, what is your opinion and tips that may help. Also, we never had Analyzer development environment. We are planning on having Analyzer development environment. In our installation, all of the Analyzer reports are centrally developed based on user requests. Once we have development and production at the same Analyzer version, if a report is developed in the development system, how can the report be mirateed/moved from development to production system?Thank you for your help,Prasant

    Balaji,
    Has this been done yet?
    Gary
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by [email protected]:
    We are working on a document using which one should be able to move a portal instance from one database to another. It is still in draft version, once it is finalized we will be putting it on otn.
    Thanks and Regards
    Balaji<HR></BLOCKQUOTE>
    null

  • How to loop and add multiple records from db in .pdf using cfdocument

    I have a query that pulls a users information (Id, FirstName,
    LastName, Title,etc). I then use cfdocument to output a person's
    biography into a pdf. This is great, because we no longer have to
    manually create bios, as they are now all dynamically generated.
    The problem I have now is that we want to be able to select
    multiple users and create a .pdf with each of their bios included
    in the one pdf.
    How do I loop thru records from a sql database in a
    cfdocument that includes a header and footer in cfdocument items,
    and ensure that one persons bio doesn't continue on the page with
    anothers.
    Here's the code I have so far for the cfdocument:

    Put the query around just the body of your cfdocument not
    around the whole cfdocument tag. Also, move any query information
    out of the header and put that in the body of the document. Lastly,
    put a cfdocumentitem pagebreak after each bio...you will need to
    check the recordcount of the query against the row you are on so
    that you don't add an empty page break at the end.

  • Importing and moving MP3 playlist from CD to hard disk

    Hi,
    The source of one of my playlists is a CD with files in MP3 format. I've addded the playlist to iTunes but want to physically move the playlist into my iTunes library on the hard disk so that I don't need the CD in the drive to play it. I know how to move individual files and reset the source but can't see how to import and move an entire playlist so that iTunes knows where it is. Can anyone help?
    Thanks in advance.
    Jane

    Two ways. You can use Windows to copy them to the hard drive, and then add them to the iTunes library. Alternatively, you can set iTunes to "Copy files to iTunes Music folder..." (you will find that option in Edit > Preferences > Advanced > General) and then drag the files from the CD into iTunes.

  • Moving a line from a smartphone to a reg phone?

    Long story short...my granddaughter used to live with me and I added a line to a smart phone to our account she ran off and wont bring the I phone back to me...I wondering if I can move the service over to an extra phone I have? I don't have the to pay an early termination fee or I'd just turn it off...she was paying her portion until she ran off so lesson learned ...but now I just need to get control of my bill.

    Yes you can switch the phone.

  • A real task..( to search and display few lines from a log file)

    have a look at the following link
    http://computing.unn.ac.uk/staff/cgpb2/public_html/log.html
    i need to display to the users only the Hourly Transmission Statistics (Bytes Sent Requests Time) on a tabular format from the above mentioned link.
    t
    his is not easy
    can any one write down the code please..
    thank you very much.

    What have you done so far?
    What kind of approach are you going to take (aside from asking others to do it all for you)?
    Have you written the algorithm in psuedo-code? If so, can we see it? We might be able to give you a few pointers.

  • I downloaded a program on my macbook pro and moved the file now everytime i open the program it says repair now...how do i fix that

    i downloaded a program and moved the file from which it was orignally downloaded now everytime i open it it says repair now...what do i do to get it to stop doing that...i hit repair now every time and it still says it everytime upon the programs startup

    Photoshop needs to be in the folder within Applications in which it was originally created. Put it back where you got it.
    Did you actually complete the download process or were you maybe running from the .dmg that you downloaded?

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

  • How can I get my ES2 loops to play correctly? I keep getting the message that the audio is not found when I drag the loops from my audio browser even though they play fine in the preview.

    How can I get my ES2 loops to play correctly? I keep getting the message that the audio is not found when I drag the loops from my audio browser even though they play fine in the preview.

    It's exactly as I stated. Whenever I try to drag these kinds of loops (ESX24 / software instrument loops? the ones marked in green with the white music note next to them) from the loop browser into the timeline a message comes up saying Audio Not Found for that loop.  And a new track is created automatically when loops are dragged into the timeline, so I'm not creating some other random / synth instrument track so I'm not sure  what the deal is... But perhaps I'll try creating a software instrument track first and then drag the loop into that track and see what happens - maybe there's something with the default settings that automatically creates audio tracks whenever loops are imported?

  • 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 can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

Maybe you are looking for