×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Data scrape over multiple pages

Data scrape over multiple pages

Data scrape over multiple pages

(OP)
I am new to this forum and posting - but here is my issue. I am trying to grab data that is located on multiple pages in the same location. The Macro goes to a file and gets the part numbers (from input file) and then goes to get the data from Attachmate to put in another (output) file. This works for all data on the first page in Attachmate but when it goes to page 2 for each part number - which I see it go to on my screen - it returns the same data that was on page 1. I do not know how or what to do to fix this. Any help or direction would be great ! Thank you.


'======= Start of program

Open "C:\Users\dzgwtn\Desktop\Macro info\MXAdjustment.csv" for input as #1
Open "C:\Users\dzgwtn\Desktop\Macro info\MXAdjustment Report.csv" for output as #2


ACTION = "C"
INQ1100COMPLETE = "I0001"
UPD1100COMPLETE = "COMPLETE"


Sess0.Screen.WaitHostQuiet(1500)

Input #1, partx$
PartNum = right$("00"+partx,8)



Sess0.Screen.Sendkeys("<Clear>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("ms8p1100 <Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("t <tab><tab><tab><tab>0000 LGE <Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


While not eof(1)

Sess0.Screen.MoveTo 3, 42
Sess0.Screen.Sendkeys(PartNum+"<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 3, 42
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


Upd1100 = ""
Upd1100 = Sess0.Screen.GetString(8,25,4)
Upd1200 = Sess0.Screen.GetString(9,25,4)
Upd1300 = Sess0.Screen.GetString(10,25,4)
Upd1400 = Sess0.Screen.GetString(11,25,4)
Upd1500 = Sess0.Screen.GetString(12,25,4)
Upd1600 = Sess0.Screen.GetString(13,25,4)
Upd1700 = Sess0.Screen.GetString(14,25,4)
Upd1800 = Sess0.Screen.GetString(15,25,4)
Upd1900 = Sess0.Screen.GetString(16,25,4)
Upd2000 = Sess0.Screen.GetString(17,25,4)
Upd2100 = Sess0.Screen.GetString(18,25,4)
Upd2200 = Sess0.Screen.GetString(19,25,4)
Upd2300 = Sess0.Screen.GetString(20,25,4)

'==============Got to next page and continue to get data

Sess0.Screen.Sendkeys("<PF8>")
Sess0.Screen.Sendkeys("<tab>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

Upd2400 = ""
Upd2400 = Sess0.Screen.GetString(8,25,4)
Upd2500 = Sess0.Screen.GetString(9,25,4)
Upd2600 = Sess0.Screen.GetString(10,25,4)
Upd2700 = Sess0.Screen.GetString(11,25,4)
Upd2800 = Sess0.Screen.GetString(12,25,4)
Upd2900 = Sess0.Screen.GetString(13,25,4)
Upd3000 = Sess0.Screen.GetString(14,25,4)
Upd3100 = Sess0.Screen.GetString(15,25,4)
Upd3200 = Sess0.Screen.GetString(16,25,4)
Upd3300 = Sess0.Screen.GetString(17,25,4)
Upd3400 = Sess0.Screen.GetString(18,25,4)
Upd3500 = Sess0.Screen.GetString(19,25,4)
Upd3600 = Sess0.Screen.GetString(20,25,4)

'====Put data into excel file

Print #2, PartNum+","+Upd1100+","+Upd1200+","+Upd1300+","+Upd1400+","+Upd1500+","+Upd1600+","+Upd1700+","+Upd1800+","+Upd1900+","+Upd2000+","+Upd2100+","+Upd2200+","+Upd2300+","+Upd2400+","+Upd2500+","+Upd2600+","+Upd2700+","+Upd2800+","+Upd2900+","+Upd3000+","+Upd3100+","+Upd3200+","+Upd33000+","+Upd3400+","+Upd3500+","+Upd3600

Input #1, partx$
PartNum = right$("00"+partx,8)

RE: Data scrape over multiple pages

hi,

First off, just a clarification. You are not putting data in an Excel file. Rather, you are writing to a comma separated TEXT file that you probably intend to open/import with Excel.

It is a difference with a distinction, but its okay, if that's your method.

Now to the substance.

1. You have defined a CHANGE action code (SOP in many mainframe systems: A=ADD, C=CHANGE, D=DELETE, I=INQUIRY), it appears and two System messages:
ACTION = "C"
INQ1100COMPLETE = "I0001"
UPD1100COMPLETE = "COMPLETE"
 
... yet I see no use of them, the messages especially. These are what your code should use to determine what to do, how many pages to access.

2. In effect, you arrive at a traffic light, ALWAYS stop for 5 seconds and then blindly proceed through the intersection without regard to the condition of the light or the conditions in the intersection.
You do understand that your mainframe system operates ASYNCHRONOUSLY with your code.
That means that you send off your command, and you have to WAIT until the system responds COMPLETELY.
Could be less than a second as it often is. Could be longer. WHO KNOWS? Certainly 1500 ms is a crap shoot!

So the very first thing that you must do is determine the screen navigation logic loop: what happens when each message is encountered?
Your outer loop gets the data to drive the screen.
Your next inner loop determines what you do with your messages.

So it might look something like this, ASSUMING that your message area is row 24...

CODE

'
    Open "C:\Users\dzgwtn\Desktop\Macro info\MXAdjustment.csv" For Input As #1
    Open "C:\Users\dzgwtn\Desktop\Macro info\MXAdjustment Report.csv" For Output As #2
    
    Action = "C"
    INQ1100COMPLETE = "I0001"
    UPD1100COMPLETE = "COMPLETE"
    
    Sess0.Screen.SendKeys ("<Clear>")
    Sess0.Screen.SendKeys ("ms8p1100 <Enter>")
    Do Until Sess0.Screen.WaitForCursor(3, 42)
        DoEvents
    Loop
    
    Sess0.Screen.SendKeys ("t <tab><tab><tab><tab>0000 LGE <Enter>")
    Do Until Sess0.Screen.WaitForCursor(3, 42)
        DoEvents
    Loop
    
    Input #1, partx$
    PartNum = Right$("00" + partx, 8)
    
    Do While Not EOF(1)                                                         'your main loop
        Do Until Trim(Sess0.Screen.GetString(24, 2, 79)) = UPD1100COMPLETE      'your navigation loop
    
            'issue next screen command
        Loop
    Loop 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close