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.
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">
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.
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
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>
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
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.
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
Post a Comment