Created
June 25, 2014 02:32
-
-
Save js1972/a7c23eaf2a535e98eb5c to your computer and use it in GitHub Desktop.
Dynamic Configuration (ASMA) in a mapping UDF (User Defined Function).
Note that the getTransformationParameters() method is deprecated; but it is the only way it seems to work within an ICO (iflow). Note: You create UDF's in a function library with NWDS and not in the mapping directly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pi_test_purchaseorder_es; | |
import com.sap.aii.mapping.api.*; | |
import java.io.*; | |
import java.util.*; | |
import com.sap.aii.mappingtool.tf7.rt.*; | |
import com.sap.aii.mapping.lookup.*; | |
import java.lang.reflect.*; | |
import com.sap.ide.esr.tools.mapping.core.LibraryMethod; | |
import com.sap.ide.esr.tools.mapping.core.ExecutionType; | |
import com.sap.ide.esr.tools.mapping.core.Argument; | |
import com.sap.ide.esr.tools.mapping.core.Init; | |
import com.sap.ide.esr.tools.mapping.core.Cleanup; | |
public class DynamicConfigFunctions { | |
@LibraryMethod(title="setParameter", description="Set a Dynamic Configuration attribute", category="DynamicConfigFunctions", type=ExecutionType.SINGLE_VALUE) | |
public String setParameter ( | |
@Argument(title="") String namespace, | |
@Argument(title="") String key, | |
@Argument(title="") String value, | |
Container container) throws StreamTransformationException{ | |
DynamicConfiguration config = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); | |
DynamicConfigurationKey configKey = DynamicConfigurationKey.create(namespace, key); | |
config.put(configKey, value); | |
return value; | |
} | |
@Init(description="") | |
public void init ( | |
GlobalContainer container) throws StreamTransformationException{ | |
} | |
@Cleanup | |
public void cleanup ( | |
GlobalContainer container) throws StreamTransformationException{ | |
} | |
@LibraryMethod(title="getParameter", description="Get a Dynamic Configuration attribute", category="DynamicConfigFunctions", type=ExecutionType.SINGLE_VALUE) | |
public String getParameter ( | |
@Argument(title="") String namespace, | |
@Argument(title="") String key, | |
Container container) throws StreamTransformationException{ | |
DynamicConfiguration config = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); | |
DynamicConfigurationKey configKey = DynamicConfigurationKey.create(namespace, key); | |
return config.get(configKey); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment