Forum Discussion

DCat1223's avatar
DCat1223
Frequent Contributor
9 years ago
Solved

Help with a dataloop within a dataloop

Good afternoon…

First let me preface this by stating that I am not a developer. That being said, I am writing a web-based Keyword test that basically tests an automated ordering application. 

 

The way this application works is the user access a screen where they input the Vendor # and Warehouse (vend_num) & (whse_name) into a screen and click a next button.

 

A second screen displays where the user enters the items they want to order (item_num).  My data is an Excel file with variables set up in TC to correspond to the spreadsheet.

 

Here is a very basic example of my data

mstr_dept

sub_dept

dept_name

vend_num

item_num

item_name

whse_name

1

1

FROZEN BAKERY          

1111

100000

Frozen Rolls

Frozen Warehouse

1

1

FROZEN BAKERY          

1111

100001

Frozen Bagels

Frozen Warehouse

1

1

FROZEN BAKERY          

1111

100002

Frozen Doughnuts

Frozen Warehouse

2

1

Meat

2222

200000

Steak

Meat Warehouse          

2

1

Meat

2222

200001

Hamburger

Meat Warehouse          

2

1

Meat

2222

200002

Chicken

Meat Warehouse          

3

1

DAIRY PRE-PACK          

3333

300000

Packaged Ham

Dairy Warehouse    

3

1

DAIRY PRE-PACK          

3333

300001

Packaged Turkey

Dairy Warehouse    

3

1

DAIRY PRE-PACK          

3333

300002

Packaged Bologna

Dairy Warehouse    

3

2

CULTURED DAIRY          

4444

400000

Strawberry Yogurt

Dairy Warehouse    

3

2

CULTURED DAIRY          

4444

400001

Blueberry Yogurt

Dairy Warehouse    

3

2

CULTURED DAIRY          

4444

400002

Raspberry Yogurt

Dairy Warehouse    

3

3

DAIRY BEVERAGES

5555

500000

Whole Milk Gallon

Dairy Warehouse    

3

3

DAIRY BEVERAGES

5555

500001

2% Milk Gallon

Dairy Warehouse    

3

3

DAIRY BEVERAGES

5555

500002

Skim Milk Gallon

Dairy Warehouse    

 

So for example, the first dataloop will tell the automation to enter vend_num 1111 and whse_name Frozen Warehouse in the first screen and click a ‘Next’ button and a second screen will appear.

 

In the second screen, the nested data loop will begin, telling the automation to enter item_num 100000 and a random qty, 100001 and a random qty, 100002 and a random qty, create the Purchase Order, and return to screen#1 to input the next vendor and warehouse.

 

It is at this point I am having trouble getting loop#2 to end, and telling loop #1 to go on to the next vendor – in this case vend_num 2222 and whse_name Meat Warehouse and the whole process repeats again with the next set of items.  

 

So my questions are:

  1. Is this possible with the way my data is laid out?
  2. I’m thinking I need to tell loop2 that if the next row has a different vend_num than the current one, thent it needs to end. Any suggestions on how to do this?

Thank you for your time!

Dave.

  • Depends.

     

    If you will always have three entries for each vendor, then loop2 can just have an index from 1 to 3 and quit.  

     

    If the number of entries will vary, then you can keep track of CurrentVendor and LastVendor.  When you go through and the CurrentVendor is different, then you need to process a purchase order before you continue.

     

    Seems like it would be easier to have just one loop though.  Read a row, if it's a new vendor, process the purchase order and clear the totals before you continue.  Then process the row you have and loop again.

     

    If you need more detail let me know.


  • DCat1223 wrote:

    Hi william_roe...

     

    Thank you for the input.  I'm not a technical person and this is all pretty new to me so please forgive my ignorance.  I'm still muddling my way through all of this.

     

    Humor me if you will, as I reiterate what I think you are suggesting - I'm probably going to get this worng but here it goes...

     

    1) I replace any duplicate instance of Vendor# with NULL, or "" in my datasheet.

    2) When Vendor# changes, I execute the portion of the test that creates the PO, and start the loop over with the next vendor. 

    Am I close?

     

    If so, how do I tell the test that if the Vendor# changes to run the lines of the script that create the PO and restart the loop using the next vendor? 

     

    Thank you for your time.

     

    DC.

     

     


    1) Don't input "NULL' OR "" in the vend_num cell - simply delete the redundant value in the cells and in then perform an "if" operation where the value != null. (I can include a screen capture later if it would help)

    2.) You don't need to start the loop over. Finish whatever needs to be done on page 2, the po detail (after the next non null vend_num value is found and return back to page 1 (the po header) and continue on to the next record in the loop. 

     

8 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Depends.

     

    If you will always have three entries for each vendor, then loop2 can just have an index from 1 to 3 and quit.  

     

    If the number of entries will vary, then you can keep track of CurrentVendor and LastVendor.  When you go through and the CurrentVendor is different, then you need to process a purchase order before you continue.

     

    Seems like it would be easier to have just one loop though.  Read a row, if it's a new vendor, process the purchase order and clear the totals before you continue.  Then process the row you have and loop again.

     

    If you need more detail let me know.

    • DCat1223's avatar
      DCat1223
      Frequent Contributor

      Hi Marsha_R

       

      Thank you for the reply.  You are correct.  The number of items per vendor will indeed vary.  I am loving one loop.  I don't know why I thought it had to be two.

       

      Regarding CurrentVendor and LastVendor - That sounds ideal.  I'm going to play around with that and see if i can figure out how to assign those variables.  I may be hitting you up again for some guidence if that's ok.

       

      Thank you so much!

    • DCat1223's avatar
      DCat1223
      Frequent Contributor

      Hi Marsha_R

       

      I'm still struggling with this.  I'm still not quite understanding how this can be done with one loop. 

       

      The PO Create process relies on 2 screens... 

       

       - The first screen is where the user enters the Vendor# and the Warehouse the product is to ship to.  Once the Vendor and Warehouse are entered the user navigates to the next screen in the workflow via a NEXT button.

       

       - The second screen is where the item# and quantity are entered.  The user remains on this screen and enters items and quantities unlil they have completed the item entry process for the current vendor, (no more items for this Vendor# on the datasheet) at which time they create the PO (PO CREATE Button).

       

      Once the PO has been created, the User returns to the first screen (Create Another PO Button) and start this process all over again, returning to the first screen and entering the next Vendor# and Warehouse. 

       

      With one loop, wouldn't this force the application to return to the first screen after each item and quantity is entered?  If so this will not work.  The application does not behave this way.  This is why I am thinking a second loop is required where if CurrentVendor = LastVendor, the second loop repeats until CurrentVendor < > LastVendor, then loop2 ends, the PO is created, and loop1 iterates to the next Vendor# and Warehouse.

       

      The sedcond part of my question is regardless of one or two loops, how do I go about setting the values of CurrentVendor and LastVendor?  I'm familiar with the Set Variable Value statement in the Keyword test, but not sure what the syntax for those variables should look like.

       

      Thank you again for your help!

       

      DC.

       

      • william_roe's avatar
        william_roe
        Super Contributor

        DCat1223 wrote:

         

        The PO Create process relies on 2 screens... 

         

         - The first screen is where the user enters the Vendor# and the Warehouse the product is to ship to.  Once the Vendor and Warehouse are entered the user navigates to the next screen in the workflow via a NEXT button.

         

         - The second screen is where the item# and quantity are entered.  The user remains on this screen and enters items and quantities unlil they have completed the item entry process for the current vendor, (no more items for this Vendor# on the datasheet) at which time they create the PO (PO CREATE Button).

         

        Once the PO has been created, the User returns to the first screen (Create Another PO Button) and start this process all over again, returning to the first screen and entering the next Vendor# and Warehouse. 

         

        With one loop, wouldn't this force the application to return to the first screen after each item and quantity is entered?  If so this will not work.  The application does not behave this way.  This is why I am thinking a second loop is required where if CurrentVendor = LastVendor, the second loop repeats until CurrentVendor < > LastVendor, then loop2 ends, the PO is created, and loop1 iterates to the next Vendor# and Warehouse.

         

        The sedcond part of my question is regardless of one or two loops, how do I go about setting the values of CurrentVendor and LastVendor?  I'm familiar with the Set Variable Value statement in the Keyword test, but not sure what the syntax for those variables should look like.

         

        Thank you again for your help!

         

        DC.

         


        There's no reason a single pass through the loop won't work. Don't close the second screen until the Vendor # changes. Then open the first / second screen again and repeat.You could even leave the dept_name / vendor number blank and use this != null logic instead of tracking whether Vendor # changed. We store the one-to-many relationship as comma separated values to reduce the redundant data in the spreadsheet. This works best for a single value (i.e. item serial s1,s2,s3). There are places where multiple values are stored and use a second delinator i.e. (serial, quantity;serial, quantity). If your not a technical person the nested loops will be confusing.

         

        Variables don't have a sytax - they are of a specific type (i.e. string, integer etc). Unless calculations are performed strings are fine - even if the value is a number.