Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data scrape over multiple pages

Status
Not open for further replies.

12skidoo

Technical User
Mar 11, 2015
1
US
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)
 
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:
[pre]
ACTION = "C"
INQ1100COMPLETE = "I0001"
UPD1100COMPLETE = "COMPLETE"
[/pre]
... 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top