08-10-2017 10:13 AM - edited 02-04-2024 1:55 AM
Guys I need some help,
I am writing a script to automate the thousands of credits I have to issue every month. But there are some popups which are debugging.
I create credits in transaction VA01 referencing a existent invoice. I can not create Credits or Debit if this referenced invoice has already credits or have a credit return.
Some invoices on list have credits, other invoices have credits and debits and also returns.
the problem is because when the invoice have this credits one pop up will shows up, Information pop up, but I don't never know if the invoice I am doing will show one information popup or two or three.
When this popup information shows up, I have to go out of this invoice, and process the next one. When I have only one popup, great, I can do it, but when I have 2 or more, I can do it. if second popup doestn exist, It goes inside de order, but i cancel it and i go back to the principal window VA01 and i do next;
Therefore if a second popup exist, it will be showed just after the first poppup, and then it goes inside the order, where i will cancel and go outo to VA01 screen and then process next.
Besides this information popups, I also have the internal notes popups, these always come first if exists, and it is managed well, once I can continue issuing the order without problems.
here is my code:
StartTime = Timer
Number = Worksheets("Credit").Cells(2, 7).Value
Number = Number + 1
For i = 6 To Number
OrderType = Worksheets("Credit").Cells(i, 1).Value
Invoice = Worksheets("Credit").Cells(i, 2).Value
Delta = Worksheets("Credit").Cells(i, 10).Value
Billingdate = Worksheets("Credit").Cells(3, 2).Value
OrderReason = Worksheets("Credit").Cells(i, 4).Value
Payterms = Worksheets("Credit").Cells(i, 3).Value
Line1 = Worksheets("Credit").Cells(i, 11).Value
Line2 = Worksheets("Credit").Cells(i, 12).Value
Line3 = Worksheets("Credit").Cells(i, 13).Value
Line4 = Worksheets("Credit").Cells(i, 14).Value
Line5 = Worksheets("Credit").Cells(i, 15).Value
Line6 = Worksheets("Credit").Cells(i, 16).Value
Line7 = Worksheets("Credit").Cells(i, 17).Value
Line8 = Worksheets("Credit").Cells(i, 18).Value
Line9 = Worksheets("Credit").Cells(i, 19).Value
Line10 = Worksheets("Credit").Cells(i, 20).Value
Text = Line1 & Chr(10) & Chr(10) & Line2 & Chr(10) & Line3 & Chr(10) & Chr(10) & Line4
session.findById("wnd[0]").Maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "VA01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxt[0]").Text = OrderType
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/tabsMYTABSTRIP/tabpRFAK/ssub/1/2/ctxt[0]").Text = Invoice
session.findById("wnd[1]/usr/tabsMYTABSTRIP/tabpRFAK/ssub/1/2/ctxt[0]").caretPosition = 8
session.findById("wnd[1]/tbar[0]/btn[5]").press
*** HERE comes the first popups - internal notes popups - tehre are usually 2 popups - here is fine - if exists it will press enter and continue, if doesn't exists will jump and continue same way***
If session.ActiveWindow.Name = "wnd[1]" Then
If session.findById("wnd[1]").Text = "Internal order notes (H-pop" Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
End If
End If
If session.ActiveWindow.Name = "wnd[1]" Then
If session.findById("wnd[1]").Text = "Internal order notes (H-pop" Then
session.findById("wnd[1]/tbar[0]/btn[0]").press
End If
End If
*** HERE IS PROBLEM - information popups - if is one only, perfect. It will not execute this invoice, and it write down in my excel that credits already exists and will continue the next line.***
**Therefore, if there is two or more information popups, the second popup will be displayed just after I have clicked .press from the first one, and so on, and only after press enter in all of then it will goes inside the order, where then I will have to cancel and go to the initial screen VA01 and then GoTo Nextone***
session.findById ("wnd[0]/sbar")
Worksheets("Credit").Cells(i, 21).Value = session.findById("wnd[0]/sbar").Text
session.findById("wnd[0]").sendVKey 3
Nextone:
Next i
SecondsElapsed = Round(Timer - StartTime, 2)
MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation
End Sub
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.