Dear SCN Friends,

If you are someone who has been working with the PI dual stack architecture and has now moved to SAP Process Orchestration or you are starting to work with the Process Orchestration suite,this blog provides the basic understanding on how to create an udf with different execution types by comparing with Swing tool used in the Enterprise Service Repository (ESR) .The focus here will be on execution types and Input/Output variable types.


Either in Swing tool(ESR) UDF or UDF in NWDS we have below execution types and Input/Output variable types


Execution Tpes:


1)Single Values

2)All Values of a Context

3)All Values of Queue


Input/Output Variable Types:


1)Argument

2)Parameter

3)Result

I’m taking couple of examples to explain in brief.

Example1:Covers Execution type “Single Values”


UDF Creation for mapping in Swing tool(ESR) :

SingleValues.jpg

UDF Creation for mapping in NWDS:

To create the same UDF in NWDS we need to follow the below streps.

1)Add the below Import statements.

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;

2)To the existing default annotations (Init,Cleanup) , we need to add the annotation LibraryMethod which acts as an header for our main method .

@LibraryMethod(title=“insertDoubleQuotes”, description=“”, category= ReusableUserDefinedFunctions”, type=ExecutionType.SINGLE_VALUE)


3)Main Method creation –>This method contains main Logic


public String insertDoubleQuotes (


              @Argument(title=“”) String input,Container container) throws StreamTransformationException{


               //UDF logic Starts here


               // Assign double quotes to the String “doulbleQuote”

               String doubleQuote = “\””;

               // Create  variable “outString”

               String outString = “”;

               // Concate doubleQuote with input value and assign to outString

               outString = doubleQuote.concat(input).concat(doubleQuote);


               //UDF logic ends here

                                  return outString;


               }//close brace for insertDoubleQuotes method

Example2:Covers Execution type “All Values of a Context”

UDF Creation for mapping in Swing tool(ESR) :

AllVC.jpg



























UDF Creation for mapping in NWDS:


To create the same UDF in NWDS we need to follow the below streps.


Step1 willl remain the same.


2)


@LibraryMethod(title=” splitByDelimiter”, description=“”, category=” ReusableUserDefinedFunctions”, type=ExecutionType.ALL_VALUES_OF_CONTEXT)


3)Main Method creation –>This method contains main Logic


public void splitByDelimiter (

                      @Argument(title=””)  String Input[],

                      @Argument(title=””)  String delimiter[],

                           ResultList outFirstString,

                           ResultList outLastString,

                           Container container) throws StreamTransformationException{

              //UDF logic Starts here

                              String[] output;

                              output =Input[0].split(delimiter[0]);  // splitting the input by delimiter

                               if(output.length == 0)

                                {

                                outFirstString.addValue(“”);  // setting the empty string since the input value is empty

                                outLastString.addValue(“”); // setting the empty string since the input value is empty

                                }else  if(output.length >= 2)

                                {

                                outFirstString.addValue(output[0]); // setting the result for outFirstString

                                outLastString.addValue(output[1]); // setting the result for outLastString

                                }else{

                                outFirstString.addValue(output[0]); // setting the result for outFirstString

                                outLastString.addValue(“”); // setting the result for outLastString

                                        }

                                   //UDF logic ends here

                           }//close brace for splitByDelimiter method

For Execution type “All Values of Queue” ,only modification required when compared to “All Values of Context” type is ,we need to replace “ExecutionType.ALL_VALUES_OF_CONTEXT” statement with ExecutionType.ALL_VALUES_OF_QUEUEstatement .

Example3:Covers  Using Input variable type  “paramter” and  Java Type “Channel” as an Input to UDF:


Step1 willl remain the same. (I hope most of them would get a doubt that don’t we need to use Import statement for this ?  …Ans is ,”It is optional.The annotation is not required for arguments of type Channel and ResultList unless the user wants to provide a title to the argument.”)


Step2 willl remain the same.


@LibraryMethod(title=”getHike”, description=””, category=”GetHikeDet”, type=ExecutionType.SINGLE_VALUE)


3)Main Method creation –>This method contains main Logic


  public String getHike (  @Argument(title=””)  String grade,  @Argument(title=””)  String region,  Channel soapHikeDet,

  Container container)  throws StreamTransformationException{

               //UDF logic

                    return something;                        

}

Here is the reference Link for How to Create an UDF for Message Mapping in NWDS:BlogbyLee

Regards

Venkat

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply