cynthiatmi
cynthiatmi

Reputation: 9

Input data from excel to SAP GUI then output specific row and column back to excel

Initial question is at the bottom

UPDATE:

Here is what I'm working with so far, but it gives me error 619 because SAP isn't returning data when the notification number isn't found.

Sub QM03()

Set SapGuiAuto = GetObject("SAPGUI")  'Get the SAP GUI Scripting object
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection

'Start the transaction to view a table session.StartTransaction "QM03"

Dim rngNotificationNumbers As Range
Set rngNotificationNumbers = Range("A4:A704")
Dim arrNotificationNumbers(700) As String
Dim cell As Range
Dim i As Long
i = 0

For i = 0 To UBound(arrNotificationNumbers) - 1
session.FindById("wnd[0]/usr/ctxtRIWO00-QM03").Text = arrNotificationNumbers(i)
session.FindById("wnd[0]").SendVKey 0
StatusBarText = session.FindById("wnd[0]/sbar/pane[0]").Text
If InStr(StatusBarText, " does not exist") Then
  GoTo NextIteration
End If

NextIteration:
Next

End Sub

`

***I'm new to SAP and VBA, but I really need some help with it!

I'm trying to take notification numbers from an excel sheet, input it into QM03, and from there go to 'Items' to output the 'Defect type' to excel and then go to 'Item Task', in the row with the task code P020, and output the 'Task Text' to excel.

If the notification number is not found, I'd want to skip it and move on to the next one.

I'm using SAP GUI for Windows.

I'd truly appreciate any help! Thank you!***

Upvotes: 0

Views: 1173

Answers (1)

Storax
Storax

Reputation: 12177

Instead of

If InStr(StatusBarText, " does not exist") Then
  GoTo NextIteration
End If

NextIteration:

Do something like that

If InStr(StatusBarText, " does not exist") Then
  ' Do nothing 
else
   ' Do your stuff here
End If

and remove the label NextIteration:

PS You seem to miss basic programming knowledge so you might have a look here or other sites for beginners

Upvotes: 1

Related Questions