cancel
Showing results for 
Search instead for 
Did you mean: 

UDF help required

Former Member
0 Kudos

Hi experts,

Can you please help in UDF where I have two inputs, Field 1 and Field 2 each context may have values from 1 to many. I want output of Field 2 based on removing or suppressing how many values are there in Field1 context.

i.e;

attached in screenshot where field 1 i have only one value in context and field 2 i have three values so i want to eliminate or suppress first value in field 2

since the field 1 is having one value.

If field 1 is having two values in a context and field 2 has three values in a context then i want output as field 2 with last third value only.

Accepted Solutions (1)

Accepted Solutions (1)

rhviana
Active Contributor
0 Kudos

Hi Prasad,

Did you check the node function OneAsMany ?

useOneAsMany (SAP Library - Partner Connectivity Kit)

Kind regards,

Former Member
0 Kudos

HI Ricardo,

Use One as Many wont work for this scenario.

My requirement is as below:

Example 1:

Field 1                     Field 2                      Output

  1                              1                              2

-------                          2                              3

                                  3                           ----------

                              -------------

Example 2:

Field 1                     Field 2                      Output

  1                              1                              3

  2                              2                              4

---------                         3                          ------------

                                  4                         

                              -------------

Hope this clarifies.

Regards,

Prasad K

rhviana
Active Contributor
0 Kudos

Hi Prasad.

Sorry for that.

But I dont follow you Prasad.

Input

<Field1>

  <Value>1</Value>

</Field1>

<Field2>

  <Value>1</Value>

  <Value>2</Value>

  <Value>3</Value>

</Field2>

Output must be:

<Field>

  <Value>2</Value>

  <Value>3</Value>

</Field>

Thats it, you need miss always the first value of xml file ?

Kind regards,

Former Member
0 Kudos

Correct.. not always first value it depends on how many values are there in Field 1 i.e;

Input

<Field1>

  <Value>1</Value>

  <Value>2</Value>

</Field1>

<Field2>

  <Value>1</Value>

  <Value>2</Value>

  <Value>3</Value>

</Field2>

Output must be:

<Field>

   <Value>3</Value>

</Field>

Regards,

Prasad K

rhviana
Active Contributor
0 Kudos

But what is the criterion (If the value repeat into field 1 and field 2 ?) ?

How much values you need to check to generate output structure ?

Kind regards,

Former Member
0 Kudos

Hello,

Try this UDF:

Input : var1,var2

Execution type: all values of a context

int start  = var1.length;

for(int i=start;i<var2.length;i++)

{

result.addValue(var2[i]);

}

BTW, what if at some instances second input queue has lesser number of values than first input queue?

Thanks

Amit Srivastava

rhviana
Active Contributor
0 Kudos

Hi Prasad,

Check the collapseContexts node function:

SAPTechnical.COM - Implementation of Node functions

I hope help this time.

Kind regards,

Former Member
0 Kudos

Hey Amit,

Thanks for your quick reply always

regarding your question ideally such case shouldn't come is what i feel but any how i will check and come back.

Regards,

Prasad K

Answers (1)

Answers (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can also do simple java mapping for this. Create one list for the field1 and second list for the field2.  The third ouput list will do for loop to read the first list and check each content in the second list using another for loop and if matches don't add in the third list and if no match found then add it .

Basically you create java.list

List (Java Platform SE 7 )

rhviana
Active Contributor
0 Kudos

I´m agree with you Baskar.

Now the most of time I use javamapping, graphical mapping it´s limited for some situation or hard to create a logical.

Regards,