Skip to Content
author's profile photo Former Member
Former Member

Mapping problem with filter condition

I have a souce structure like this:

<master node A>
<node A>
<element A>xxxxxxxxxxx</element A>
</node A>
</master node A>

And a target structure like this:

<master node B>
<node B>
<element B> </element B>
</node B>
</master node B>

Then I have a filed mapping

<element A> -> substring(0,8) -> <element B>

There are two possible types of content in <element B>, a string with a length of 10 or an empty string. That’s why I have added a condition to the mapping of <node A> to <note B>.

IfWithoutElse (<element A> != "" ) <node A> -> <node B>

<element A> has the context of the <master node>.


In general this condition works. If I look in the queues (graphical mapping tool) I can see, that I get a "SUPRESS" for <node B> if <element A> is an empty string. But nevertheless I get a mapping error from the substring function. I can't understand this. Why PI tries to map the child element although the parent node won't be mapped. Where is my fault?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2012 at 12:43 PM

    Okay, I've found a solution by my own. I've created a second mapping from my source structure to my source structure. In this mapping I map all the fileds 1:1 but I use my filter rule to find the records where all fields are empty. In the second step I map from the source structure to the target structure using all of my normal field mappings.

    Nevertheless thank you.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 30, 2012 at 08:14 AM

    Hi Gil,

    check out standard text function "length" and ask if length is not equal 0.

    Regards,

    Udo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2012 at 08:15 AM

    Hi Ritter,

    Please find the below mapping it works

    Also change your <elementA> context to <node A> and map it to target field.

    Regards,

    $HRI


    test_image.png (22.4 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 30, 2012 at 08:21 AM

    Hi,

    In ur mapping use Removecontext

    IfWithoutElse (<element A> != "" ) <node A> ->RemoveContext-> <node B>

    IfWithoutElse (<element A> != "" ) <elementA> ->Substring(0,8) -> <elementB>

    Context of elementA will be of MasterNodeA

    Thanks

    Amit Srivastava

    Message was edited by: Amit Srivastava

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2012 at 08:30 AM

    Yes of course, I know this.

    My structure is a lot more complex as I've posted it here. I have to check whether
    a field has an empty context many times. That’s terrible.

    Therefore my main question is: Why PI tries to map a child element although the parent node
    won't be mapped.

    @Amit That doesn't work I still get the following error:

    Runtime exception during processing target field mapping /ns0:<master node B>/<node B>[2]/<element B>(suppressed field). The message is:
    Exception:[java.lang.StringIndexOutOfBoundsException] in class com.sap.aii.mappingtool.flib3.TextFunctions method substring[,com.sap.aii.mappingtool.tf3.rt.Context@44ab44ab]

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2012 at 09:52 AM

    I believe you got me wrong. Of course all this works. I know this already. But as I mentioned earlier I have <element A> not only one time. And I have <element A1>, <element A2>, <element A3>, <element A4> ….

    I have the following situation. Either I have a record where all elements are filled with proper values or I have a record where (nearly) all elements are empty. My field mappings are partially quite complex. I want avoid making a check whether an element is empty in each field mapping. So my hope was that I can filter these records. Filtering works but I get still these mapping errors.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.