cancel
Showing results for 
Search instead for 
Did you mean: 

IF statement in HTML ITS page

Former Member
0 Kudos

In my ITS page I have the following code:

`if (area == 3)`

<input type="image" name="~OkCode=GETPRODUCTS_RES" src="`mimeURL()`/tab_residential_on.gif" width="131" height="36" border=0 />

`else`

<input type="image" name="~OkCode=GETPRODUCTS_RES" src="`mimeURL()`/tab_residential_off.gif" width="131" height="36" border=0 />

`end`

This works fine but I want to remove the literal "3" and replace it with a variable g_res. So I change the code to read:

`if (area == g_res)`

This doesn't work as I think it's still checking the literal value of "g_res" not the value in the variable. I've checked several HTML code forums but this seems too simple a problem for them to solve. I'm a HTML novice so any pointers would be great.

Regards,

Gill

Accepted Solutions (1)

Accepted Solutions (1)

former_member185704
Contributor
0 Kudos

Hi,

Of course this is possible. The line

if (area == g_res)

should work as expected.

Maybe you have noticed that you are not writing plain HTML but mixing HTML and a scripting language. The scripting language you are using here is called HTMLBusiness. It's a language only available on SAP ITS, so you won't find anything about it in ordinary HTML forums. Check the <a href="http://help.sap.com/saphelp_47x200/helpdata/en/5f/1fb05e4aee11d189740000e8322d00/frameset.htm">HTML Business reference</a> for further information.

Best regards

Henning

Former Member
0 Kudos

Thanks, that link to SAP help was very interesting. But I still don't know why my code doesn't work.

- I've checked both variables (area and g_res) in my SAP program and they are defined the same.

- I've debugged through the code using ITS debugger and the variables have the same value but still the correct graphic isn't displayed.

Is there anything else I need to check?

former_member185704
Contributor
0 Kudos

Hi,

Try to put the following lines into the ITS template you are working on:


`area = 1;`
`g_res = 1;`
`if (area == g_res)`
<p>Values are the same</p>
`else`
<p>Values are different</p>
`end`

What is the output of the generated HTML-page?

- Henning

Message was edited by:

Henning Pingel

Former Member
0 Kudos

I get:

Values are the same

So what does this mean for my code? Are you saying the the values aren't being set correctly in SAP? I have debugged through using ITS debugger and the values are the same. Should I raise this as a call with SAP?

former_member185704
Contributor
0 Kudos

Hi,

So does g_res come from the R/3 via the context? If so, please read the section <a href="http://help.sap.com/saphelp_47x200/helpdata/en/5f/1fb0b84aee11d189740000e8322d00/frameset.htm">HTMLBusiness General Rules</a> of the HTML business reference.

Best regards

Henning

Former Member
0 Kudos

Thanks, it says in the help:

Only screen fields are visible to the ITS. Fields known only to the module pool are not visible.

So I need to make g_res a screen field or use the syntax FIELD SET or FIELD TRANSPORT to make it visible to the ITS.

Thanks so much for your help.

Answers (0)