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

Mapping problem

Hello,

I looking for the way to use with first constant in <TEXT_LINE>

Until the <ItemNum> changing.

Here is the source:

<QuotationTexts>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0001</TEXT_ID>

<TEXT_LINE>elad</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0006</TEXT_ID>

<TEXT_LINE>aaaaaa</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0005</TEXT_ID>

<TEXT_LINE>bbbbb</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0004</TEXT_ID>

<TEXT_LINE>ccccc</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0001</TEXT_ID>

<TEXT_LINE>peleg</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0006</TEXT_ID>

<TEXT_LINE>aaaaaa</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0005</TEXT_ID>

<TEXT_LINE>bbbbb</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0004</TEXT_ID>

<TEXT_LINE>ccccc</TEXT_LINE>

</QuotationText>

</QuotationTexts>

Here is what I'm expecting to accept to receive:

<QuotationTexts>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0001</TEXT_ID>

<TEXT_LINE>elad</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0006</TEXT_ID>

<TEXT_LINE> elad </TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0005</TEXT_ID>

<TEXT_LINE> elad </TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>10</ItemNum>

<TEXT_ID>0004</TEXT_ID>

<TEXT_LINE> elad </TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0001</TEXT_ID>

<TEXT_LINE>peleg</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0006</TEXT_ID>

<TEXT_LINE>peleg</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0005</TEXT_ID>

<TEXT_LINE>peleg</TEXT_LINE>

</QuotationText>

<QuotationText>

<ItemNum>20</ItemNum>

<TEXT_ID>0004</TEXT_ID>

<TEXT_LINE> peleg </TEXT_LINE>

</QuotationText>

</QuotationTexts>

Thank you very much.

Elad

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2008 at 05:07 AM

    Hi,

    Using following UDF you can achieve your requirement.

    Put execution type = Queue.

    1st parameter = TEXT_LINE tpye string.

    2nd parameter = ItemNum tpye string.

    Mapping

    TEXT_LINE --> RemoveContext -->
                                                  UDF --> SplitByValue(Each Value) --> TEXT_LINE
    ItemNum --> RemoveContext --> SplitByValue-->
                                  (Value Change)

    UDF

    int j;
    int cnt = 0;
    for(int i =0;i < TEXT_LINE.length;i++)
    {
    	for( j = i;j < ItemNum.length;j++)
    	{
    		if(cnt > 0)
    		{
    			j = j + 1;
    			cnt = 0;
    		}
    		if(ItemNum[j].equals(ResultList.CC))
    		{
    			cnt++;
    			i = j - 1;
    			break;
    		}
    		else
    		{
    			result.addValue(TEXT_LINE<i>);
    		}
    		if(j == (ItemNum.length - 1))
    		{
    			i = j;
    		}				
    	}
    }

    -Rohit.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 08, 2008 at 04:55 AM

    Hi Elad,

    I am providing one solution for your requirement.

    Just go through the following screen shots and do the mapping as i specified.

    http://picasaweb.google.com.au/jag.int/MappingSolution#

    I have created only one UDF i.e GenerateConstant rest are Standard functions only.

    Here is the code

    al.add(new String(a[0]));

    for(int j=0; j<a.length; j++)

    {

    if(a[j] == ResultList.CC)

    al.add(new String(a[j+1]));

    }

    for(int k=0;k < al.size();k++)

    {

    for(int m=0 ; m < (Integer.parseInt(b[k])); m++ )

    result.addValue((String)al.get(k));

    }

    Please let me know if you need further details about this mapping.

    Thanks,

    Jag

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2008 at 12:43 PM

    Hello,

    I checked again this scenario and I found a problem:

    The function work OK but forward with 2 numbers.

    For example:

    The <TEXT_LINE> of the <ItemNum> 150 in the source appear in correct way but in <ItemNum> 130 in the target.

    Elad

    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.