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 books by the author's name and loop through the resulting screens, extracting the results on each screen.  After we obtain a list of books, 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 Unrecognized Screen appears.  Create a definition for this screen by clicking Yes.

We will rename this screen from DataScreen1 to Introduction Screen.  Then, click Next.

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

The Gather Data Screen appears.  In this example, we will extract the names of books by a particular author.  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.  For recording purposes, we fill in a temporary value for the author.  Since this value is 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 data.

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

We will rename this screen from DataScreen2 to Search Results Screen.  Then, click Next.

The Text Area Recognition appears.  Draw a box around the words Search Results, select At the specified position, then 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 titles of the books in a table format, then you will continue the selection by choosing PF8 (forward page) until all members are selected.  In this example, PF8 was chosen because that is an easy way to get to the next page of the data.  Click Next to continue.

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 a table.  Select Extract data as a table, then click Next.

The Extract Data page appears.  Type a name for this extraction, then click Next.

The Recording Loop - Select Column Names page 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 appears.  Select the column name and provide an identifiable value.  In this example, the header was allowed to default column0, which we changed to book_titles.  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 capturing 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 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.

This screen is recognized when you cannot go forward any longer.  We defined this screen Last Page Screen.  Click Next.

The last screen must be recognized in the macro.  When a screen contains selected information, Host Access assumes that the repetitive action is finished.  Make sure you select unique text.  In this example, the end of a search result list is identified by the PF7 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 Finish Data Extraction screen appears.  Select Finished capturing 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 Unrecognized Screen appears.  Click Yes to create a definition for this screen.

The Define Screen appears.  Rename the screen from DataScreen5 to Database Selection Menu Screen.  Click Next.

The Text Area Recognition appears.  Draw a box around the words Database Selection Menu and select At the specified position, then click Next.

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.

Save this Integration Object as Looping 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 .