Clicky

The partial code below uses "500000001723" which can not be a static entry.  Is there a way to make this an Input box, that were ever in the code it is called, that number is used?  I need the input validated to a 12 digit number that begins with a 5

Can this even be done?  Please advise and thanks. -R-
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = "500000001723"
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0

asked 10/11/2011 02:21

RWayneH's gravatar image

RWayneH ♦♦


35 Answers:
Like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
Dim strAENNR
If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
strAENNR = session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text
If Left(strAENNR,1) = "5" And Len(strAENNR) = 12 Then
	session.findById("wnd[0]/tbar[0]/btn[0]").press
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
End If
link
Zvonko's gravatar image

Zvonko

Check also this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Dim strAENNR
If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
strAENNR = InputBox("Enter AENNR with leading '5' folowed by 11 digits","500000000000")
If Left(strAENNR,1) = "5" And Len(strAENNR) = 12 Then
	session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
	session.findById("wnd[0]/tbar[0]/btn[0]").press
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
	session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
Else
	MsgBox("Invalid AENNR entered: " & strAENNR, "Error")
End If
link
Zvonko's gravatar image

Zvonko

I see Ln1 dims it as: strAENNR.

What is Ln 17 & 18, doing.  Does this open a input box for whatever strAENNR is?  and does it remember what is entered for it to be used later in the code.

I am new to this, but understand vba  Does this insert a popup dialog box to put in the 12 digit 5 number? or does the code stop on that field so the value can be put it?  I am used to the vba Input box statements...

My example code Ln 15 thru 22 are not contained in an If..   End if.  Does this matter?  I just copied out enough lines to show an example of the 12 digit 5 number.

I notice that your code Ln 18 starts with an If.. and you added in Ln an End If...  I was wondering if I need to put the End If up higher on Ln18.5?  Or do I carry the End If to the bottom of my code.

Forgive my novice level here, just what to learn this better.

Just for future thought, can I also create a dropdown to select from?  Then run some code based on the selection, just like in vba?

Please advise and thanks for the reply. -R-

link
RWayneH's gravatar image

RWayneH

This statement does press a button:
session.findById("wnd[0]/tbar[0]/btn[0]").press

So, that statement has to be inside the if-endif section when the entered number can be checked.

Same as that line put everything inside if-endIf what can be executed only when number is OK.

link
Zvonko's gravatar image

Zvonko

I see your second post has the Input and error message.  Nice!!  There are many more session.findbyId .....  statements after this... and I want to make sure the value entered is stored for later use...  I could post the whole thing but it have to wait til tomorrow, but if I have a good understanding if how to keep the If block together I should be able to do the edits. -R-
link
RWayneH's gravatar image

RWayneH

Was Jscript the proper group to post .vbs questions too?
link
RWayneH's gravatar image

RWayneH

The whole transaction does not make sense with wrong Number.
So an Exit Sub after the error message would be the better choice.

 
link
Zvonko's gravatar image

Zvonko

Last quick question.  Can I comment code lines in .vbs as I can in .vba using the '
link
RWayneH's gravatar image

RWayneH

On the Exit Sub, is there a way to force the proper input by sending them right back to the input?  This would eliminate the need for an Exit Sub.. correct?
link
RWayneH's gravatar image

RWayneH

When I tried to run this solution it failed and did not even get to the Input box.  Error: "Cannot use paraenthesis when calling a Sub -"  I was using the second solution that had the Else MsgBox ..  I can not tell you what line it is error on, as it is not vb or vba, and it does not goto to debug or the vb editor.  This uses a .vbs file to execute.

Still need some help.  Please advise and thanks. -R-
link
RWayneH's gravatar image

RWayneH

Remove the parenthesis like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Dim strAENNR
If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
strAENNR = InputBox("Enter AENNR with leading '5' folowed by 11 digits","500000000000")
If Left(strAENNR,1) <> "5" Or Len(strAENNR) <> 12 Then
   MsgBox "Invalid AENNR entered: " & strAENNR, "Error"
   Exit Sub
End If
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
link
Zvonko's gravatar image

Zvonko

Can you be more specific about where they were removed?  What line numbers?

Also, if there is a setFocus or select...  How do I reuse the stored value?  Maybe we can pretend that the line in my original code needed to use it?  
link
RWayneH's gravatar image

RWayneH

In my last posting in line 19 were braces () before that are now removed.

Line 17 is the InputBox() statement to store the user entered value into variable: strAENNR

Use that variable if possible otherwhere in the procedure.
link
Zvonko's gravatar image

Zvonko

Ok, now I see it, they where around the MsgBox statement.  Thanks.

Sorry I am not very good at this..  How in the code below, line 2 would I call that value?

Instead of the = 500000001723 would it be = strAENNR  ?

Also, thanks for moving the Exit Sub up  -R-
1:
2:
3:
4:
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = "500000001723"
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
link
RWayneH's gravatar image

RWayneH

For your line 2 see my line 22 in my last post. There you see exact how you assign the variable value to the input field.

And for your "moving" of Exit Sub that was not Moving! That Exit Sub is a new exit from the procedure in case that user did not enter 12 digits with leading 5 digit. The other one or more Exit Sub stay unchanged.

link
Zvonko's gravatar image

Zvonko

Sorry it took so long to reply, I had issues testing this...  it is still failing.  The failure I believe is on Ln20.  "Exit Sub".  Because we are not using a Sub and End Sub, I do not think it understands what a Sub is.  -R-
link
RWayneH's gravatar image

RWayneH

The Block of code that you invoke in upper procedure is either a Sub or a Function.
That is the first statement of the block.

Perhaps is a good idea to show the whole story so I can see what exactly you are doing and what do you try to improve.


link
Zvonko's gravatar image

Zvonko

The whole code is below.  I was not sure that .vbs  used Sub statements..   The error reads Invalid 'exit' statement.   None of the .vbs scripts have a Sub and End Sub statement.  This was recorded in SAP.   -R-
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
Dim strAENNR

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize

strAENNR = InputBox("Enter AENNR with leading '5' folowed by 11 digits","500000000000")
If Left(strAENNR,1) <> "5" Or Len(strAENNR) <> 12 Then
   MsgBox "Invalid AENNR entered: " & strAENNR, "Error"
   Exit 
End If

session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR

session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/txtMARC-FXHOR").text = "12"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISPO").text = "999"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").caretPosition = 2
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-BESKZ").text = "E"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-SOBSL").text = "50"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGPRO").text = ""
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGFSB").text = "0100"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-DZEIT").text = ""
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-PLIFZ").text = "12"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14").select
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-STRGR").text = "Z2"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/txtMARC-LOSGR").text = "100.000"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/chkMARC-KZKUP").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-RAUBE").text = "01"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").caretPosition = 0
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").setFocus
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").caretPosition = 12
session.findById("wnd[0]/tbar[1]/btn[6]").press
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").text = "1005"
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").setFocus
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").caretPosition = 4
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").caretPosition = 4
session.findById("wnd[0]/tbar[0]/btn[11]").press
link
RWayneH's gravatar image

RWayneH

I removed the Sub from Exit Sub in Ln22.  Still did not work.  Same error. -R-
link
RWayneH's gravatar image

RWayneH

OK, then you have to do it by if-then-else:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
Dim strAENNR

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize

strAENNR = InputBox("Enter AENNR with leading '5' folowed by 11 digits","500000000000")
If Left(strAENNR,1) <> "5" Or Len(strAENNR) <> 12 Then
   MsgBox "Invalid AENNR entered: " & strAENNR, "Error"
Else
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/txtMARC-FXHOR").text = "12"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISPO").text = "999"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").caretPosition = 2
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-BESKZ").text = "E"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-SOBSL").text = "50"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGPRO").text = ""
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGFSB").text = "0100"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-DZEIT").text = ""
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-PLIFZ").text = "12"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14").select
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-STRGR").text = "Z2"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").caretPosition = 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/txtMARC-LOSGR").text = "100.000"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/chkMARC-KZKUP").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-RAUBE").text = "01"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").caretPosition = 0
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").setFocus
session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").caretPosition = 12
session.findById("wnd[0]/tbar[1]/btn[6]").press
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").text = "1005"
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").setFocus
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").caretPosition = 4
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").caretPosition = 4
session.findById("wnd[0]/tbar[0]/btn[11]").press
End If
link
Zvonko's gravatar image

Zvonko

Thanks.. no error now, however when the wrong 12 digit number is loaded it fails.  Is there a way to return the user back to the input box, until they enter a valid 12 digit number that begins with a 5?  -R-
link
RWayneH's gravatar image

RWayneH

Check this method:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
Dim strAENNR

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
do 
  wscript.sleep 500
  strAENNR = InputBox("Enter AENNR with leading '5' folowed by 11 digits","AENNR","500000000000")
  If Left(strAENNR,1) <> "5" Or Len(strAENNR) <> 12 Then
     If Len(strAENNR) > 0 Then
       MsgBox "Invalid AENNR entered: " & strAENNR
	 End If
  Else
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
     session.findById("wnd[0]/tbar[0]/btn[0]").press
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/txtMARC-FXHOR").text = "12"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISPO").text = "999"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").caretPosition = 2
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-BESKZ").text = "E"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-SOBSL").text = "50"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGPRO").text = ""
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGFSB").text = "0100"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-DZEIT").text = ""
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-PLIFZ").text = "12"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").caretPosition = 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14").select
     session.findById("wnd[0]").sendVKey 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-STRGR").text = "Z2"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").caretPosition = 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/txtMARC-LOSGR").text = "100.000"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/chkMARC-KZKUP").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-RAUBE").text = "01"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").caretPosition = 0
     session.findById("wnd[0]/tbar[0]/btn[11]").press
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").setFocus
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").caretPosition = 12
     session.findById("wnd[0]/tbar[1]/btn[6]").press
     session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").text = "1005"
     session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").setFocus
     session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").caretPosition = 4
     session.findById("wnd[1]").sendVKey 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").caretPosition = 4
     session.findById("wnd[0]/tbar[0]/btn[11]").press
  End If
Loop Until strAENNR=""
link
Zvonko's gravatar image

Zvonko

New error is: Object required: 'WScript' -   Input box did not even open..  The attempt prior to this worked... just failed when an invalid 12 digit was loaded.  Not sure what is going on now.  -R-

link
RWayneH's gravatar image

RWayneH

Remove line 19
Also change line 20 to former InputBox() syntax.

link
Zvonko's gravatar image

Zvonko

Show me your current running script and explain what condition you want to be fulfiled to run once.
So if the user enters the correct input then it should do and exit.
If he does input wrong then repeat the input until what?
link
Zvonko's gravatar image

Zvonko

I submitted the whole script earlier in this thread.  I tested the latest solution and it appear to work, however it loops until I blank the input box.  What should happen is when a valid 12 digit number beginning with a 5 get entered into the input box, the code runs through once.  If an invalid 12 digit code is entered, reset the dialog box, and force the user to try again until a valid one is entered.  If they want to exit with entering one, they can use the "x" in the upper righthand corner of the input box.  Hope this makes sense. -R-
link
RWayneH's gravatar image

RWayneH

Make sense but I do not see where the error stated in http:#36995327 is comming from...

link
Zvonko's gravatar image

Zvonko

Check this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
Dim strAENNR

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
do 
  strAENNR = InputBox("Enter AENNR with leading '5' folowed by 11 digits","500000000000")
  If Left(strAENNR,1) <> "5" Or Len(strAENNR) <> 12 Then
     If Len(strAENNR) > 0 Then
       MsgBox "Invalid AENNR entered: " & strAENNR
     End If
  Else
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
     session.findById("wnd[0]/tbar[0]/btn[0]").press
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-PMATN").caretPosition = 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/txtMARC-FXHOR").text = "12"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2482/ctxtMARC-DISPO").text = "999"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP12/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2483/ctxtMARC-DISLS").caretPosition = 2
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-BESKZ").text = "E"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-SOBSL").text = "50"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGPRO").text = ""
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2484/ctxtMARC-LGFSB").text = "0100"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-DZEIT").text = ""
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-PLIFZ").text = "12"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2485/txtMARC-WEBAZ").caretPosition = 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14").select
     session.findById("wnd[0]").sendVKey 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-STRGR").text = "Z2"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP14/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2492/ctxtMARC-VRMOD").caretPosition = 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/txtMARC-LOSGR").text = "100.000"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP26/ssubTABFRA1:SAPLMGMM:2000/subSUB3:SAPLMGD1:2903/chkMARC-KZKUP").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-RAUBE").text = "01"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP19/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2701/ctxtMARA-BEHVO").caretPosition = 0
     session.findById("wnd[0]/tbar[0]/btn[11]").press
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").text = strAENNR
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").setFocus
     session.findById("wnd[0]/usr/ctxtRMMG1-AENNR").caretPosition = 12
     session.findById("wnd[0]/tbar[1]/btn[6]").press
     session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").text = "1005"
     session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").setFocus
     session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").caretPosition = 4
     session.findById("wnd[1]").sendVKey 0
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05").select
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMARA-MTPOS_MARA").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").text = "0004"
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").setFocus
     session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP05/ssubTABFRA1:SAPLMGMM:2000/subSUB2:SAPLMGD1:2157/ctxtMVKE-MTPOS").caretPosition = 4
     session.findById("wnd[0]/tbar[0]/btn[11]").press
     strAENNR=""
  End If
Loop Until strAENNR=""
link
Zvonko's gravatar image

Zvonko

What is the reason for the Loop Until at the end?  Is that the only way to stop it?  People that do not understand the script will loop through it over and over and think it is broke.  Is there any way to just let it run once?  If a bad number is loaded, force user back to the Input until a valid number is loaded.  Break out of the script if the "x" is clicked in the input box..  No loop please.  -R-
link
RWayneH's gravatar image

RWayneH

I do not know about that error now... it has not happened since I removed Ln19 in an earlier direction. -R-
link
RWayneH's gravatar image

RWayneH

So what is the state now? Does it work as  you asked me to make it?
link
Zvonko's gravatar image

Zvonko

Yes it works, but it loops.  I do not recall asking for it to loop, but if that is the only way to get it to stop, so be it.  There will not be a time that it needs to run more than once. -R-
link
RWayneH's gravatar image

RWayneH

Look at the bottom of the source:
1:
2:
3:
strAENNR=""
  End If
Loop Until strAENNR=""
If it has that assignment in upper line 1 to empty string then it should exit after one correct display.
You asked it to loop as long as wrong entries are made here: http:#36994758
link
Zvonko's gravatar image

Zvonko

thanks for the help. -R-
link
RWayneH's gravatar image

RWayneH

You are welcome.
link
Zvonko's gravatar image

Zvonko

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

Asked: 10/11/2011 02:21

Seen: 956 times

Last updated: 11/04/2011 03:52