Expand my Community achievements bar.

SOLVED

FormCalc IF-Statement doesnt work

Avatar

Former Community Member

Why does it don't work correctly? Does Formcalc cant handle 2 Statements? It doesnt handle the Datefiled correct...

 

if

( ( FORM_INTERFACE.DATE.formattedValue <= "01.01.2014" ) and

    ( FORM_INTERFACE.NUM eq "0271"
 
or FORM_INTERFACE.NUM eq "0272"
 
or FORM_INTERFACE.NUM eq "0413" ) )

then

$.presence ="visible"
else.
$.presence = "hidden"
endif,

1 Accepted Solution

Avatar

Correct answer by
Level 7

this works

if (($.rawValue <= "2014-01-01") and (TextField1.rawValue eq "0271" or TextField1.rawValue eq "0272" or TextField1.rawValue eq "0413"))

then TextField2.rawValue = "less and right"

else TextField2.rawValue = "more or wrong"

endif

Change the commands to whatever you need, but that if statement works just fine.

View solution in original post

4 Replies

Avatar

Level 7

I'm not sure what you mean by "it's not handling the datefield correctly."

Just looking at the code you provided, I would presume that it's not performing the logic the way you want. It should be evaulating "01.01.2014" like it would letters--one number at a time. (e.g., "flask" > "flash" because "k" > "h".) In the same way, "01.01.2013" < "01.01.2014" since all of the numbers are the same until the end, but "10.01.2013" > "01.01.2014" because "1" > "0". Is that what's happening? If so, format your date as yyyy.mm.dd so that you sort by year first. 2014 is after 2013 no matter what month or date, and "2014" > "2013" no matter what comes after it.

If that's not what you meant, please provide some more detail.

Avatar

Former Community Member

the field date is provided by an xml-interface from sap webdynpro.

In sap all date-field are internal written as : 'YYYYMMDD'. (i suppose this is the rawValue in Adobe).

On a screen the filed is displayed as: 'DD.MM.YYYY'. (formattedValue in Adobe ?).

In SAP Abap it would by no problem to check if the date is below 1.1.2014.

If date le '20140101'.

...

endif.

How i check this in FormCalc? I checked the FormCalc User Reference, but examples are hard to come by.

Also I must check 2 things togehter:

Date lt 1.1.2014 & number 271,272,413->hidden

Date ge 1.1.2014 & number 271,272,413->visible

Date lt 1.1.2014 & number NE 271,272,413->visible

Date ge 1.1.2014 & number NE 271,272,413->visible

Avatar

Correct answer by
Level 7

this works

if (($.rawValue <= "2014-01-01") and (TextField1.rawValue eq "0271" or TextField1.rawValue eq "0272" or TextField1.rawValue eq "0413"))

then TextField2.rawValue = "less and right"

else TextField2.rawValue = "more or wrong"

endif

Change the commands to whatever you need, but that if statement works just fine.

Avatar

Former Community Member

cool, seems to work :-)

rawValue < "2014-01-01" ->that was the solution...

Thanks very much.