Jarvis Pizzeria: ICS – XSLT parameters that are not found but are being used ???

Recently I came across an odd phenomenon in an ICS mapping that I want to share with the community via this blog. In short:

XSLT parameters that are not found but are being used

Let me explain: at VBCS we have a Business Object whose data can be accessed via a REST call. Here the “q” parameter can be used to filter on characteristics that are stored in the BO. In the maximum variant, the “q” parameter can contain 8 characteristics (see screenshot below).

We embed this REST call in ICS. The created integration has the 8 characteristics as parameters in the request. The first characteristic is mandatory, the others are optional. To request the same data as shown in the image above, the integration call looks like this:

The ICS integration looks like this.

Note: two BOs are queried in the integration. Only the first is important for the remainder of this blog..

What is striking is that there is a warning on the mapping “Map to getSOPKey”. The warning consists of the message:

Mapping for Target is not valid. Click here for more details. Target: q

If we look into the mapping, we see this message is related to the “q” QueryParameter.

The mapping consists of a string concatenation of eight parameters. These parameters are in the mapping above the “q” parameter on the right.

As an example we zoom in on one of these parameters (idea is the same for all parameters). If a value for “Service” has been received on the input side, the parameter varService is filled. If no value for “Service” comes in, the varService parameter remains empty.

If QueryParameters.Service =

  • filled → varService = ” and Service=’’
  • empty → varService = empty

Perhaps for the sake of clarity but for clarification purposes, I have also added the source view of the transformation used.

To be honest, I have no idea how to make this mapping in the ICS jet mapper. I made this in the XSLT source file and then imported it (with the on-premise tooling this was not a unusual approach, which is why I now apply it again).

The mapping is valid and works like expected. But we still have the warning. In my opinion an error in ICS.

So let’s see if another solution is possible. Do we get the warning because the parameter is on the right in the mapping? In that case, if we make sure they are on the left then the problem might be solved? We can do this by predefining the parameter. For this the step “Set_Q_Parts” has been added.

Now the parameters are on the left in the mapping and the warnings are gone.

The source view

But to achieve this, we must use a trick. In the first case, an XSLT mapping is used, and in XSLT it is possible to use the “IF” conditional test. But in a assign this test is not available. Here we have to solve it differently.

With the help of a trick it is possible to define an if-then-else in an assign step.

In pseudocode:

  • If <var1 has a value> then <return var2> else <return v3>

As an abstract XPath expression this can be translated to:

  • concat( substring(<var2>, 1, number (string-length(<var1>) > 0) * string-length(<var2>), substring(<var3>, 1, number(string-length(<var1>) = 0) * string-length(<var3>)

We will clarify this on the basis of a few examples

Example 1
  • <var1> = “”
  • <var2> = “FILLED”
  • <var3> = “EMPTY”

Then we get:

  • concat( substring(“FILLED”, 1, 0 > 0) * 6, substring(“EMPTY”, 1, 0 = 0) * 5 → “EMPTY”

And if <var1> = “VAR” then we get:

  • concat( substring(“FILLED”, 1, 3 > 0) * 6, substring(“LEEG”, 1, 3 = 0) * 5 → “FILLED”
Example 2:
  • <var1> = “”
  • <var2> = <var1>
  • <var3> = “”

Then we get:

  • concat( substring(“VAR”, 1, 0 > 0) * 3, substring(“”, 1, 0 = 0) * 0 → “”

And if <var1> = “VAR” then we get:

  • concat( substring(“VAR”, 1, 3 > 0) * 3, substring(“”, 1, 3 = 0) * 0 → “VAR”
Example 3:
  • <var1> = “”
  • <var2> = “FILLED with <var1>”
  • <var3> = “”

Then we get:

  • concat( substring(“FILLED with ”, 1, 0 > 0) * 12, substring(“”, 1, 0 = 0) * 0 → “”

And if <var1> = “VAR” then we get:

  • concat( substring(“FILLED with VAR”, 1, 3 > 0) * 12, substring(“”, 1, 3 = 0) * 0 → “FILLED with VAR”.

For further details I refer to a blog of Lucas Jellema from 2014.

If we apply this method for all parameters, we get the following result:

Because the value column is not completely readable here, we highlight one here. Again the varService. The value of this parameter is determined by the following statement:

concat(substring( concat(” and service='”, /nssrcmpr:execute/nssrcmpr:QueryParameters/nsmpr0:service, “‘”), 1, number(string-length(concat(” and service='”, /nssrcmpr:execute/nssrcmpr:QueryParameters/nsmpr0:service, “‘”)) > 15) * string-length(concat(” and service='”, /nssrcmpr:execute/nssrcmpr:QueryParameters/nsmpr0:service, “‘”))), “”)

Conclusion

Because ICS does not currently offer design time support for ‘creating‘ parameter in the XSLT mapper (on run time it works, but even then the warning is displayed). Is the addition of the assign activity a good working alternative for the mapper. This is very simple for a mandatory parameter (see varProductCode). For optional elements it quickly becomes a fairly complex statement in which a mistake is made quickly. So that is a disadvantage of this solution.

3 thoughts on “Jarvis Pizzeria: ICS – XSLT parameters that are not found but are being used ???

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s