Solved

Need help scraping information from SAP GUI

Posted on 2010-09-15
2
1,618 Views
Last Modified: 2013-12-08
I'm trying to pull information from the SAP GUI, and load it into another application. Specifically, I'm trying to get the Vendor Number, Vendor Name, and Invoice Number from the FB60 transaction.  A friend gave me the attached code, but it fails at session.activeWindow.handle with "Object doesn't support this property or method" Any help would be appreciated.
'The following variables are set to define the SAP Client GUI as an object, enable the SAP Scripting Engine, define the SAP Connections, and Sessions to search through for the window title that matches the windowMatchString.
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
Set connection = application.Children(0)
Set session = connection.Children(0)
' Retrieve the window title from the app plan as it runs
windowMatchString = "Enter vendor invoice: Company code 1000"
'The following For Each Statement will cycle through all of the open SAP Client Windows
'and find the window that matches the windowMatchString variable and was last active.
For Each Session in connection.Children
     If session.activeWindow.handle = FindWindow(windowMatchString) Then
      'Pulls the document for the correct window that is active.
      'found the matching session
       set window = session.activeWindow
'
'Define fields accepted from SAP
'Vendor Number
set VendorNumber = application.findById("/app/con[0]/ses[0]/wnd[0]/usr/ctxtINVFO-ACCNT")
'Vendor Name
set VendorName = application.findById("/app/con[0]/ses[0]/wnd[0]/usr/txtADRS-LINE0")
'Invoice Number
set InvoiceNumber = application.findById("/app/con[0]/ses[0]/wnd[0]/usr/txtINVFO-XBLNR")
End If
Next

Open in new window

0
Comment
Question by:JJSystems
2 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 33687502
Hi, I really have no idea, but you seem to be using the variable name "Session" for two different things.  Try changing this line:
Set session = connection.Children(0)

to this
Set colSessions = connection.Children(0)

Then change this:
For Each Session in connection.Children

to this
For Each Session in colSessions

Regards,

Rob.
0
 

Accepted Solution

by:
JJSystems earned 0 total points
ID: 33691543
The issue was resolved after upgrading the SAP GUI client to 7.2.  The handle property wasn't exposed in the version (6.2) I was running.  Thanks for looking.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running Visio Macro from VBS File 3 74
fso.FolderExists("\\server\HiddenFolder$") 4 64
ERP application comparison 1 20
VB Script: restart service function 30 36
Note: You must have administrative privileges in order to create/edit Roles. Salesforce.com (http://www.salesforce.com/) (SFDC) is a cloud-based customer relationship management (CRM) system. It is a database most commonly used by sales and marke…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question