cancel
Showing results for 
Search instead for 
Did you mean: 

node has values in display queue but not getting created

Former Member
0 Kudos

Hi,

I am working on a file to idoc scenaro. I need to create a new idoc for every 2 records . We have edited the idoc to change the occurence. then wrote a UDF

var1 is the value of source element , and var2 is count

int counter = var2.length;

if(counter == 2)

for(int i =0; i<counter ;i++)

{

result.addValue(var1<i>);

if (((i+1) % 2) == 0 && i<(counter -1))

result.addContextChange();

}

I am getting the context change and new values in the queue for the node of the idoc. But, the node is not getting created for the same.

Can somebody help please.

Thanks,

Reyaz

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

I am getting the context change and new values in the queue for the node of the idoc. But, the node is not getting created for the same.

The occurrence of your root target node is 0..unbounded, therefore it will only take the values of the queue before the first context change. As a result, it is not creating the nodes after the first CC. Do what Sarvesh suggested and it will work.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Sarvesh/Mark,

My requirement is,

I have source file with n records. I need to create idoc for every 2 records in the source file. For 100 recs in i need 50 idocs to be generated.

As of now, while testing using above UDF, I am getting 2 idocs created for 4 recs in the file. it is creating only 2 idocs for more than 4 records in the file also. But, in queue I am getting all the source values with context change for every 2 records.

PLease suggest some solution .

Thanks&regrds,

Reyaz

Former Member
0 Kudos

Hi,

After UDF, use the functions 'CollapseContext' in sequence and it shuld solve your problem.

-Supriya.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Make the code look something like this


for(int a=0;a<Math.ceil((var2.length)/2.0);a++){
			result.addValue("NewIDoc"+a+"");
		}

It will create a context per 2 records (no context change is needed)

Hope this helps,

Mark

Former Member
0 Kudos

You can also try this udf..

Your mapping should look like this..

Source(set the context to top level if it is not) >UDF>IDOC

Here, var1 is the input source field.

int count = 0;
for(int i =0; i<var1.length ;i++)
{
count = count + 1;
if(count == 2)
{
result.addValue("");
count = 0;
}

Former Member
0 Kudos

Thanks to every one for your valuable replies.

Hi Supriya,

It worked after adding a collapse context at the end.

Thanks,

Reyaz

Former Member
0 Kudos

CollapseCotext removes all context and takes one value from each context. Same thing we were also tryin from very begining not to use context change. Anyway it is working now and that is the most important thing.

Answers (1)

Answers (1)

Former Member
0 Kudos

You don't need below code at all.. while creating n number of idocs context changes is not required. Try without context change and it should work.

if (((i+1) % 2) == 0 && i<(counter -1))

result.addContextChange();