Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple transformation condition not working

dave_playfair2
Explorer
0 Kudos

Hi all!

One of the condition checks in my simple transformation (deserialization) does not seem to want to work -- I've tried a hundred different things (no exaggeration) and it’s driving me crazy. It’s probably something simple – no pun intended – and I’m hoping someone will just see what I’m doing wrong and point out how dumb I am…

The code that is always passing the check, then causing a short dump with the statement “Check failed in condition” is as follows:

  <tt:cond check="$line.ccc=0">

      <CustomerChangedFields>               
        <ChangedCustomerDataFlag>

          <tt:value ref=".UNUSED"/>

        </ChangedCustomerDataFlag>

     </CustomerChangedFields>

</tt:cond>

In my testing, the value of $line.ccc (or the variable, or alternate root name I tried) is always “1” according to the debugger, but no matter what I try, the debugger steps into this condition despite the fact that it shouldn’t and then when it gets to the end element </tt:cond>, it short dumps.

I have a condition almost identical to this later on (referring to a different fieldname) in the simple transformation and it works fine, skipping over the elements that should not exist in the incoming XML. Both are inside a loop and both refer to $line.<fieldname>.

$line refers to the main ROOT I have defined.

For the purposes of testing, the elements within the condition above do exist (even though the idea is that they will not exist if the condition is not met), otherwise I would get a parsing error before the above noted dump error.

Among the things tried, I have changed the value of the condition from “0” to “1” or “2” or “3” and the debugger always goes into the condition as if it has passed the check.

Any help is much appreciated!!

1 ACCEPTED SOLUTION

dave_playfair2
Explorer
0 Kudos

SAP helped us out on this one and clarified that root conditional checks on deserialization do not work this way. One must use a variable and a cond-var check in order to get the desired results.

This is what I ended up coding in order to make this work:

First, created the variable:


<tt:variable name="CHANGE"/>

Second, assigned the value I was trying to check to this variable:

Instead of :  <tt:value ref="$line.ccc"/>
Used:           <tt:read type="C" var="CHANGE"/>

Third, I used switch logic instead of the condition check (although the variable condition check is used inside of this.)

Instead of:  <tt:cond check="$line.ccc=0">
Used :
  <tt:switch-var>                 
   <tt:cond-var check="CHANGE='0'"> 
      <CustomerChangedFields>   

      </CustomerChangedFields>

Forth, I ended the switch logic with a condition that encapsulates nothing, as no XML elements would be expected, and ended the switch logic:

Instead of: </tt:cond>
Used:              
   </tt:cond-var>
   <tt:cond-var check="CHANGE!='0'">
   </tt:cond-var>
</tt:switch-var>

------------

Aside from the fact that these values are no longer passed to ABAP, this works. SAP explained that the tt:cond on deserialization does not work the same way and after reviewing the documentation again, I saw the reference to this. Why the variable condition works differently, I have no idea, but this works now so all is good in the world. I hope this helps someone else struggling with a "Simple" Transformation program...

3 REPLIES 3

dave_playfair2
Explorer
0 Kudos

Or maybe there is another way I can simply skip over some elements that would not exist in some cases in the incoming XML data?

dave_playfair2
Explorer
0 Kudos

Anyone have any ideas?

dave_playfair2
Explorer
0 Kudos

SAP helped us out on this one and clarified that root conditional checks on deserialization do not work this way. One must use a variable and a cond-var check in order to get the desired results.

This is what I ended up coding in order to make this work:

First, created the variable:


<tt:variable name="CHANGE"/>

Second, assigned the value I was trying to check to this variable:

Instead of :  <tt:value ref="$line.ccc"/>
Used:           <tt:read type="C" var="CHANGE"/>

Third, I used switch logic instead of the condition check (although the variable condition check is used inside of this.)

Instead of:  <tt:cond check="$line.ccc=0">
Used :
  <tt:switch-var>                 
   <tt:cond-var check="CHANGE='0'"> 
      <CustomerChangedFields>   

      </CustomerChangedFields>

Forth, I ended the switch logic with a condition that encapsulates nothing, as no XML elements would be expected, and ended the switch logic:

Instead of: </tt:cond>
Used:              
   </tt:cond-var>
   <tt:cond-var check="CHANGE!='0'">
   </tt:cond-var>
</tt:switch-var>

------------

Aside from the fact that these values are no longer passed to ABAP, this works. SAP explained that the tt:cond on deserialization does not work the same way and after reviewing the documentation again, I saw the reference to this. Why the variable condition works differently, I have no idea, but this works now so all is good in the world. I hope this helps someone else struggling with a "Simple" Transformation program...