Loop inside Loop logic

Hi,
I have 2 stringlist in the pipeline strList1 and strList2. I want to loop over this strlist one inside the other in such a so that I can do 1-to-1 mapping of values in this srtlist.
This is what I am doing.
1st loop/strList1 (Name1, Name2, Name3)
do something
2nd loop/strList2 (Name11, Name22, Name33)
do something
Map Name1 - Name11

I want to Map Name1 - Name11, Name2 - Name22, Name3 - Name33 and so on.
Does somebody knows how we can implement this logic.

Thanks for the help.
Akshay

Have your tried using StrList1 as the input array and strList2 as the output array for the loop?
I think that should do what you want.

HTH

Hi Chris,
When I am looping over loop2 for the first time then I want to map only Name11 value and need to exit so that the control goes to Loop1. When I 2nd time loop over loop2, I want Name22 only and again need to exit. I need to repeate the same till I map all the values.
I hope I clarified my problem.
Could you explain me in detail how we can do this.

Thanks
Akshay.

Akshay,

Are you using StrList2 as a lookup table of sorts? In other words are you trying to find the value of the string from StrList1 inside StrList1 and then do something? If so, a couple of alternatives related to recordLists were discussed here: http://www.wmusers.com/wmusers/messages/117/21992.shtml

If you always want to set the string in the current element n of StrList1 to the value of the same element n in StrList2, you can do that with a map statement that sets the value of your StrList1 string to %StrList2[myCounter]%, where myCounter is set to the value of $iteration - 1 (using the pub.math:subtractInts service).

Can you clarify what you are trying to do?

Mark

Mark,

Have you actually used it? I was trying something similar and variable substitution with index like, %Array[index]%, just doesn’t work for me. Am I missing something here. BTW, I am using IS4.6

if you looking for loop index and want to use dynamic increment you can use the $iterate pipeline variable(which will be inside the loop step).
And do a variable substitution %iteration% (on Branch or sequence).

HTH.

Mark,
Here is what I want to do.

In the first Iteration:
loop-1/strList1 (Name1, Name2, Name3)
do something
loop-2/strList2 (Name11, Name22, Name33)
do something
*******get the first value of strList2 (Name11)
end Loop-2

end Loop-1

In the 2nd Iteration:
loop-1/strList1 (Name1, Name2, Name3)
do something
loop-2/strList2 (Name11, Name22, Name33)
do something
*******get the second value of strList2 (Name22)
end Loop-2

end Loop-1

I am not able to do ******* part in my logic.

Could you please let me know how this can be implemented.

Thanks
Akshay

I am not sure I understand correctly. Are you suggeting I create a separate branch sequence for each possible value of $iteration and assign the corresponding Array element inside that Branch.

My earlier post was incorrect. I apologize for the bad info.

It is possible to directly reference a string or record contained in a stringList or recordList, but not using the solution I gave.

Use the pub.list:getListItem to do this. Since array elements are numbered beginning with 0 and loop iterations are numbered beginning at 1, you need to use the pub.math:subtractInts service to set a varable (index) to $iteration - 1. Map this value to the index parameter of the pub.list:getListItem service (mapping StrList2 to its list parameter).

The attached package contains a single service which illustrates what I think Akshay is attempting to do (still not clear on this).

WMUsersExamples.Zip package (Copy to your IS server’s /replicate/inbound folder and load with the Admin tool’s “Install Inbound Releases” function.
WMUsersExamples.zip (3.3 k)

HTH,

Mark

Thanks Mark for the help.
This is what I am looking for.
But I am using wm 6.0 in which pub.list:getListItem is deprecated.
Do we have some alternate service for this in 6.0.

Thanks’ for your help
Akshay.

Hi Akshay - you should take some time to read the built-in services guide and other pdf’s, however the service you probably want is pub.list:getRecordListItem for 6.0.

Good luck!

The IS 6.0 release notes indicate that there is no replacement service for the pub.list.getListItem servic, but that “you can achieve the old services’ functionality by using the Pipeline Editor to link items and specify array indexes in Link Properties.”

My IS 6.0 server is down just now, but I’ll attempt to test this tomorrow.

BTW, a list of services deprecated in WM 6.0 can be found here:
http://www.wmusers.com/wmusers/messages/6855/IS_6_0_Deprecated_Built-In_Services_v1_1-15278.xls

-M

Developer 6.0 allows you to specify a variable name (enclosed with ‘%’ characters) on the Indexing tab of the Link Properties dialog. You access the Link Properties dialog by double-clicking on the line connecting your source and target variables. When the source or target variables are lists (string or record) you can specify an index value. In IS 4.6, this could only be an integer and could not be a variable.

The attached package contains an example of this that works for IS 6.0.

IS 6.0 Mapping Example
WMUsersExamples60.zip (7.2 k)

Regards,

Mark

Thanks Mark and thanks to all for the help.
This worked perfectly for me.

Akshay

Thanks for all the help Mark. Just faced the prob and your reply post helped me solving.

* For pub.list services without replacement services, you can achieve the old services’ functionality by using the Pipeline Editor to link items and specify array indexes in Link Properties.

pub.list:appendToRecordList pub.list:appendToDocumentList
pub.list:stringListToRecordList pub.list:stringListToDocumentList
pub.list:copyListItem No replacement services. See *.
pub.list:getListItem No replacement services. See *.
pub.list:getRecordListItem No replacement services. See *.
pub.list:getStringListItem No replacement services. See *.
pub.list:setListItem No replacement services. See *.
pub.list:setRecordListItem No replacement services. See *.
pub.list:setStringListItem No replacement services. See *.

It’s not true that there isn’t a replacement for the deprecated pub.list:getListItem service.

One can easily acomplish the same functionality by using the pub.string:messageFormat service.

Just invoke the messageFormat service with the string list/array you want and pass as the pattern something like: {%idx_variable%}

Don’t forget to enable the “Perform variable substitution” option when setting the pattern.

Cheers,
CG