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

PI mapping : Context change for text lines

Hi experts

I have an idoc with E1EDKT1 node having many E1EDKT2 nodes under it (these are text lines).

I have written a UDF to conatenate all the TDLINE fields in E1EDKT2 nodes into a single target field which is working fine.

I need to conditionally send the E1EDKT1 => E1EDKT2 node contents to target field.

However the E1EDKT2 node has 2 fields as below

TDLINE always present, populated with text lines

TDFORMAT present only on some nodes and populated with /

What I need to do is in the target field insert a new-line character before the TDLINE (text line) wherever there is \ in the TDFORMAT field.

Please can you suggest appropriate mapping since I am struggling with unequal contexts and hence not getting the desired results.

I am struggling with context mappings since I am new to PI

Idoc example

E1EDKT1 ABCD Send to destination target field.

E1EDKT2 TDLINE TDFORMAT

E1EDKT2 This is the first line of text /

E1EDKT2 This is the second line

E1EDKT2 This is the third line /

E1EDKT2 This is the fourth line

The desired result i want is : \nThis is the first line of textThis is the second line\nThis is the third lineThis is the fourth line

mapping.JPG (18.5 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jul 30, 2012 at 05:51 AM

    Hi

    Check this UDF:


    var1 and var2 will be inputs
    execution type: all values of a context

    String out ="";
    for(int i=0;i<var2.length;i++)
    {
    if(var1[i].equals("/"))
    {
    out = out+ "\n" + var2[i];
    }
    else
    {
    out =out+var2[i];
    }
    }
    result.addValue(out);

    Change the context of TDLINE to E1EDXT2


    Thanks
    Amit Srivastava


    Untitled.png (27.7 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 30, 2012 at 06:33 AM

    Hello,

    You can use this mapping:

    TDFORMAT -----------------------> concat: -> replaceString -> UDF -> Target

    TDLINE -> mapWithDefault -> / Constant: / -> /

    Constant: \n -> /

    Hope this helps,
    Mark

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 30, 2012 at 07:18 AM
    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.