cancel
Showing results for 
Search instead for 
Did you mean: 

IMP: Need urgent help in queued UDFs

shweta_walaskar2
Contributor
0 Kudos

Hi,

We have a requirement:

<b>There could be 1 to N of ZSEG01 and for the ZSEG01 segment there could

be 0 to N of ZSEG20.

In Z_QTY should come the

ZSEG01-FLD1 minus the sum of all the corresponding ZSEG20-FLD1_1

Z_QTY(1) should only be created when at least

one ZSEG20 exists and then

in Z_QTY(1) should come the

sum of all the corresponding ZSEG20-FLD1_1</b>

I understand that this could be done using queued UDF .

can anyone please provide me the code for this so as to enable us to to satisfy this requirement.

Kindly reply at swalaska@in.ibm.com

This is quite urgent for us.

Thanks a lot in advance.

Best Regards,

Shweta

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Shweta,

As far as I getting it is that first u need to have a check for the ZSEG01 segment.If it exist then you need a counter to add how many times ZSEG20 is coming .Keep that in the global variable.After that you call the that global variable in the Z_QTY segment to populate the value.

If you find this helpful reward with points.

Thanks

Arijit

Former Member
0 Kudos

could you provide your source n target structure with an example of your requirment

shweta_walaskar2
Contributor
0 Kudos

Hi Arvind,

I have changed the segment names just to give an example of the requirement and cant give the exact structure names since it is specific to our project.

But I can generalise the requirement as:

Its an IDoc-to-File scenario where a segment acts as a header(occurence 1..N) and can have child elements associated to it (occurence 0..N)

we have to sum up a field in child elements corresponding to the header and then subtract the sum from a field in the header and then map this result to a field in File.

Kindly let me know if this is clear to you now.

Thanks!

Best Regards,

Shweta

Former Member
0 Kudos

Shweta,

Try this UDF

(add all fields from child node and subtract with header node based on context)

2 variables as input

First is the header field

Second the field from child node -- For this change the Context to the header

While creating UDF select "context"

String[] ret = new String[1];

int sum1=0;

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

{

sum1 = sum1 + Integer.parseInt(b<i>);

}

sum1 = sum1- Integer.parseInt(a[0]);

ret[0] = String.valueOf(sum1);

result.addValue(ret[0]);