
Understanding Groovy Scripting for SAP Integration Suite – Part 1
import com.sap.it.api.mapping.*;
def void CreateIfExistsAndHasValue(String[] Input, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
output.addValue("")
}
else
{
output.addSuppress()
}
}
}
import com.sap.it.api.mapping.*;
def void CreateIfExistsAndHasOneOfSuchValue(String[] Input, String[] Qualifier, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
if(Qualifier[0] != null && Qualifier[0].trim().length() > 0)
{
String[] str = Qualifier[0].split(';')
int count=0
for (String value : str)
{
if(Input[i]==value)
{
count++
}
}
if(count>0)
{
output.addValue("") //create node if the input value matches the given qualifiers
}
else
{
output.addSuppress() //suppress if input value doesn't match given qualifiers
}
}
else
{
output.addSuppress() //suppress if no qualifier is available
}
}
else
{
output.addSuppress() //suppress if no input is available
}
}
}
import com.sap.it.api.mapping.*;
def void PassIfExistsAndHasValue(String[] Input, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
output.addValue(Input[i])
}
else
{
output.addSuppress()
}
}
}
import com.sap.it.api.mapping.*;
def void PassIfExistsAndHasOneOfSuchValue(String[] Input, String[] Qualifier, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
if(Qualifier[0] != null && Qualifier[0].trim().length() > 0)
{
String[] str = Qualifier[0].split(';')
int count=0
for (String value : str)
{
if(Input[i]==value)
{
count++
}
}
if(count>0)
{
output.addValue(Input[i]) //return input value to output if true
}
else
{
output.addSuppress() //suppress if input value doesn't match given qualifiers
}
}
else
{
output.addSuppress() //suppress if no qualifier is available
}
}
else
{
output.addSuppress() //suppress if no input is available
}
}
}
import com.sap.it.api.mapping.*;
def void ExistsAndHasValue(String[] Input, Output output)
{
for(int i=0; i<Input.size(); i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
output.addValue("true")
}
else
{
output.addValue("false")
}
}
}
import com.sap.it.api.mapping.*;
//Qualifiers need to be separated by semi-colon (;)
def void ExistsAndHasOneOfSuchValue(String[] Input, String[] Qualifier, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
if(Qualifier[0] != null && Qualifier[0].trim().length() > 0)
{
String[] str = Qualifier[0].split(';')
int count=0
for (String value : str)
{
if(Input[i]==value)
{
count++
}
}
if(count>0)
{
output.addValue(true) //return true to output if input value matches given qualifiers
}
else
{
output.addValue(false) //return false if input value doesn't match given qualifiers
}
}
else
{
output.addValue(false) //return false if no qualifier is available
}
}
else
{
output.addValue(false) //return false if no input is available
}
}
}
import com.sap.it.api.mapping.*;
def void SimpleUseOneAsMany(String[] Input1, String[] Input2, Output output)
{
for (int i=0; i<Input1.size();i++)
{
if (Input1[i] != null && Input1[i].trim().length() > 0 && !output.isSuppress(Input1[i]))
{
for (int j=0; j<Input2.size();j++)
{
if (Input2[j] != null && Input2[j].trim().length() > 0 && !output.isSuppress(Input2[j]))
{
output.addValue(Input1[i])
}
else
{
output.addSuppress() //suppress if 2nd input is not available
}
}
}
else
{
output.addSuppress() //suppress if 1st input is not available
}
}
}
import com.sap.it.api.mapping.*;
def void DeleteSuppress(String[] Input, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && !output.isSuppress(Input[i]))
{
output.addValue(Input[i])
}
else
{
output.addValue(null)
}
}
}
import com.sap.it.api.mapping.*;
def void GetFirstContextValue(String[] Input, Output output)
{
int count=0
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
output.addValue(Input[i])
count++
break;
}
}
if (count==0)
{
output.addSuppress()
}
}
import com.sap.it.api.mapping.*;
def void ContextHasOneOfSuchValues(String[] Input, String[] Qualifier, Output output)
{
int count=0
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
if(Qualifier[0] != null && Qualifier[0].trim().length() > 0)
{
String[] str = Qualifier[0].split(';')
for (String value : str)
{
if(Input[i]==value)
{
count++
}
}
}
}
}
if(count>0)
{
output.addValue(true) //return true to output if input value matches given qualifiers
}
else
{
output.addValue(false) //return false if input value doesn't match given qualifiers
}
}
import com.sap.it.api.mapping.*;
def void AssignValueByCondition(String[] Input, String[] Condition, String[] PassValue, Output output)
{
for (int i=0; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
if(Condition[0] != null && Condition[0].trim().length() > 0)
{
String[] str = Condition[0].split(';')
int count=0
for (String iteration : str)
{
if(Input[i]==iteration)
{
count++
}
}
if(count>0)
{
output.addValue(PassValue[i]) //return PassValue to output if input value matches condition
}
else
{
output.addSuppress() //suppress if input value doesn't match given condition
}
}
else
{
output.addSuppress() //suppress if no condition is available
}
}
else
{
output.addSuppress() //suppress if no input is available
}
}
}
import com.sap.it.api.mapping.*;
def void GetValueByIndex(String[] Input, int[] Index, Output output)
{
int indexcount = Index[0]
if (Input[indexcount] != null && Input[indexcount].trim().length() > 0 && !output.isSuppress(Input[indexcount]))
{
output.addValue(Input[indexcount])
}
else
{
output.addSuppress() //suppress output if no input is available
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |