on 06-09-2011 9:18 AM
Based on the "Developing Custom Action in in SAP MII 12.1" i encountered error while running the action block in BLS. In Link Editor I assign 2 values in Inputs and Output to a tracer. When I execute this BLS, I receive following error
[ERROR] [Tracer_0] Link ('Tracer_0.Message' [Assign] from "SimpleAction_0.Output") execution threw an exception. Exception: Invalid variable: SimpleAction_0.Output [Unknown variable: SimpleAction_0.Output
[ERROR] [Tracer_0] Action: Runtime threw an exception. Exception: [Invalid variable: SimpleAction_0.Output Unknown variable: SimpleAction_0.Output
The code is exactly like in the document
package customactions;
import com.sap.lhcommon.common.*; // Needed for the VariantDataTypes and
import com.sap.lhcommon.exceptions.DataConversionException;
// VariantData types.
import com.sap.xmii.bls.sdk.*; // This is the main SDK for custom actions.
/**
* This is a simple action construct used to show how to use some of the basic
* MII 12.1 Custom Action constructs.
*
*/
public class SimpleActions {
/**
* To ensure the parameters are always named the same, it is good practice to
* create a static final string with the parameters name. This also make it
* easy to use across actions.
*/
private static final String PARAM_OUTPUT = "Output";
/**
* Describes a simple action that adds two numbers together.
* @param instance This is the action instance. This is the main interface
* from the action code back into the transaction engine. Most
* users will only need to set their variables through this
* interface, though much more powerful operations are also
* available.
* @param in1 This is an input into the action. The type is detected by the
* transaction engine and automatically cast to the correct value.
* @param in2 This is a second input.
* @throws InvalidVariableException This exception is
*/
@Action(name = "AddTwoNumbers") // This annotation tells the engine that this
// is an action available to execute.
@Outputs(names = { PARAM_OUTPUT },
types = { VariantDataTypes.INTEGER }) // This annotation tells
// the engine that one
// integer output called
// 'Output' is going to be
// returned.
public static void addTwoNumbers(
IActionInstance instance, // Besides the basic types, the
// IActionInstance interface is the only
// other type allowed to be defined in
// parameter list of a custom action.
@Input(name = "Input1") int in1, // @Input annotations are used to
// indicate the user modifiable
// inputs to this action.
@Input(name = "Input2") int in2)
throws InvalidVariableException { // Exceptions can be thrown directly from
// the actions without causing critical
// execution failures. These exceptions
// will be caught and logged by the engine
// and will cause the Success flag to be
// set to false.
// The following code describes how to set an actions output.
try {
instance.setActionResult(PARAM_OUTPUT, in1 + in2);
} catch (DataConversionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
the catalog is
<ComponentCatalog>
<Category Name="Custom" Description="Custom">
<Component Type="Action" Name="AddTwoNumbers"
Description="" Label="SimpleAction"
ClassName="customactions.SimpleActions"
AssemblyName="SimpleActions.jar" Dependencies=""
HelpFileName="" />
</Category>
</ComponentCatalog>
Is there anything I might have done wrong?
To my point the problem is that first you define PARAM_OUTPUT variable as String:
private static final String PARAM_OUTPUT = "Output";
and later you try to assign an integer value to this variable:
instance.setActionResult(PARAM_OUTPUT, in1 + in2);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hargoe
and do you know why my icon does not show up? it just black.
@Action(name = "AddTwoNumbers", icon="icons/CustomAction.png")
i created a package called icons and in this package I have a .png file called CustomAction.png
I copied this CustomAction.png from another .jar and it works for that jar.
thanks
User | Count |
---|---|
12 | |
6 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.