Skip to main content

Document Keyword Replace Service in IBM Sterling B2B Integrator

In IBM Sterling B2B Integrator, there are situations where you want to replace a specific character in a document with another character. Document Keyword Replace service provides you the facility to  find and replace text in a document. You need to configure a Service and Business Process for this functionality in IBM Sterling B2B Integrator.  
Please do the following to create and configure the service :
1. Login to IBM Sterling Integrator 5.2.6.1.  Go to Deployment - Configuration. Create a New Service of type : Document Keyword Replace Service.
2. Enter Keyword start and end definition as $ as shown below. Click Next.
3. Check the Checkbox to enable the service for Business Processes as shown below :
4. Click Finish. The Service is now created.
5. Go to Business Processes - Manager. Create a Process Definition "DKR_regular". This is the process definition xml. 
Example:1

<process name="DKR_regular">
 <sequence>
  <operation name="DocKeyRepl">
    <participant name="DocKeyRepl"/>
    <output message="DocKeyReplInputMessage">
      <assign to="literal_bufferSize">104400</assign>
      <assign to="literal_mode">true</assign>
      <assign to="literal_readAheadSize">8194</assign>
      <assign to="keyword1">|</assign>
      <assign to="replace1">~</assign>
      <assign to="." from="*"></assign>
    </output>
    <input message="inmsg">
      <assign to="." from="*"></assign>
    </input>
  </operation>
 </sequence>
</process>
Please note, the literal_mode is true here. So, this will replace a single character in your document.  
6. Now, lets test the Business Process. Search for the Business Process "DKR_regular" and click on execution manager.
7. Click on execute button. Under specify input parameters, select the input document that contains text below :
3.2|0|3.2|0|3.2|0
8. Click go. The service should execute and show the status as Success.

 9. Click on DocumentInfo under the service DocKeyRepl. It should replace the character | with ~ as shown below:




Now, lets see how to replace multiple words with another words in a document.
Here is the process definition :
Example:2
<process name="DKR_Recursive_Ex">
  <sequence>
<operation name="DocKeyReplRecursive">
       <participant name="DocKeyReplRecursive"/>
       <output message="outmsg">
         <assign to="." from="*" />
         <assign to="keyword1">GLN</assign>
         <assign to="replace1">0008586666221</assign>      
         <assign to="keyword2">USERNAME</assign>
         <assign to="replace2" from="'user1'" />
         <assign to="keystart" from="'$('" />
         <assign to="keyend" from="'$)'" />
       </output>
       <input message="inmsg">
         <assign to="." from="*"/>
       </input>
     </operation>
</sequence>
</process>

Here is the input document : GLN: $(GLN$), UserName: $(USERNAME$)
When you execute the Business Process, the output will be :
GLN: 0008586666221, UserName: user1
Now, lets see how to recursively replace words with another words in a document.
In the service : DocKeywordReplace, specify start and end definition as $.
BP:
Example:3
<process name="DKR_String_RecurseText">
  <sequence>
    <operation name="Document Keyword Replace">
    <participant name="DocKeywordReplace"/>
      <output message="DocKeywordReplaceInputMessage">
        <assign to="literal_mode">false</assign>
        <assign to="mode">String</assign>
        <assign to="keyword1">|||</assign>
        <assign to="replace1">˜$@$</assign>
<assign to="keyword2">@</assign>
        <assign to="replace2">˜</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
  </sequence>
</process>
Input document:
3.2$|||$0$|$0$|$0$|||$3.2$|||$0$|||$3.2$|||$0
Output :
3.2˜˜0$|$0$|$0˜˜3.2˜˜0˜˜3.2˜˜0
Notice here, that ||| are replaced by ˜$@$. Again, $@$ are recursively replaced by ˜˜. The keyword symbols should be surrounded by $ start and end characters.

In this article, we saw how to replace a single character, multiple words in a document in IBM Sterling B2B Integrator. We also saw how to recursively replace a word with another word in a document.
Reference Links :  
https://www.ibm.com/support/knowledgecenter/en/SS3JSW_5.2.0/com.ibm.help.svcs_adpts_a_l.doc/Doc_Keyword_Replace_svc.html

Comments

Popular posts from this blog

Configuring Cluster in IBM Sterling B2B Integrator

In this article, I will show you how to configure a horizontal cluster in IBM Sterling B2B Integrator  with two nodes.   Cluster setup provides 24x7 high availability. Even if one of the node goes down, the other node can serve the requests. Cluster is needed to share the work load which is possible through load balancing in Web server. The nodes in the cluster share the same database and they ensure that all the nodes are consistent and show the same output to customer. There are two ways to install Sterling B2B Integrator :  a. Using GUI. b. Using Response files.  In this article, I have used response files for installing Sterling Integrator v5.2.6.1 with ifix level 5 . Starting from version 5.2.6, Sterling Integrator uses IBM Installation Manager (IIM) for installation.  In Node1, install sterling integrator in the same way as you do for a standalone system.  1. Set lang as en_US. export LANG=en_US 2. echo $LANG en_US 3. Install the base version 5.2.6.1. Get the insta