cancel
Showing results for 
Search instead for 
Did you mean: 

SAP field - VBA InStr problems

Former Member
0 Kudos

Hello,

I'm trying to find a value in a SAP field.

The field displays values like 100, 101, 102, 103, 200, 201, 300 etc. I want to identify those items that ends with two zeros and perform a action on those.

This is what i got now:

' Dimming the field

Dim SOItemNmbr

Set SOItemNmbr = session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4013/txtVBAP-POSNR")

If Not InStr(SOItemNmbr.Text, "00") > 0 Then

' <execute some code>

End If

I also tried InStrRev and it just does not seem to get me.

Anyone have a solution on this?

BR Mattias

Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

Hi Mattias,

You can also try this:

Set SOItemNmbr = session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4013/txtVBAP-POSNR")

myText = SOItemNmbr.Text

'msgbox myText

If Not InStr(myText, "00") > 0 Then

' <execute some code>

End If

Regards,

ScriptMan

Former Member
0 Kudos

Hello,

Thanks for your efforts, it still didn't work though, strangely enough...

I used this to fix it instead;

Dim SOItemNmbr As Integer

SOItemNmbr = session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4013/txtVBAP-POSNR").Text

     If SOItemNmbr = itemVariable Then

     <execute some code>

     itemVariable = itemVariable + 100

     End If

This If statement is part of a loop, so in each loop the itemVariable will increase when the If returns true.

So problem solved!

Answers (0)