imthekrish Respected Contributor.
Respected Contributor.
1349 views

make lists from a list

Jump to solution

I've a list with values as below 

order|servername

1|server1.xxx.com

2|server2.xxx.com

2|server3.xxx.com

3|server4.xxx.com

3|server5.xxx.com

3|server6.xxx.com

4|server7.xxx.com

Now I have to feed servers to multiple instance operation based on order. i.e., all servers with order 1 should be fed to multiple instance at once and all 2s at the same time after finishing 1s and so on. Is there anything operation to do this.

Labels (1)
0 Likes
1 Solution

Accepted Solutions
imthekrish Respected Contributor.
Respected Contributor.

Re: make lists from a list

Jump to solution

Thanks Bridges!!

The besy way to do this is query DB for the distinct order number and make a list using LIST APPENDER operation.

Pass the list to LIST ITERATOR operation and then query DB for servername whoes order is first number in list item. In my case I have multiple servers of same order, in such case use LIST APPENDER and make a list of servers with same order. Pass this list to multi instance. After coming out the multi instance check for errors, if no errors go back to list iterator get second set and so on..

I hope this helps.

0 Likes
5 Replies
Bridges Respected Contributor.
Respected Contributor.

Re: make lists from a list

Jump to solution

Yes,  have a selection ciriteria and then use the list appender to add the selection to the list you want.    Pass that list to the mutli-instance.

0 Likes
imthekrish Respected Contributor.
Respected Contributor.

Re: make lists from a list

Jump to solution

Thanks Bridges!!

The besy way to do this is query DB for the distinct order number and make a list using LIST APPENDER operation.

Pass the list to LIST ITERATOR operation and then query DB for servername whoes order is first number in list item. In my case I have multiple servers of same order, in such case use LIST APPENDER and make a list of servers with same order. Pass this list to multi instance. After coming out the multi instance check for errors, if no errors go back to list iterator get second set and so on..

I hope this helps.

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: make lists from a list

Jump to solution

Hi,

It can be solved somewhat easyer. As you have seen the db query operation gives you this list either comma separated or each line in a new line.

In the case where you get the list comma separated you must create separate results (list) for each order. You create on the step the result order1 and apply the following filters:

- replace all comma with new line (in the replace with field just press the enter key and studio will know what to do)

- regex to match only lines that start with 1|

- replace all new line with comma (or the delimiter of choice for you)

-  replace 1| with nothing, if needed to remove the order and just have the server name

- strip whitespace (to ensure there are no leading or trailing whitespaces or other hidden chars that could affect the execution)

Repeat this step for all orders and then just pass the results to the various MI steps.

In case the list is given by the db operation with each order/server group on a new line then the filters are the same as above just start with the second filter.

 

Regards,

Vlad 

0 Likes
imthekrish Respected Contributor.
Respected Contributor.

Re: make lists from a list

Jump to solution

order varies from application to application in my situation. Lets suppose if im make 4 list for 4 order and if tomorrow i will have an app thats needs to perform same operation but it has 7 orders. This will FAIL. correct me if im wrong

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: make lists from a list

Jump to solution

Hi,

The approach i mentioned will not fail, however it will just perform the processing for the existing results. In your example it will only process the 4 orders and leave 3 orders unprocessed. Where this will fail is if on one call you have 4 orders and on another you only have 3 orders. In this case you will eventually try to run some commands on an enmpty input which can only lead to failures.

Now in case you have an unknown number of orders each time in the result (could be 1 could be 10) and assuming you can have a situation where you may have servers with order 1,2,3 no order 4 then 5 and 6 (for example) the individual call for each order is going to be a bit of a nightmare to implement.  In this case however i think using dynamic variables is what is needed. 

Once you get the list in the form of order_number | server_name (as stated above) pass  this list to a list iterator  and on the iterator create 2 results orderNumber (filter to strip everything after and including |) and serverName (filter to strip everything up to and including | ) and strip whitespace at the end on both as a precaution.  In a list appender add the server name to a list called  listOrder${orderId} and after that check if the order number is the greatest in order to find the max order  of servers you need to process. If the order is the greatest store it in a variable called maxOrderId.  

Now once the iterator completes you will have the list of servers and the max orderId. Place a counter ( library\utiity operations\looping) and set it to run from 1 to ${maxOrderId} on that step create a result orderId which will just take the result string. Now connect the has more transition to a check null step to check if there are servers to process on that order. For the check null verify the keyname  listOrder${orderId}. If there are are servers in that order then on the MI step  on the multivalue input type in the assign from field the value  listOrder${orderId}.

In this way you will be able to have any number of orders handled dynamically.

Hope this helps,

Vlad

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.