cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional subtracting

Former Member
0 Kudos

Hi,

Can you tell me if the bellow is possible to be performed or there is no such functionality VBS & SAP?

And if yes how should looks like the script?

n = session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpFRML/ssubSUBSCR_2000:SAPLCOVG:2052/tblSAPLCOVGTCTRL_2052/txtAFVGD-PREIS[12,0]").value

m = sht.cells(i,1).Value

If n<=m than n=0,01

Else

n=n-m

End If

' and this result to be returned as value in

session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpFRML/ssubSUBSCR_2000:SAPLCOVG:2052/tblSAPLCOVGTCTRL_2052/txtAFVGD-PREIS[12,0]").text=n

BR,

Guerolito

Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

Hi Guerolito.

I would try it like this:

n = session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpFRML/ssubSUBSCR_2000:SAPLCOVG:2052/tblSAPLCOVGTCTRL_2052/txtAFVGD-PREIS[12,0]").text

m = sht.cells(i,1).Value

If n<=m than n=0,01

Else

n=n-m

End If

' and this result to be returned as value in

session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpFRML/ssubSUBSCR_2000:SAPLCOVG:2052/tblSAPLCOVGTCTRL_2052/txtAFVGD-PREIS[12,0]").text=cstr(n)

Regards,

ScriptMan

Former Member
0 Kudos

Hi Script Man,

Thank you for your reply!

I've tried the code but the following error occurred for If n<=m than n=0,01:

Error: Expected end of statement

Code: 800A0401

Do you have any idea what is wrong.

Thanks

Guerolito


script_man
Active Contributor
0 Kudos

Hi Guerolito,

I have not seen at all.

If n <= m then

n = 0,01

Else

n = n - m

End If

Regards,

ScriptMan

Former Member
0 Kudos

Hi,

It seems that the error was caused by "," in 0,01.

When I replaced 0,01 with 1 the problem disappeared.

Finally I decide to "use" 0,01 from excel file.

And the code bellow:

n = session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpFRML/ssubSUBSCR_2000:SAPLCOVG:2052/tblSAPLCOVGTCTRL_2052/txtAFVGD-PREIS[12,0]").text

m = sht.cells(2,2).Value

k = sht.cells(1,1).Value ' = 0,01

If n>m then n=n-m else n=k End if

session.findById("wnd[0]/usr/tabsTABSTRIP_2000/tabpFRML/ssubSUBSCR_2000:SAPLCOVG:2052/tblSAPLCOVGTCTRL_2052/txtAFVGD-PREIS[12,0]").text=cstr(n)

Regards,

Guerolito

Answers (0)