cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping problem

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (2)

Answers (2)

Former Member
0 Kudos

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

SudhirT
Active Contributor
0 Kudos

Seems problem related to the contexts, use proper context function required, check in display queue of each step in the mapping if it comes in output of UDF then you need to add context change in UDF itself.

Thanks!

Former Member
0 Kudos

Hello,

I found here 2 options to solve my problem but they both not working:

1. Jag solution bring me the value __cC1_ after the second item.

2. Rohit solution work but bring the text line 2 item line before the time that need to be.

I tried all the good recommendations from the tread without succeed.

I'll be happy to hear more options

Elad

Former Member
0 Kudos

Hi Elad,

I have create a mapping using the SplitByValue and a small UDF to achieve the desired output structure.

I have uploaded the UDF as well as the screen shot of output generated in MM.

Here is the linke : http://picasaweb.google.com/pooja13pandey/SDNSAPComForum#slideshow

Code :

//write your code here
 int j=0;
for(int i=0; i<item_num.length;i++)
       if (item_num<i>.equals(ResultList.CC))
  	j=i;
       else
	  result.addValue(text_line[j]);

Let me know if you still face issue in creating the desired output.

Thanks,

Pooja

Former Member
0 Kudos

HI Elad,

Were you able to resolve your mapping issue ?

Thanks,

Pooja

former_member214364
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hello Jag,

Thank you very very mach about your help.

I tried to implement this scenario and I received this error:

13:46:31 Start of test

Source code has syntax error:

L:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapea96fcb1c51d11ddae87001635c5b25f/source/com/sap/xi/tf/_PLM_Out_MM_.java:476: cannot resolve symbol

symbol : variable aj

location: class com.sap.xi.tf._PLM_Out_MM_

al.add(new String(aj+1));

^

1 error

Source code has syntax error:

L:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapea96fcb1c51d11ddae87001635c5b25f/source/com/sap/xi/tf/_PLM_Out_MM_.java:476: cannot resolve symbol

symbol : variable aj

location: class com.sap.xi.tf._PLM_Out_MM_

al.add(new String(aj+1));

^

1 error

13:46:33 End of test

Elad

SudhirT
Active Contributor
0 Kudos

Hi Elad,

This is editor related problem you need to use

a[j]

instead of aj wherever it is used.

Thanks!

Former Member
0 Kudos

Hello,

u2022 Now the first <TEXT_LINE> is OK but all the other <TEXT_LINE> came with the value: " __cC_1 "

Elad

former_member214364
Active Contributor
0 Kudos

Hi Elad,

Have you used removeContexts node function between count and UDF(2nd input) as i shown in pic1?

You have to use this if not.

Enhancement: You can delete removeContexts node function which i used between mapWithDefault and formatByExample

Cheers,

Jag

Former Member
0 Kudos

Hi Elad

change the Cache type for your UDF to Queue and give it a try,

Thanks

Gaurav