Quantcast
Channel: SCN: Message List - Scripting Languages
Viewing all articles
Browse latest Browse all 1708

Re: Gui navigation - entering data through VBA

$
0
0

The answer to the above question is no.  You cannot address a field that is not visible. :/

 

I have been playing with a variety of work-arounds to address the different screen resolution issue.

 

This is the best I've come up with so far....

 

Sub testoperations()

 

'Logs onto SAP, unless already connected it'll bind the connection

Call SapLogin

 

Dim TravelTime As String

Dim TimeOnsite As String

Dim Mileage As String

TravelTime = "0"

TimeOnsite = "240"

Mileage = "0"

 

AppActivate Session.findById("wnd[0]").Text

 

Dim TestForField As String

 

'**************

'Operations tab

'**************

Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2").Select

 

'Travel Time

Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,0]").Text = TravelTime

'Time Onsite

Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,3]").Text = TimeOnsite

Session.findById("wnd[0]").sendVKey 0

 

On Error Resume Next

' Test to see if 5th row is visible

TestForField = Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,4]").Text

'MsgBox Err.Description & " " & Err.Number

 

If Err.Number = 619 Then

    'Do this if 5th row not visible

    Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS").verticalScrollbar.Position = 1

    Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,3]").Text = Mileage

Else

    'do this if 5th row is visible

    Session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,4]").Text = Mileage

End If

Session.findById("wnd[0]").sendVKey 0

On Error GoTo 0

 

End Sub

 

The above does work, but it requires trapping the error when it can't see a particular field.  The only issue with doing it this way is that the 3 fields are mandatory and right when it executes the test portion of the code (in bold) SAP throws a quick error because of the mandatory field.  It didn't matter where I tested it, I tried at the beginning without doing anything yet, as well as where you see it in this example.

 

There's just something about testing for an error that bothers me.  I've  been able to avoid error trapping in most VBA situations, but it seems this is the only way I could come up with short of actually checking for screen resolution, but even then, I'm not entirely sure that all monitors will display it all at the higher screen resolution, so checking for what is and isn't visible seems to be the best way to do it.  I would just like to avoid the additional SAP error if possible.

 

Any ideas, suggestions or a better way to accomplish the same task?

 

Thanks,

 

RJ


Viewing all articles
Browse latest Browse all 1708

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>