Below are tidbits used when you are automating SAP applications.
''' Generic function to verify success message displays in status bar
Public Function SAP_VerifySuccessMsg(objSAPWindowName)
On Error Resume Next
Report_WriteStepHeader("<B> Verify Success Message in the statusbar </B>")
SAPGuiSession("SAPSession").SAPGuiWindow(objSAPWindowName).SAPGuiStatusBar("StatusBar").Sync
strSBarSuccessMsg = SAPGuiSession("SAPSession").SAPGuiWindow(objSAPWindowName).SAPGuiStatusBar("StatusBar").GetROProperty("text")
intTransNum = Trim(Split(Split(strSBarSuccessMsg,"Transaction ")(1)," saved")(0))
Print intTransNum
On Error GoTo 0
SAP_VerifySuccessMsg = intTransNum
End Function
''Making fields values empty:
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SelectMenuItemById "DELSCTX"
If SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").Exist(intMinSyncTime) Then
PODefaultValue=SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").GetROProperty("value")
If PODefaultValue<>"" Then
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").SetFocus
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").SetCaretPos 0
Set WScript = createobject("WScript.Shell")
WScript.SendKeys "^"+"{A}"
WScript.SendKeys "{DEL}"
Set WShell = Nothing
End If
End If
''''################### to make sure cell is editable in SAP table
BlockCellEditable1 = SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4"). SAPGuiTable("Dates").IsCellEditable(1, "Block")
If Trim(BlockCellEditable1)="True" Then
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4"). SAPGuiTable("Dates").SetCellData 1,"Block",""
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4").
SAPGuiTable("Dates").SelectCell 1,"Block"
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4").SendKey ENTER
If SAPGuiSession("SAPGuiSession").SAPGuiWindow("Information").Exist Then
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Information").SAPGuiButton("Continue (Enter)").Click
End If
End If
'''############Changing reply mode type
Setting.WebPackage("ReplayType") = 2 'Mouse
Browser("KnowledgeInbox").Page("ReplayType").WebEdit("txtReplayType").Set "KnowledgeInbox"
Browser("KnowledgeInbox").Page("ReplayType").WebButton("Type and enable me").Click
Setting.WebPackage("ReplayType") = 1 'Events
'''############
''' Generic function to verify success message displays in status bar
Public Function SAP_VerifySuccessMsg(objSAPWindowName)
On Error Resume Next
Report_WriteStepHeader("<B> Verify Success Message in the statusbar </B>")
SAPGuiSession("SAPSession").SAPGuiWindow(objSAPWindowName).SAPGuiStatusBar("StatusBar").Sync
strSBarSuccessMsg = SAPGuiSession("SAPSession").SAPGuiWindow(objSAPWindowName).SAPGuiStatusBar("StatusBar").GetROProperty("text")
intTransNum = Trim(Split(Split(strSBarSuccessMsg,"Transaction ")(1)," saved")(0))
Print intTransNum
On Error GoTo 0
SAP_VerifySuccessMsg = intTransNum
End Function
''Making fields values empty:
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SelectMenuItemById "DELSCTX"
If SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").Exist(intMinSyncTime) Then
PODefaultValue=SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").GetROProperty("value")
If PODefaultValue<>"" Then
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").SetFocus
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Purchasing Documents").SAPGuiEdit("Purchasing document").SetCaretPos 0
Set WScript = createobject("WScript.Shell")
WScript.SendKeys "^"+"{A}"
WScript.SendKeys "{DEL}"
Set WShell = Nothing
End If
End If
''''################### to make sure cell is editable in SAP table
BlockCellEditable1 = SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4"). SAPGuiTable("Dates").IsCellEditable(1, "Block")
If Trim(BlockCellEditable1)="True" Then
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4"). SAPGuiTable("Dates").SetCellData 1,"Block",""
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4").
SAPGuiTable("Dates").SelectCell 1,"Block"
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Change S/O SysB SDI 4").SendKey ENTER
If SAPGuiSession("SAPGuiSession").SAPGuiWindow("Information").Exist Then
SAPGuiSession("SAPGuiSession").SAPGuiWindow("Information").SAPGuiButton("Continue (Enter)").Click
End If
End If
'''############Changing reply mode type
Setting.WebPackage("ReplayType") = 2 'Mouse
Browser("KnowledgeInbox").Page("ReplayType").WebEdit("txtReplayType").Set "KnowledgeInbox"
Browser("KnowledgeInbox").Page("ReplayType").WebButton("Type and enable me").Click
Setting.WebPackage("ReplayType") = 1 'Events
'''############
No comments:
Post a Comment
Note: only a member of this blog may post a comment.