cancel
Showing results for 
Search instead for 
Did you mean: 

problem with queue and context change JAVA udf

Former Member
0 Kudos

Hi all,

MY scenorio is from source i get multiple instances and each instance i need to pass to different fields od target

in one source instance i may get multiple values which i have to create multple nodes under one target instance.

my source xml looka like below:

- <CustomFieldsSegment>

- <CustomFields Name="ForeignLanguageonPackaging">

<Value Qualifier="en">English</Value>

<Value Qualifier="fr">French</Value>

</CustomFields>

- <CustomFields Name="LayerHeight">

<Value>5.0</Value>

</CustomFields>

- <CustomFields Name="LayerHeightUOM">

<Value Qualifier="IN">Inches</Value>

</CustomFields>

</CustomFieldsSegment>

</TargetMarketData>

</ItemRegistration>

</Payload>

</ns:MT_TradeItemsExport>

in the above xml the first custom field has qualifier "en' and "fr"

i need to create 2 nodes under one target field.

example:

<AttrMany Name="ForeignLanguageonPackaging">

<Value ="en">en</Value>

<Value ="fr">fr</Value>

</AttrMany>

int eh source node <CustomFields Name="ForeignLanguageonPackaging"> may come in any matter .doesnt come always first

and i wrote udf like below:

public void queue(String[] a,String[] b,String[] c,ResultList result,Container container){

// write your code here

AbstractTrace traceObj = container.getTrace();

int baseArrayIndex = 99;

int ccCount = 0;

boolean isfound = false;

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

isfound = false;

if (a<i>.equals(c[0])) {

baseArrayIndex = i;

traceObj.addInfo("initial "+ i);

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

if (b[j].equals(ResultList.CC)) {

ccCount++;

} else {

if ( baseArrayIndex == ccCount ) {

result.addValue(b[j]);

traceObj.addInfo("result "+ b[j]);

isfound = true;

}

}

}

break;

}

}

if (!isfound)

result.addSuppress();

traceObj.addInfo("final result "+ result);

Please can anyone help me.

Regards,

jyothi

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jyothi,

Did you tried like: If Name equals to ForeignLanguageonPackaging then Qualifier --> splitbyvalue --> target.

Regards,

---Satish

Former Member
0 Kudos

Hi Satish,

i am passing three variables a,b,c

c is a constant which i am passing ForeignLanguageonPackaging

then in the java udf i am checking if Name equals to ForeignLanguageonPackaging .here name is "a" variable i am passing

Tthen then Qualifier --> splitbyvalue --> target but in the target i am getting one one value "er" but the second value is not showing in the target but when i display the queue on the output it is showing "en" and "fr"

i am not undustanding where exactly the problem is .

i have given name context as Custom field segments.

qualifier as Custom Fields.

Thanks,

Jyothi

Former Member
0 Kudos

Hi Jyothi,

Hope u have maintained the occurrence of your target field as 0..Unbounded.

Regards,

Rahul

Former Member
0 Kudos

Hi Rahul,

Yes i have maintained the occurrence of your target field as 0..Unbounded.

Please help me.

i am not undustanding where exactly the problem is whether in the UDF of some other only first value is displsyed int he target and the second value is not displaying.

but when i execute the code on eclipse it is showing both values.

Please help me .

Regards,

Jyothi

Former Member
0 Kudos

Hi all,

MY scenorio is from source i get multiple instances and each instance i need to pass to different fields od target

in one source instance i may get multiple values which i have to create multple nodes under one target instance.

my source xml looks like below:each ItemRegistration is one item at target

-<ItemRegistration>

- <CustomFieldsSegment>

- <CustomFields Name="ForeignLanguageonPackaging">

<Value Qualifier="en">English</Value>

<Value Qualifier="fr">French</Value>

</CustomFields>

- <CustomFields Name="LayerHeight">

<Value>5.0</Value>

</CustomFields>

- <CustomFields Name="LayerHeightUOM">

<Value Qualifier="IN">Inches</Value>

</CustomFields>

</CustomFieldsSegment>

</TargetMarketData>

</ItemRegistration>

-<ItemRegistration>

- <CustomFieldsSegment>

- <CustomFields Name="ForeignLanguageonPackaging">

<Value Qualifier="en">English</Value>

<Value Qualifier="fr">French</Value>

</CustomFields>

- <CustomFields Name="LayerHeight">

<Value>5.0</Value>

</CustomFields>

- <CustomFields Name="LayerHeightUOM">

<Value Qualifier="IN">Inches</Value>

</CustomFields>

</CustomFieldsSegment>

</TargetMarketData>

</ItemRegistration>

</Payload>

</ns:MT_TradeItemsExport>

in the above xml the first custom field has qualifier "en' and "fr"

i need to create 2 nodes under one target field.

example:

<AttrMany Name="ForeignLanguageonPackaging">

<Value ="en">en</Value>

<Value ="fr">fr</Value>

</AttrMany>

int eh source node <CustomFields Name="ForeignLanguageonPackaging"> may come in any matter .doesnt come always first

and i wrote udf like below:

public void queue(String] a,String[ b,String[] c,ResultList result,Container container){

// write your code here

AbstractTrace traceObj = container.getTrace();

int baseArrayIndex = 99;

int ccCount = 0;

boolean isfound = false;

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

isfound = false;

if (a.equals(c[0])) {

baseArrayIndex = i;

traceObj.addInfo("initial "+ i);

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

if (b[j].equals(ResultList.CC)) {

ccCount++;

} else {

if ( baseArrayIndex == ccCount ) {

result.addValue(b[j]);

traceObj.addInfo("result "+ b[j]);

isfound = true;

}

}

}

}

}

if (!isfound)

result.addSuppress();

traceObj.addInfo("final result "+ result);

if i have only one item at the source it is working but when 2items are comming from the source my udf is not working.

can anyone help me if you have faced the similar problem or who is fimilar like this kind.

Regards,

jyothi

Edited by: jyothi vonteddu on Oct 21, 2009 9:14 PM

Edited by: jyothi vonteddu on Oct 21, 2009 9:22 PM