Input Array in LOOP, or Label in Branch

Hello there

I am new in webMethods, and am working in webMethods developer.

I created a service that reads data from a text delimited flat file, then it filters the data.

I created a flat file dictionary for the record definition and then I mapped it to a flat file schema to get the document type.

I created my service and it worked well.

Inside a LOOP in the input array property I paste the path of the record I want to read from the file, and then I compare (using branch) between a value the user input and the value of a selected field in the file. All the previous steps are hard coded.

Is there a way I can let the user input the field name and the value then getting results by using only one branch instead of using multiple branches for all fields?

Eg. If the service prompt the user to input the field name “fieldName” and the value “fieldValue”.
If I loop through the record and Inside my branch I set it to Evaluate Label =true. Could I write this statement inside my label in the step flow? %fieldValue% == %docParent/recordWithNoID/%fieldName%%.

or could I do the following in the loop:
1. set a value in a pipline tmpStr = docParent/recordWithNoID/
2. set input array of a LOOP to %tmpStr%

Hello

out of your two options

"If I loop through the record and Inside my branch I set it to Evaluate Label =true. Could I write this statement inside my label in the step flow? %fieldValue% == %docParent/recordWithNoID/fieldName%.

or could I do the following in the loop:
1. set a value in a pipline tmpStr = docParent/recordWithNoID/
[FONT=Times New Roman][SIZE=3]2. set input array of a LOOP to %tmpStr% "

I did not understand the second part but basically you can use the first option but remember two things
-for %fieldValue% use ‘Perform variable substitution’ option and

  • rememeber to drop the %fieldvalue% after each iteration

and also notice the syntax updated above to use in the lable [/size][/font]

thanks
Anil

Thank you Sir for replying

I created a package to show you what am trying to do.
I’ve created two flow services; one for the Loop step and the other is for the Branch.
Logicaly I suppose to get result but if you debug them you will notice my problem.

Thanks & Regards
Ameer
variables in loop.zip (8.21 KB)

Hello Alamir,

I create a simple java service that it can help you (I guess).
It receives a general document (“docin”) and an address (“lookup”) that you want to locate and reply an object (it can be a string or an document).

 
IDataCursor pipelineCursor = pipeline.getCursor();
pipelineCursor.first("lookup");
String lookup = (String) pipelineCursor.getValue();
Object docin = ValuesEmulator.get(pipeline, "docin");
String[] lst = lookup.split("/"); 
for (int i = 0; i < lst.length; i++) {
docin = ValuesEmulator.get((IData)docin, lst[i]);
if (docin == null) {
break;
}
}
Object docout = null;
if (docin != null)
docout = docin;
pipelineCursor.insertAfter("docout", docout);
pipelineCursor.destroy();