cancel
Showing results for 
Search instead for 
Did you mean: 

Problem solving elseif statement in SAP scripting

0 Kudos

Hi All,

Need to resolve a elseif statement - my problem is the code is straight away giving the false statement as result.

whereas my first condition is true: i.e. my date is 06/04/2019 (mm/dd/yy) so my result should be 06/29/2019 however i get my result as 09/24/2019

If CurrentDate ()>= "05/25/2019" AND CurrentDate ()<= "06/29/2019" THEN
session.findById("wnd[0]/usr/c_aaa-LOW").text = "09/30/2019"
session.findById("wnd[0]/usr/c_aaa-HIGH").text = "06/29/2019"
ElseIf CurrentDate ()>= "06/29/2019" AND CurrentDate ()<= "07/24/2019" THEN
session.findById("wnd[0]/usr/c_aaa-LOW").text = "09/30/2019"
session.findById("wnd[0]/usr/c_aaa-HIGH").text = "07/24/2019"
Else
session.findById("wnd[0]/usr/c_aaa-LOW").text = "09/30/2019"
session.findById("wnd[0]/usr/c_aaa-HIGH").text = "08/24/2019"
End if

Mahendran8888
Contributor
0 Kudos

what is the error message? false statement in where?

0 Kudos

while running the query I get the answer as 08/04/2019 whereas my answer should be 06/29/2019

0 Kudos

This is being performed in SAP ABAP program

Accepted Solutions (0)

Answers (2)

Answers (2)

Sandra_Rossi
Active Contributor
0 Kudos

By the way, it's 100% a Visual Basic question, so you would get an immediate answer if you post the question in a dedicated forum like stackoverflow for instance. The problem you have is a type mismatch. There is probably an implicit conversion between a Date type and a String type, which does not what you expect. You should better look for a conversion function to convert the date from String to Date type, and then you may compare two Date variables.

Sandra_Rossi
Active Contributor
0 Kudos

You must test dates as numbers, in format YYYYMMDD. Otherwise 01/2018 will be considered more recent than 02/2019.