Looping Example

This is an example of how to use WebSphere Host Publisher to connect, collect data, and disconnect from a University site.  Using Host Access, we will connect to the University of Michigan's Library database.  From this database we can search for books by authors, titles, subjects, and so on.  We will search for authors under a particular last name and loop through the resulting screens, extracting the results on each screen.  After we obtain a list of authors, we will disconnect from the database.

Understanding Looping

Looping enables you to define an action that should be repeated until a condition is met.  For example, if a user wants to get more data than appears on one page, you need a way to repeat collecting data until the last screen is recognized.  You can use looping to achieve this.

You do not need to record a Connect/Disconnect Macro with every Data Macro if you already have a Connect and Disconnect Macro saved.  Every Data Macro must be associated with a Connect and Disconnect Macro, so if you do not have one saved, then you have to create one.  In this example, we are using the same database as the Basic Example that showed how to build Connect and Disconnect Macros, therefore, we are going to reuse the Basic_Example as the connection pool.  Otherwise, you can follow the instructions provided in the Basic Example to create a Connect and Disconnect Macro.
.
Begin Looping

Create a new Integration Object.  Then select to Share an existing connection pool.  This allows you to use the same connection from another Integration Object when they are using the same server.  In this example, we are going to use Basic_Example.  Click Next.

You are asked if you want to run the Connect Macro.  Click Yes.

The Connect Macro associated with the pool runs, logging you onto the system.  Once this is done, the Begin recording box appears informing the user that he is now ready to record the Data Macro.  You are NOT automatically thrown into the Record state.  You must indicate when you are ready to begin recording.  Click OK.

Highlight the Data Macro on the left-hand side and click Record Macro.

The Begin Data Macro screen appears.   In this example, we will extract the names of authors that share the same last name.  Therefore, choose Gather Data and click Next.

The Gather Data Screen appears.   Enter MCAT and press Enter to select the University of Michigan's Online Catalog.

The Unrecognized Screen appears.  Create a definition for this screen by clicking Yes.

The New Screen Definition screen appears.  The screen name defaults to Screen1, Screen2, and so forth.  To make the macro easier to read, change the name to something meaningful.  If this screen appears at different times in the Macro and requires the same action each time, select This is a global screen.  You cannot use a global screen as the last screen in a Macro.  In this example, we rename the screen to Introduction Screen which makes the screen easier to identify on the left-hand side.  Click Next.

The Add Recognition Criterion to Screen Definition appears.  This page allows you to choose how you want the Integration Object to remember this screen.  Text area allows you to choose specific text on the screen, Number of fields allows you to choose the number of total fields on the screen or the number of input fields, Cursor position allows you to recognize the screen by the position of the cursor, and then there is an Advanced choice that you can read about in Help.  Remember that you must uniquely define each screen.  For this example, we are going to select Text area and click Next.

The Text Area Recognition appears.  Draw a box around the word Introduction, select At the specified position, then click Next.

The Screen Definition appears.  This screen allows you to add additional criterion to recognize the screen.  Choose Add if you want to add additional features to recognize the screen by.  Otherwise, click Next.

The Gather Data Screen appears.  By selecting to use a variable for the author, you can fill in different names during invocations of the Data Macro.  Type a=, then click, Insert Input Variable.  (You may use the Menu item pull downs, or use the Insert Input Variable item on the tool bar.)

The Insert Input Variable box appears.  Type an input variable name, and provide a value for the variable, which will be used only to record the interaction with this system.  The value itself will not be remembered.

In this example, the variable will be author_input.  For recording purposes, we fill in a temporary value for the author.  Since this value is a variable, the value is not stored in the Integration Object.  It is merely used to continue recording.  After typing this information, click OK.

Note that the value used for the variable is inserted in the command line.  Press Enter to continue recording this Macro.

The Unrecognized Screen appears.  Create a definition for this screen by clicking Yes.

The New Screen Definition screen appears.  In this example, we rename the screen to Search Results Screen which makes the screen easier to identify on the left-hand side.  Click Next.

The Add Recognition Criterion to Screen Definition appears.  For this example, we are going to select Text area.  Click Next.

The Text Area Recognition appears.  Draw a box around the words Author Guide, select At the specified position, then click Next.

The Screen Definition appears.  Click Next.

The Gather Data Screen appears.  You are now ready to capture data associated with this page. This is where you want to start the loop because this is the first screen of many that you want to extract the data from.  Select Start Loop.

The Record Loop page appears.  The loop captures the listing of the authors in a plain text format by running a fixed number of times or continuing through the entire loop until it reaches the last page.  Click Next to continue.

The Recording Loop - Begin Loop screen appears.  Select Gather Data and click Next.

You are already at the screen where you want to capture data.  Click Next.

The Recording Loop - Select Data page appears.  Select Select data on the terminal and draw a box around the data you want to capture.  When you finish, click Next.

The Recording Loop - Data Format page appears.  We can choose to display the information in the selected area as text, or provide to the user in a table format.  In this example, the data will appear as plain text.  Select Extract data as a table, then click Next.

The Recording Loop - Extract Data screen appears.  Type a name for this extraction, then click Next.

The Recording Loop - Select Column Names screen appears.  You can either use values on the screen as table headers by selecting text on the screen, or use default values by selecting Next.  You can change these names when you use the Studio.  Therefore, let the table header names default and click Next.

The Recording Loop - Data Table screen appears.  Click Merge to combine the two columns since it is one name for each row.

Now, you can select the column name and provide an identifiable value.  In this example, the header was allowed to default to column0, to change the column name select the column then type the new name in the text box which says Column name.  After values are provided for all of the column headers, click Next.

The Recording Loop - Finish Data Extraction page appears.  Even though you have more of the same type of data to capture, select Finish extracting data since this is all the data to be extracted in one pass of the loop.  Click Next.

The Recording Loop - Perform Repetitive Action page appears.  You will now perform the action that you want repeated.  In this example, press PF8 once, then click Next.

The Loop Ending Conditions screen appears.  If you know the number of iterations that you want to perform then select Stop loop after fixed number of iterations and enter a number.  Otherwise, you can define a unique screen to stop the loop.  In this example, we are going to Define a unique screen where the loop will stop.  Click Next.

The Recording Loop - Define Last Loop page appears.  The system will now stop recording until you get to the last page.  Follow the directions on the screen.  After you navigate to the final screen of the loop you will be ready to record your interaction of the last screen.  In this example, this is the last screen of the loop.  Click Next.

The Recording Loop - New Screen Definition screen appears.  In this example, we rename the screen to Last Screen which makes the screen easier to identify on the left-hand side.  Click Next.

The Recording Loop - Add Recognition Criterion to Screen Definition screen appears.  Select Text area and click Next.

In this example, the end of a search result list is identified by the PF7 BACK page in the lower right hand corner because for this macro, this is the only screen that PF7 appears in this exact location.  Draw a box around the text to identify this page, select At the specified position, then click Next.

The Recording Loop - Screen Definition screen appears.  Click Next.

The Finish Data Extraction screen appears.  Select Finished extracting data, then click Next.

Navigate back to the Database Selection Menu Screen by typing STA to disconnect from the session.  The system records each step.  Press Enter.  The Finish Data Macro screen appears.  Because we chose to use the Basic_Example session pool, there is a Disconnect Macro associated with the Connect Macro, so there is no need to continue with the Disconnect Macro after you have completed your Data Macro.  Therefore, once you navigate back to the initial screen (Database Selection Menu Screen), you are done recording the data macro.  Click the Stop Recording button.

Click Yes to stop recording.


 

Save this Integration Object as Looping_Example and click Save.  You are finished!  You are ready to use the Host Publisher Studio to build an application to deploy to Host Publisher servers.  For details on how to build the Web Application go to  Host Publisher Studio: Looping Example .