import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void concatContextValues(String[] Input, String[] Separator, Output output)
{
StringBuilder result = new StringBuilder()
String delimiter = Separator[0];
if (Input[0] != null){
result.append(Input[0])
}
for (int i=1; i<Input.size();i++)
{
if (Input[i] != null && Input[i].trim().length() > 0 && !output.isSuppress(Input[i]))
{
result.append(delimiter).append(Input[i])
}
}
result.toString()
output.addValue(result)
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void concatToOneQueue(String[] queue1, String[] queue2, String[] queue3, String[] queue4, String[] queue5, Output output) throws Exception{
if (queue1 != null && queue1.length > 0) {
for (int i = 0; i < queue1.length; i++) {
output.addValue(queue1[i])
}
} else {
output.addSuppress()
}
if (queue2 != null && queue2.length > 0) {
for (int i = 0; i < queue2.length; i++) {
output.addValue(queue2[i])
}
} else {
output.addSuppress()
}
if (queue3 != null && queue3.length > 0) {
for (int i = 0; i < queue3.length; i++) {
output.addValue(queue3[i])
}
} else {
output.addSuppress()
}
if (queue4 != null && queue4.length > 0) {
for (int i = 0; i < queue4.length; i++) {
output.addValue(queue4[i])
}
} else {
output.addSuppress()
}
if (queue5 != null && queue5.length > 0) {
for (int i = 0; i < queue5.length; i++) {
output.addValue(queue5[i])
}
} else {
output.addSuppress()
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void concatTwoQueuesToOne(String[] queue1, String[] queue2, Output output) throws Exception{
if (queue1 != null && queue1.length > 0) {
for (int i = 0; i < queue1.length; i++) {
output.addValue(queue1[i])
}
} else {
output.addSuppress()
}
output.addContextChange()
if (queue2 != null && queue2.length > 0) {
for (int i = 0; i < queue2.length; i++) {
output.addValue(queue2[i])
}
} else {
output.addSuppress()
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void createMultipleCopies(String[] contextValues, String[] copyCounts, Output output) throws Exception {
if (contextValues == null || contextValues.length == 0) {
throw new Exception("createMultipleCopies: contextValues is null or empty")
}
if (copyCounts == null || copyCounts.length != contextValues.length) {
throw new Exception("createMultipleCopies: copyCounts is null or has a different length than contextValues")
}
for (int i = 0; i < contextValues.length; i++) {
String value = contextValues[i]
if (value != null && value.trim().length() > 0) {
try {
int count = Integer.parseInt(copyCounts[i])
if (count > 0) {
for (int j = 0; j < count; j++) {
output.addValue(value)
}
} else {
output.addSuppress()
}
} catch (NumberFormatException ex) {
throw new Exception("UDF createMultipleCopies: " + copyCounts[i] + " is not a valid number")
}
} else {
output.addSuppress()
}
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void createMultipleContextCopies(String[] contextValues, String[] copyCounts, Output output) throws Exception{
if (copyCounts.length == 0) {
throw new Exception("UDF createMultipleContextCopies: "
+ " copyCounts has length 0")
}
int count = 0;
try {
count = Integer.parseInt(copyCounts[0])
} catch (Exception ex) {
throw new Exception("UDF createMultipleContextCopies: "
+ copyCounts[0] + " is not a number")
}
if (count > 0) {
for (int i = 0; i < contextValues.length; i++) {
output.addValue(contextValues[i])
}
for (int i = 1; i < count; i++) {
output.addContextChange();
for (int k = 0; k < contextValues.length; k++) {
output.addValue(contextValues[k])
}
}
} else {
for (int i = 0; i < contextValues.length; i++) {
output.addSuppress()
}
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void useOneContextAsMany(String[] contextValues, String[] secondContext, Output output) throws Exception{
if (contextValues != null && contextValues.length > 0) {
if (secondContext != null && secondContext.length > 0) {
for (int i = 0; i < secondContext.length - 1; i++) {
for (int j=0; j < contextValues.length; j++) {
output.addValue(contextValues[j])
}
output.addContextChange()
}
// the last context
for (int j=0; j < contextValues.length; j++) {
output.addValue(contextValues[j])
}
}
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void suppressMultipleContextValues(String[] contextValues, Output output) throws Exception{
List values = new ArrayList()
if (contextValues != null && contextValues.length > 0) {
for (int i = 0; i < contextValues.length; i++) {
if (output.isSuppress(contextValues[i])) {
output.addSuppress()
} else if (!values.contains(contextValues[i])) {
values.add(contextValues[i])
output.addValue(contextValues[i])
} else {
output.addSuppress()
}
}
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void deleteMultipleContextValues(String[] contextValues, Output output) throws Exception{
List values = new ArrayList()
if (contextValues != null && contextValues.length > 0) {
for (int i = 0; i < contextValues.length; i++) {
if (!values.contains(contextValues[i])) {
values.add(contextValues[i])
output.addValue(contextValues[i])
}
}
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.mapping.*;
def void simpleUseOneAsManyAndSplitByEachValue(String[] contextValues, String[] secondContext, Output output) throws Exception{
if (contextValues != null && contextValues.length > 0
&& secondContext != null && secondContext.length > 0) {
String value = null;
if (contextValues.length == 1) {
value = contextValues[0]
} else {
for (int i = 0; i < contextValues.length; i++) {
if (!output.isSuppress(contextValues[i])) {
value = contextValues[i]
break;
}
}
if (value == null) {
value = contextValues[0]
}
}
output.addValue(value)
for (int i = 1; i < secondContext.length; i++) {
output.addContextChange()
output.addValue(value)
}
}
}
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import com.sap.it.api.mapping.*;
def void rearrangeByKey(String[] arrangedSetOfKeys, String[] allKeys, String[] valuesToRearrange, Output output) throws Exception{
if (allKeys == null || valuesToRearrange == null
|| allKeys.length != valuesToRearrange.length) {
throw new Exception("UDF rearrangeByKey: "
+ "allKeys and valuesToRearrange have different lengths")
}
if (valuesToRearrange == null || valuesToRearrange.length == 0) {
for (int i = 0; i < arrangedSetOfKeys.length; i++) {
output.addSuppress()
}
} else {
if (arrangedSetOfKeys == null || arrangedSetOfKeys.length == 0) {
throw new Exception(
"UDF rearrangeByKey: there is no arrangedKeySet")
}
Set indexSet = new HashSet()
for (int i = 0; i < allKeys.length; i++) {
if (output.isSuppress(allKeys[i])
|| allKeys[i].trim().length() == 0) {
// keep suppress values
output.addSuppress()
} else {
// iterate over the arranged key set
for1 : for (int k = 0; k < arrangedSetOfKeys.length; k++) {
for (int m = 0; m < allKeys.length; m++) {
if (indexSet.contains(new Integer(m))) {
// value is already processed; ignore
continue;
}
if (output.isSuppress(allKeys[m])
|| allKeys[m].trim().length() == 0) {
continue;
}
if (arrangedSetOfKeys[k].equals(allKeys[m])) {
// value is not yet already processed;
// add to output list and keep in mind by
// putting onto a set
output.addValue(valuesToRearrange[m])
indexSet.add(Integer.valueOf(m + ""))
break for1;
}
}
}
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |