cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dispatcher - Modification handler - Define IF-Statements

Private_Member_19084
Active Contributor
0 Kudos

Hi,

how can I define the following if-statement in SAP-Web Dispatcher modification handler, so that I can use a combination of OR and AND.

So the statement below is what I want, so I am looking for the "bracket" functionality, where I don't know how to realize this.

Kind regards

if %{HTTP_HOST} regimatch <host>.* [and]

( If %{REMOTE_ADDR} regimatch ^<ip1>.* [or]

If %{REMOTE_ADDR} regimatch ^<ip2>.* [or]

If %{REMOTE_ADDR} regimatch ^<ip3>.*  ) [and]

if %{PATH} regimatch "^/<name of page>"

SetHeader x-sap-webdisp-target-sid <ID> [break]

Accepted Solutions (1)

Accepted Solutions (1)

isaias_freitas
Advisor
Advisor
0 Kudos

Hello,

That would already be the correct feature.

See the following SAP Help page.

Linking Modification Actions to Conditions - Internet Communication Manager (ICM) - SAP NetWeaver - ...

Regards,

Isaías

Private_Member_19084
Active Contributor
0 Kudos

Hello Isaias,

and one thank you again for your help.

However, I still don't see exactly how I can solve it...

Do you mean with IF- and Else-Statements or rules?

isaias_freitas
Advisor
Advisor
0 Kudos

Hello,

Both are supported.

You can use the "[and]" and "[or]" operators as well as if/else blocks.

I now noticed that you would be using parenthesis at your rule definition.

This is not supported.

Regards,

Isaías

Private_Member_19084
Active Contributor
0 Kudos

So, I have to create for each IP-adress (in my case) an own complete rule-block, is that right?

Kind regards

isaias_freitas
Advisor
Advisor
0 Kudos

Hello,

Not necessarily.

I believe that something like the below should work (notice I changed the order of the conditions).

if %{HTTP_HOST} regimatch <host>.* [and]

   if %{PATH} regimatch "^/<name of page>" [or]

   if %{REMOTE_ADDR} regimatch ^<ip1>.* [or]

   if %{REMOTE_ADDR} regimatch ^<ip2>.* [or]

   if %{REMOTE_ADDR} regimatch ^<ip3>.*

SetHeader x-sap-webdisp-target-sid <ID> [break]

Regards,

Isaías

Private_Member_19084
Active Contributor
0 Kudos

Yes, but how is the relation.

I think the relation is like in abap.

if a=b and c=d or e=f endif

This means that IF is good if A=B and C=D or if only E=F (without considering a and c).

Right?

isaias_freitas
Advisor
Advisor
0 Kudos

Hello,

Now I realize there is a mistake in the example I sent. It should be:

if %{HTTP_HOST} regimatch <host>.* [and]

   if %{PATH} regimatch "^/<name of page>" [and]

   if %{REMOTE_ADDR} regimatch ^<ip1>.* [or]

   if %{REMOTE_ADDR} regimatch ^<ip2>.* [or]

   if %{REMOTE_ADDR} regimatch ^<ip3>.*

SetHeader x-sap-webdisp-target-sid <ID> [break]

As the SAP Help page I sent states, there "and" and "or" operators have equal precedence.

This means that the Web Dispatcher will not perform all "and's" before all "or's", for example.

The operations (and/or) will be applied from the first to the last (or from left to right), in the order they appear in your rule.

So, I believe that the Web Dispatcher will first test

     %{HTTP_HOST} regimatch <host>.*

If this is true, it will test the next condition (%{PATH} regimatch "^/<name of page>") and perform an "and" operation (both must be true).

It will then perform an "and" with the next condition, which is followed by an "or" operation...

I am not quite sure how it would proceed as of this point. You would need to test this.

Regards,

Isaías

Private_Member_19084
Active Contributor
0 Kudos

Hello Isaias,

thank you very much.
I did now create for each IP an own statement, to be sure that it is really safe.

As this is also a kind of security-setup I don't want to try a risk there.

Thank you very much for your help.

Kind regards

isaias_freitas
Advisor
Advisor
0 Kudos

You are welcome .

Answers (0)