This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
bw:looping_tool [2019/01/03 05:36] _deletedUser4_ [Loop-Within-Loop Example] |
bw:looping_tool [2022/08/02 10:57] (current) akoehler |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Introduction ====== | + | ====== Introduction |
| - | This document | + | 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: | + | |
| - | * [[bw: | + | |
| - | * [[bw: | + | |
| - | + | ||
| - | ====== 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 49: | 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. | ||
| - | {{: | + | {{ : |
| - | - 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. \\ {{: | + | - 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. \\ {{ : |
| - | - A loop is started using the list from step 1 as input. (Linked Object). \\ {{: | + | - A loop is started using the list from step 1 as input. (Linked Object). \\ {{ : |
| - A second SQL Command: Reader step is used to get the details for the first contact record. | - 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. \\ {{: | + | - The code from the list is used to get the specific information for the contact. \\ {{ : |
| - The e-mail is created. | - The e-mail is created. | ||
| - | - The recipient’s e-mail address is taken from the details in step 3. \\ {{: | + | - The recipient’s e-mail address is taken from the details in step 3. \\ {{ : |
| - The application now checks to see if there are any additional records in the list passed into the loop that have not been processed. | - 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 an unprocessed record is found, steps 3 and 4 are executed for the next record. | ||
| Line 70: | 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. | ||
| - | {{: | + | {{ : |
| - | - 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.” \\ {{ : |
| - The initial loop processes the list of files created in step 1. | - The initial loop processes the list of files created in step 1. | ||
| - The input is selected from the “Linked Object” drop-down list. | - The input is selected from the “Linked Object” drop-down list. | ||
| - If a file is found, the workflow proceeds to the next step (3). | - If a file is found, the workflow proceeds to the next step (3). | ||
| - | - If no files are found to process, the workflow proceeds to the end of the loop (step 7) and, in this case, ends. \\ {{: | + | - If no files are found to process, the workflow proceeds to the end of the loop (step 7) and, in this case, ends. \\ {{ : |
| - A File Reader step processes the file presented from step 2. | - A File Reader step processes the file presented from step 2. | ||
| - The file is referenced using a variable as shown. | - The file is referenced using a variable as shown. | ||
| - | - The output of the File Reader is a virtual list of the records in the file. \\ {{: | + | - The output of the File Reader is a virtual list of the records in the file. \\ {{ : |
| + | }} | ||
| - A second loop processes the list of records created in step 3. | - A second loop processes the list of records created in step 3. | ||
| - The input is selected from the “Linked Object” drop-down list. | - The input is selected from the “Linked Object” drop-down list. | ||
| - If a record is found, the workflow proceeds to the next step (5). | - If a record is found, the workflow proceeds to the next step (5). | ||
| - | - If no records are found, the workflow proceeds to the end of the loop (step 6). \\ {{: | + | - If no records are found, the workflow proceeds to the end of the loop (step 6). \\ {{ : |
| - The record from the previous step is inserted into an SQL table. | - The record from the previous step is inserted into an SQL table. | ||
| - | - The input values are referenced by Bizweaver variables. \\ {{: | + | - The input values are referenced by Bizweaver variables. \\ {{ : |
| - At this Loop End, the application tests to see if any records from the virtual list have not been processed. | - At this Loop End, the application tests to see if any records from the virtual list have not been processed. | ||
| - If unprocessed records are found, the process returns to the starting point of the current loop (step 4) | - If unprocessed records are found, the process returns to the starting point of the current loop (step 4) | ||
| Line 92: | Line 74: | ||
| - If unprocessed files are found, the process returns to the starting point of the current loop (step 4) | - 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. | - If no unprocessed files are found, the process continues to the next step, which is the end of the workflow. | ||
| - | ====== | + | ====== 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. | ||
| + | </ | ||
| + | |||
| 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 102: | 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. | ||
| - | {{: | + | {{ : |
| - | + | ||
| - | - Two variables are used: MaxDocEntry and RecsRemain. The variables are defined and initialized in the “Variables_Init” step. | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | 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. | + | |
| - | + | ||
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | The condition to continue processing (looping) is that the “RecsRemain” variable = 1. | + | |
| - | + | ||
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | {{: | + | |
| - | + | ||
| - | Note that the value used for “RecsRemain” is either a 0 or a 1. | + | |
| - | < | + | - Two variables are used: MaxDocEntry and RecsRemain. The variables are defined and initialized in the “Variables_Init” step. \\ {{ : |
| - | < | + | - Loop_Counter begins the loop process. This is where the looping condition is established. \\ {{ |
| + | : | ||
| + | | ||
| + | | ||
| + | | ||
| + | - 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. | ||
| - | {{: | + | ====== Loop Variables ====== |
| - | < | + | ^ Name ^ Description |
| - | < | + | | StepMessage |
| + | | StepStatus | ||