Set up a Looping Process
Looping is a powerful function that can be used with the FileIterator event to:
- Copy files from a source folder to a target folder
- Run a batch job against those same files individually
- Run a stored procedure against the same files
A few notes about looping:
- Before setting up looping events, add Logical Paths and File Operations. Refer to Add Logical Paths and Add File Operations for more information.
- Looping must be enabled for all events for the @filename to be populated with the most current Path/File. If Looping is not enabled on any succeeding events (by clicking the Loop check box on the Interface Events page, only the last value of the @filename will be available to that event.
- Looping is not needed on a FileIterator when there is no other process that needs to run individually against the files.
To enter content in the Field, type the field name in the list box and click Use this Value for it to be added to the list box. The following is an example of how looping can be set up:
Event #1: Copy files from a source folder to a target folder, then delete the files from the source folder.
-
Select Interfaces in the Navigation pane.
-
Click the Events icon for the desired interface.
-
Click Add.
-
Enter a value in the PRIORITY field.
NOTE: The PRIORITY field indicates the order in which the interface event runs.
-
Select WebApp from the EVENT TYPE list box.
-
Select InterfaceServer: File Operations from the PAGE ID list box.
-
Click the LOOP check box to enable it, indicating the event will be processed multiple times based on input.
-
Enter a descriptive comment in the COMMENT field.
-
Click Save; the Vertical View displays.
View the field description for the Interface Events page’s Vertical View
-
Select FileIterator from the Event list box.
-
Click Save.
-
Click the Web App Parameters icon.
-
Click Add.
-
Enter the @filename in the Field combo box.
NOTE: “filename” includes the complete path/filename of the copied file. Any “field” parameters that start with an “@” is an output parameter, which means that the files copied during this event can be referenced as “filename” in the next event.
-
Leave the Value field blank.
-
Click Save.
-
Enter Operation in the Field combo box.
-
Enter the name of a File Operation that was created on the File Operations page in Value field.
-
Click Save.
Event #2: Run a batch job against the same files individually where the FileName is passed to a batch job
-
Select Interfaces in the Navigation pane.
-
Click the Events icon for the desired interface.
-
Click Add.
-
Enter a value in the PRIORITY field.
NOTE: The PRIORITY field indicates the order in which the interface event runs.
-
Select WebApp from the EVENT TYPE list box.
-
Select InterfaceServer: Parameters from the PAGE ID list box.
-
Click the LOOP check box to enable it, indicating the event will be processed multiple times based on input.
-
Enter a descriptive comment in the COMMENT field.
-
Click Save; the Vertical View displays.
View the field description for the Interface Events page’s Vertical View
-
Select CommandExec from the Event list box.
-
Click Save.
-
Click the Web App Parameters icon.
-
Click Add.
-
Enter commandname in the Field combo box.
-
Enter “c:\test\dirlist.bat” #file1# in the Value field.
NOTE: The text within the quotes is the name of the batch job and the text between the # signs is a parameter set up for this event. In this case, it is the @file parameter that is populated from the @filename parameter, which is configured for the FileIterator event. The text between the #s must match the field name exactly, including the case. In this example, if the commandname stayed the same and a new parameter was added as File1, the interface job would fail because it would not have a value for #file1#.
-
Click Save.
-
Enter file1in the Field combo box.
-
Enter @filename in the Value field.
NOTE: Any “field” (value) parameters that start with an “@” is an input parameter.
-
Click Save.
-
Enter WAIT in the Field field.
-
Leave the Value field blank.
The WAIT parameter makes the interface wait for the batch job to finish before it goes to the next job. If the job fails and the WAIT parameter is not set, the interface appears as Successful.
Event #3: Run a stored procedure against the same files.
A stored procedure can be created to accept parameters. In the case of the File Iterator Loop, if a stored procedure is part of the loop, the filename needs to be one of the parameters of the stored procedure.
When adding a stored procedure as an event, the parameters in the stored procedure are automatically created for the event. Click the Parameters icon to see all the parameters sent to the stored procedure. One of these parameters is the Field to which the @filename is passed.
For example, if an UpdateLog stored procedure that has a parameter named “Description” is added after a File Iterator event, @filename is passed to the “Description” field.
-
Select Interfaces in the Navigation pane.
-
Click the Events icon for the desired interface.
-
Click Add.
-
Enter a value in the PRIORITY field.
NOTE: The PRIORITY field indicates the order in which the interface event runs.
-
Select StoredProcedure from the EVENT TYPE list box.
-
Click the LOOP check box to enable it, indicating the event will be processed multiple times based on input.
-
Enter a descriptive comment in the COMMENT field.
-
Click Save; Vertical View displays.
-
Click Save.
-
Click the Stored Procedure Parameters icon to open the Stored Procedure page.
NOTE: When adding a stored procedure as an event, the parameters in the stored procedure are automatically created for the event. Click the Stored Procedure Parameters icon to view all parameters sent to the stored procedure.
-
Enter the filename in the Field combo box.
NOTE: “filename” is the name of the parameter in the stored procedure to which the filename is passed.
-
Enter @filename in the Value field.
-
Click Save.
Was this article helpful?
Sorry about that.
Why wasn't this helpful? (check all that apply)
Thanks for your feedback.
Want to tell us more?
Send an email to our authors to leave your feedback.
Great!
Thanks for your feedback.