Tuesday, 27 September 2016

Command Line Adapter 2 to execute Java Code in Sterling Integrator

Using Command Line Adapter we can run a java program in a business process. We run programs, perl scripts, OS commands.
To work out this we must have JVM in the machine where Sterling integrator is installed.

To execute java program in Sterling Integrator first check the java program working or not through command with this line.

java -jar C:\Users\PDFToXML\dist\PDFToXML.jar C:\53_Map_Editor.pdf D:\data.xml
I am passing two parameters. One is input file and other one is output file.

Then write the bat file like this.
 pdftoxml.bat
java -jar C:\Users\miracle\Desktop\test\PDFToXML\dist\PDFToXML.jar %1 %2

Note: % for windows, $ for Linux

%1 is Input file %2 is Output file.

Configuring Command Line Adapter
In cmdLine option write like this
C:\Users\pdftoxml.bat $Input $Output



 Give input Name:(i.e input file path)
Give outputName(i.e Output file path)
 Make useInput and useOutput true saying that we are sending input and ouput file path.
The other requirement is we need to send primary document to this Command Line adapter. If we didn't give path for inputName (inputpath). Then Primary Document is the input for this service. Otherwise inputName(inputpath) is replaced with Primary Document.

BPML:



<process name="CommandLineAdapterSample">
  <operation name="Command Line 2 Adapter">
    <participant name="CommandLineAdapter2"/>
    <output message="CmdLine2InputMessage">
      <assign to="." from="*"></assign>
      <assign to="cmdLine">C:\Users\pdftoxml.bat $Input $Output</assign>
      <assign to="inputName">C:\53_Map_Editor.pdf</assign>
      <assign to="outputName">C:\data.xml</assign>
      <assign to="successValue">0</assign>
      <assign to="useInput">true</assign>
      <assign to="useOutput">true</assign>
    </output>
    <input message="inmsg">
      <assign to="." from="*"></assign>
    </input>
  </operation>

</process>

 It shows Success value 0 if this bp is success.


 If find any issues regarding please leave comment.



Wednesday, 7 September 2016

XPath function DOMToDoc

We can move the data from Process Data to External document using DOMToDoc function.
This function will execute the xpath query aganist process data and will store in the external document.
DOMToDoc signature:

DOMToDoc(xpath expression , [document_name], [standalone], [root_name])

In xpath expression give the xpath that you want to store into external document.

document_name This is the name to be assigned to the new workflow document. The default value is 'Document'

root_name is to wrap the data that is being extracted from process data to document.


DOMToDoc(/ProcessData/DocumentWorkflowId,'PrimaryDocument','NO','DocumentWorkFlowId')



Output:
 

Wednesday, 20 July 2016

Sterling integrator useful functions for Mapping

To perform count:


integer count_LIN;

count_LIN=count($GROUP_12[1][*]);//Group_12 is in the Group_1 So we have two indexes.
* for calulating count.

ntoa(count_LIN,$INPUT.#TEMP_mdTxLineCount);//converting integer to string

Concate two string(one is in date format YYYYMMDD another is in time format HHMMSS) and converting string format into date format:


mdate=#CREDAT+#CRETIM;
$INPUT.#TEMP_mdExtractDate = date("%Y%m%d%H%M%S",mdate);

NOTE: Be cautious with date format If you give data format incorrect it will give redundant results.

Compare first few characters with some string 

STRING[20] temp_variable;
temp_variable=left($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,2);//
it store first two characters in temp_variable
CERROR(100,temp_variable); 

LEFT:

The left function extracts a specified number of characters from the left side of a string variable or field and returns the result as a string.

STRING[20] temp_variable;
temp_variable=left($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,2);  //first 2 characters stored in temp_variable

RIGHT: 

The right function extracts a specified number of characters from the right side of a string variable or field.

 $INPUT.#temp_costHandling=right($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos); //stores the characters after * position


MID:

The mid character extracts the specified characters from the specified position in the string,either to the end of the string or up to the characters we specified.

1)IF $GROUP_7[1][group_7_cnt].#TDID:2="0003" & temp_variable="ED" THEN
BEGIN
2)dec_pos = strstr($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,"*");
3)i=len($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2);

ntoa(dec_pos,v_s_cerror);
//cerror(1001,v_s_cerror);

//var_datePromised=right($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos+1);
4)var_datePromised= mid($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,dec_pos+1,i-dec_pos);
$INPUT.#temp_datePromised=date("%Y%m%d",var_datePromised);
cerror(100,"sample",var_datePromised);
END

 For example we are getting ED*20110701 as input in step2 we can find the position of * i.e 2 because strstr is zero based function.
Third step returns length of the input i.e 10.
In 4th step it returns the characters from 3 to 8(10-2) i.e "20110701"


 

STRSTR:

The strstr function finds a substring inside a string. 

IF #TDID:2="0003" THEN
IF temp_variable="FC" THEN
BEGIN
dec_pos = strstr($E1TXTP8[1][group_7_cnt][E1TXTP8_cnt].#TDLINE:2,"*");  // finds * position
END