Wiki

Scale Your Enterprise

User Tools

Site Tools


bw:looping_tool

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bw:looping_tool [2019/01/03 05:28]
_deletedUser4_ created
bw:looping_tool [2022/08/02 10:57] (current)
akoehler
Line 1: Line 1:
-====== Introduction ======+====== Introduction (Looping Tool) ======
  
-This document describes the use of the “looping” tool in Bizweaver+This page describes the use of the “looping” tool in Bizweaver.
- +
-====== Audience ====== +
- +
-This document is intended for developers of Bizweaver workflows. +
- +
-====== Related Documents ====== +
- +
-The following documents contain additional information that may be helpful with the development of Bizweaver workflows. +
- +
-  * Bizweaver – Configuration Guide +
-  * [[bw:using_variables|Using Variables]] +
-  * [[bw:sql_command_tool|SQL Command Tool]] +
-  * [[bw:file_operations_tool|File Operations Tools]] +
- +
-====== General Workflow Rules ====== +
- +
-  - Each workflow step must have a unique name. +
-    - The application will assign a default name, but we recommend that you change the name to something that helps you understand the purpose of the step. +
-    - The name cannot have spaces or special characters other than and underscore (_).+
  
 ====== The Looping Tool ====== ====== The Looping Tool ======
Line 40: Line 21:
     - If no unprocessed records are found, the loop ends, and the processing continues to the next step in the workflow.     - If no unprocessed records are found, the loop ends, and the processing continues to the next step in the workflow.
  
 +<WRAP center round important>
 **In the following examples, the name of the Loop and LoopEnd are similar. However, the names of the looping steps are used only to assist the developer. The only requirements are that for each “Loop” step there must be a corresponding “LoopEnd” step, and that the step name is unique.** **In the following examples, the name of the Loop and LoopEnd are similar. However, the names of the looping steps are used only to assist the developer. The only requirements are that for each “Loop” step there must be a corresponding “LoopEnd” step, and that the step name is unique.**
 +</WRAP>
 +
  
 ====== Simple Example ====== ====== Simple Example ======
Line 46: Line 30:
 This example illustrates the use of looping to process a set of records from an SQL Command: Reader step. In this case, we are using Customer Contact Persons in SAP Business One. We will send an email to each contact. This example illustrates the use of looping to process a set of records from an SQL Command: Reader step. In this case, we are using Customer Contact Persons in SAP Business One. We will send an email to each contact.
  
-{{:bw:loopimage1.png?576x106}}+{{  :bw:loopimage1.png?576x106  }}
  
-<HTML><ol start="2" style="list-style-type: decimal;"></HTML> +  - The first step is to create a list of contacts. In this example, we use the internal code assigned to each contact by SAP Business One. From this we get a list of code values. \\ {{  :bw:loopimage2.png?384x181  }} 
-<HTML><li></HTML><HTML><p></HTML>The first step is to create a list of contacts. In this example, we use the internal code assigned to each contact by SAP Business One. From this we get a list of code values.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML>+  - A loop is started using the list from step 1 as input. (Linked Object). \\ {{  :bw:loopimage3.png?384x135  }} 
 +  - A second SQL Command: Reader step is used to get the details for the first contact record. 
 +      - The code from the list is used to get the specific information for the contact. \\ {{  :bw:loopimage4.png?384x194  }} 
 +  - The e-mail is created. 
 +      - The recipient’s e-mail address is taken from the details in step 3. \\ {{  :bw:loopimage5.png?384x127  }} 
 +  - The application now checks to see if there are any additional records in the list passed into the loop that have not been processed. 
 +      - If an unprocessed record is found, steps 3 and 4 are executed for the next record. 
 +      - If no records remain to be processed, the loop ends, and the process continues to the next workflow step.
  
-{{:bw:loopimage2.png?384x181}}+<WRAP center round info> 
 +In this example, the list is created for a single valueThe details needed for processing are then retrieved for each record inside the loop. Another approach is to get all the information needed in the first SQL step. The second SQL step inside the loop is then not required since all the information is available. There are no specific rules about which approach to use. **However**, attempting to feeding very large blocks of data into the loop can potentially cause failure of the workflow. 
 +</WRAP>
  
-<HTML><ol start="3" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>A loop is started using the list from step 1 as input. (Linked Object).<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> 
- 
-{{:bw:loopimage3.png?384x135}} 
- 
-<HTML><ol start="4" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>A second SQL Command: Reader step is used to get the details for the first contact record.<HTML></p></HTML> 
-<HTML><ol start="3" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>The code from the list is used to get the specific information for the contact.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> 
-<HTML></li></HTML><HTML></ol></HTML> 
- 
-{{:bw:loopimage4.png?384x194}} 
- 
-<HTML><ol start="5" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>The e-mail is created.<HTML></p></HTML> 
-<HTML><ol start="4" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>The recipient’s e-mail address is taken from the details in step 3.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> 
-<HTML></li></HTML><HTML></ol></HTML> 
- 
-{{:bw:loopimage5.png?384x127}} 
- 
-<HTML><ol start="6" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>The application now checks to see if there are any additional records in the list passed into the loop that have not been processed.<HTML></p></HTML> 
-<HTML><ol start="5" style="list-style-type: decimal;"></HTML> 
-<HTML><li></HTML><HTML><p></HTML>If an unprocessed record is found, steps 3 and 4 are executed for the next record.<HTML></p></HTML><HTML></li></HTML> 
-<HTML><li></HTML><HTML><p></HTML>If no records remain to be processed, the loop ends, and the process continues to the next workflow step.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> 
-<HTML></li></HTML><HTML></ol></HTML> 
- 
-In this example, the list is created for a single value. The details needed for processing are then retrieved for each record inside the loop. Another approach is to get all the information needed in the first SQL step. The second SQL step inside the loop is then not required since all the information is available. There are no specific rules about which approach to use. **However**, attempting to feeding very large blocks of data into the loop can potentially cause failure of the workflow. 
  
 ====== Loop-Within-Loop Example ====== ====== Loop-Within-Loop Example ======
Line 87: Line 51:
 This example illustrates a more complicated set of looping cycles; a loop within a loop. The first loop processes a list of files from a File Operations: Get step. The second loop, which is inside the first loop, processes the records in each file and posts them into an SQL table. This type of loop processing is very common. This example illustrates a more complicated set of looping cycles; a loop within a loop. The first loop processes a list of files from a File Operations: Get step. The second loop, which is inside the first loop, processes the records in each file and posts them into an SQL table. This type of loop processing is very common.
  
-{{:bw:loopimage6.png?576x126}}+{{  :bw:loopimage6.png?576x126  }}
  
-  - The first step is to create a “virtual” list of files to be processed. This is done using **File Operations: Get.** In this sample, we are processing any .csv file starting with “test.” +  - The first step is to create a “virtual” list of files to be processed. This is done using **File Operations: Get.** In this sample, we are processing any .csv file starting with “test.” \\ {{  :bw:loopimage7.png?384x172  }} 
- +  - The initial loop processes the list of files created in step 1. 
-{{:bw:loopimage7.png?384x172}} +      - The input is selected from the “Linked Object” drop-down list. 
- +      If a file is found, the workflow proceeds to the next step (3). 
-<HTML><ol start="2" style="list-style-type: decimal;"></HTML> +      If no files are found to process, the workflow proceeds to the end of the loop (step 7) and, in this case, ends. \\ {{  :bw:loopimage8.png?384x136  }} 
-<HTML><li></HTML><HTML><p></HTML>The initial loop processes the list of files created in step 1.<HTML></p></HTML> +  - A File Reader step processes the file presented from step 2. 
-<HTML><ol style="list-style-type: decimal;"></HTML> +      - The file is referenced using a variable as shown. 
-<HTML><li></HTML><HTML><p></HTML>The input is selected from the “Linked Object” drop-down list.<HTML></p></HTML><HTML></li></HTML> +      The output of the File Reader is a virtual list of the records in the file. \\ {{  :bw:loopimage9.png?384x319  
-<HTML><li></HTML><HTML><p></HTML>If a file is found, the workflow proceeds to the next step (3).<HTML></p></HTML><HTML></li></HTML> + }} 
-<HTML><li></HTML><HTML><p></HTML>If no files are found to process, the workflow proceeds to the end of the loop (step 7) and, in this case, ends.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +  - A second loop processes the list of records created in step 3. 
-<HTML></li></HTML><HTML></ol></HTML> +      - The input is selected from the “Linked Object” drop-down list. 
- +      If a record is found, the workflow proceeds to the next step (5). 
-{{:bw:loopimage8.png?384x136}} +      If no records are found, the workflow proceeds to the end of the loop (step 6). \\ {{  :bw:loopimage10.png?384x133  }} 
- +  - The record from the previous step is inserted into an SQL table. 
-<HTML><ol start="3" style="list-style-type: decimal;"></HTML> +      - The input values are referenced by Bizweaver variables. \\ {{  :bw:loopimage11.png?384x230  }} 
-<HTML><li></HTML><HTML><p></HTML>A File Reader step processes the file presented from step 2.<HTML></p></HTML> +  - At this Loop End, the application tests to see if any records from the virtual list have not been processed. 
-<HTML><ol start="4" style="list-style-type: decimal;"></HTML> +      - If unprocessed records are found, the process returns to the starting point of the current loop (step 4) 
-<HTML><li></HTML><HTML><p></HTML>The file is referenced using a variable as shown.<HTML></p></HTML><HTML></li></HTML> +      If no unprocessed records are found, the process continues to the next step (7). 
-<HTML><li></HTML><HTML><p></HTML>The output of the File Reader is a virtual list of the records in the file.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +  At this Loop End, the application tests to see if any files from the virtual list have not been processed. 
-<HTML></li></HTML><HTML></ol></HTML> +      - If unprocessed files are found, the process returns to the starting point of the current loop (step 4) 
- +      If no unprocessed files are found, the process continues to the next step, which is the end of the workflow. 
-{{:bw:loopimage9.png?384x319}} +====== Conditional Looping ======
- +
-<HTML><ol start="4" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>A second loop processes the list of records created in step 3.<HTML></p></HTML> +
-<HTML><ol start="6" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>The input is selected from the “Linked Object” drop-down list.<HTML></p></HTML><HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>If a record is found, the workflow proceeds to the next step (5).<HTML></p></HTML><HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>If no records are found, the workflow proceeds to the end of the loop (step 6).<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
-<HTML></li></HTML><HTML></ol></HTML> +
- +
-{{:bw:loopimage10.png?384x133}} +
- +
-<HTML><ol start="5" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>The record from the previous step is inserted into an SQL table.<HTML></p></HTML> +
-<HTML><ol start="9" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>The input values are referenced by Bizweaver variables.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
-<HTML></li></HTML><HTML></ol></HTML> +
- +
-{{:bw:loopimage11.png?384x230}} +
- +
-<HTML><ol start="6" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>At this Loop End, the application tests to see if any records from the virtual list have not been processed.<HTML></p></HTML> +
-<HTML><ol start="10" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>If unprocessed records are found, the process returns to the starting point of the current loop (step 4)<HTML></p></HTML><HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>If no unprocessed records are found, the process continues to the next step (7).<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
-<HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>At this Loop End, the application tests to see if any files from the virtual list have not been processed.<HTML></p></HTML> +
-<HTML><ol start="12" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>If unprocessed files are found, the process returns to the starting point of the current loop (step 4)<HTML></p></HTML><HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>If no unprocessed files are found, the process continues to the next step, which is the end of the workflow.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
-<HTML></li></HTML><HTML></ol></HTML> +
- +
-====== Appendix A – Conditional Looping ======+
  
 A feature added in Bizweaver 2.1.0 is the ability to use conditions in loops. The functionality is used in place of the “Linked Object” as input. Its primary use is for web service calls that require paging to retrieve all records from the remote system. However, it may be used for other purposes as well. A feature added in Bizweaver 2.1.0 is the ability to use conditions in loops. The functionality is used in place of the “Linked Object” as input. Its primary use is for web service calls that require paging to retrieve all records from the remote system. However, it may be used for other purposes as well.
  
 +<WRAP center round info>
 A loop can use only a “Linked Object” or a “Conditional Expression.” Both options cannot be used simultaneously. A loop can use only a “Linked Object” or a “Conditional Expression.” Both options cannot be used simultaneously.
 +</WRAP>
 +
  
 The following example workflow illustrates how conditional looping works. This example is for demonstration purposes but can serve as a foundation to understand the concept. The following example workflow illustrates how conditional looping works. This example is for demonstration purposes but can serve as a foundation to understand the concept.
Line 152: Line 87:
 In this example, we want to drop out of the loop when records are no longer available for processing. The difference here is that we are checking for valid records in blocks of 50 records. Again, this for illustration only. In this example, we want to drop out of the loop when records are no longer available for processing. The difference here is that we are checking for valid records in blocks of 50 records. Again, this for illustration only.
  
-{{:bw:loopimage12.png?576x61}} +{{  :bw:loopimage12.png?576x61  }}
- +
-  - Two variables are used: MaxDocEntry and RecsRemain. The variables are defined and initialized in the “Variables_Init” step. +
- +
-{{:bw:loopimage13.png?420x220}} +
- +
-MaxDocEntry starts at 0 so the following tests begin with the lowest record ID (DocEntry). RecsRemain starts at 1 to indicate that records to remain to process. +
- +
-<HTML><ol start="2" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>Loop_Counter begins the loop process. This is where the looping condition is established.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
- +
-{{:bw:loopimage14.png?384x225}} +
- +
-The condition to continue processing (looping) is that the “RecsRemain” variable = 1. +
- +
-<HTML><ol start="3" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>The SQLCommand_checkMaxRec step determines the last DocEntry value in the current block of 50 records. This value will be used in the next step.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
- +
-{{:bw:loopimage15.png?384x116}} +
- +
-<HTML><ol start="4" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>The SQLCommand_checkRemainCount set determines whether records remain or not.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
- +
-{{:bw:loopimage16.png?384x182}} +
- +
-Note that the value used for “RecsRemain” is either a 0 or a 1.+
  
-<HTML><ol start="5" style="list-style-typedecimal;"></HTML> +  - Two variables are used: MaxDocEntry and RecsRemain. The variables are defined and initialized in the “Variables_Init” step. \\ {{  :bw:loopimage13.png?420x220  }} \\ MaxDocEntry starts at 0 so the following tests begin with the lowest record ID (DocEntry). RecsRemain starts at 1 to indicate that records to remain to process. 
-<HTML><li></HTML><HTML><p></HTML>The two variables established at the beginning of the workflow are updated.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML>+  - Loop_Counter begins the loop process. This is where the looping condition is established. \\ {{  
 + :bw:loopimage14.png?384x225  }} \\ The condition to continue processing (looping) is that the “RecsRemain” variable 1. 
 +  The SQLCommand_checkMaxRec step determines the last DocEntry value in the current block of 50 records. This value will be used in the next step. \\ {{  :bw:loopimage15.png?384x116  }} 
 +  The SQLCommand_checkRemainCount set determines whether records remain or not. \\ {{  :bw:loopimage16.png?384x182  }} \\ Note that the value used for “RecsRemain” is either a 0 or a 1. 
 +  The two variables established at the beginning of the workflow are updated. \\ {{  :bw:loopimage17.png?384x203  }} 
 +  - At this point the difference between a “Linked Object” loop and a “Conditional Expression” loop comes into play. In a “Linked Object” loop the process would check to see if another single record exists for processing. In this “Conditional Expression” loop the process instead checks the value of the “RecsRemain” variable. The determination to continue looping is made based on this value. Once the “RecsRemain” variable value changes to 0, the loop ends.
  
-{{:bw:loopimage17.png?384x203}}+====== Loop Variables ======
  
-<HTML><ol start="6" style="list-style-type: decimal;"></HTML> +^ Name           ^ Description          ^ 
-<HTML><li></HTML><HTML><p></HTML>At this point the difference between “Linked Object” loop and a “Conditional Expression” loop comes into play. In a “Linked Object” loop the process would check to see if another single record exists for processing. In this “Conditional Expression” loop the process instead checks the value of the “RecsRemain” variable. The determination to continue looping is made based on this value. Once the “RecsRemain” variable value changes to 0, the loop ends.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML>+| StepMessage         | During failure the reason for failure will be populated here| 
 +| StepStatus         | True or False        |
bw/looping_tool.1546511306.txt.gz · Last modified: 2019/01/03 05:28 by _deletedUser4_