Skip to Content
0
Former Member
Apr 08, 2010 at 06:30 PM

Problem in comparing two dates in SAP textfields

52 Views

Hello experts, i have a huge problem and i would like to know if im doing something wrong.

i need to compare two dates from two sap fields and then take an action. but im having problem in comparing these two dates. below is the code.

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/txtSO_ORDER-LOW").text = "xxxxxxx"
session.findById("wnd[0]/usr/txtSO_ORDER-LOW").caretPosition = 8
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/lbl[12,10]").setFocus
session.findById("wnd[0]/usr/lbl[12,10]").caretPosition = 6
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4411/subSUBSCREEN_TC:SAPMV45A:4912/subSUBSCREEN_BUTTONS:SAPMV45A:4050/btnBT_POPO").press
session.findById("wnd[1]/usr/txtRV45A-POSNR").text = "xxxx"	
session.findById("wnd[1]/usr/txtRV45A-POSNR").caretPosition = 4
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4411/subSUBSCREEN_TC:SAPMV45A:4912/tblSAPMV45ATCTRL_U_ERF_ANGEBOT/ctxtRV45A-MABNR[1,0]").caretPosition = 5
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\03").select
dim var1,var2
Set var1 = session.findById("/app/con[0]/ses[0]/wnd[0]/usr/tabsTAXI_TABSTRIP/tabpT\03/ssubSUBSCREEN_BODY:SAPLV45W:4201/ctxtVEDA-VBEGDAT").text
Set var2 = "4/01/2010"
If var1 == var2 Then
	session.findById("wnd[0]").sendVKey 3
End If