cancel
Showing results for 
Search instead for 
Did you mean: 

Script POPUPS management when creating Credits

0 Kudos

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***


If session.ActiveWindow.Name = "wnd[1]" Then

If session.findById("wnd[1]").Text = "Information" Then

Worksheets("Credit").Cells(i, 21).Value = "CREDITS/RETURNS ALREADY ISSUED"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[1]/usr/btn[1]").press
session.findById("wnd[0]").sendVKey 3
GoTo Nextone

End If
End If

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/ctxt[0]").Text = Billingdate
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/ctxt[0]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/ctxt[0]").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/sub/2/3/1/tblSAPMV45ATCTRL_U_ERF_GUTLAST").getAbsoluteRow(0).Selected = True
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/sub/2/3/1/tblSAPMV45ATCTRL_U_ERF_GUTLAST/txt[0,0]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/sub/2/3/1/tblSAPMV45ATCTRL_U_ERF_GUTLAST/txt[0,0]").caretPosition = 4
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssub/2/3/sub/2/3/1/sub/2/3/1/2/btn[9]").press
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\07/ssub/2/3/tblSAPLV69ATCTRL_KONDITIONEN/txt[3,2]").Text = Delta
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\07/ssub/2/3/tblSAPLV69ATCTRL_KONDITIONEN/txt[3,2]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\07/ssub/2/3/tblSAPLV69ATCTRL_KONDITIONEN/txt[3,2]").caretPosition = 16
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]/usr/sub/1/btn").press
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\01/ssub/2/3/cmb[0]").Key = OrderReason
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\01/ssub/2/3/cmb[0]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\03").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\03/ssub/2/3/ctxt[3]").Text = Payterms
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\03/ssub/2/3/ctxt[3]").SetFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\03/ssub/2/3/ctxt[3]").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10").Select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10/ssub/2/3/sub/2/3/1/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[0]/shell").selectItem "Z021", "Column1"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10/ssub/2/3/sub/2/3/1/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[0]/shell").ensureVisibleHorizontalItem "Z021", "Column1"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10/ssub/2/3/sub/2/3/1/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[0]/shell").doubleClickItem "Z021", "Column1"
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10/ssub/2/3/sub/2/3/1/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").Text = Text
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10/ssub/2/3/sub/2/3/1/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").setSelectionIndexes 251, 251
session.findById("wnd[0]").sendVKey 3
session.findById("wnd[0]/tbar[0]/btn[11]").press

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

Accepted Solutions (0)

Answers (0)