Need help in designing a service

Hi All,
My requirement is getting data from db and creating a csv file with that. I followed the below steps.

I got the data from db with my required columns say col1,col2 and col3. When i am trying to append everything to a string, i am not getting expected resultSet. I first initialized errorData string variable with empty string.

PFA dia and help to meet my requirement.

Thanks,
RP

Why not use getTracedataOutput/results/BID directly, don’t need to specify index, results will become a single document in the Loop.

since you are looping over getTracedataOutput/results, you should remove the index of [$iteration], directly use:
%getTracedataOutput/results/BID% for inString2.

I think Xiaowei is saying the same.

Hi,
Both options will work but the mistake tat i did was, didn’t select “Perform variable Substitution” button. Now its working fine.

Now my input string contains value -bid1,tid1bid2,tid2bid3,tid3

How can i make this as below

bid1,tid1
bid2,tid2
bid3,tid3

And how can i write the same into xls in 2 diffreent columns. Kindly guide me.

You can append “\r\n” after “%getTracedataOutput/results/TID%” like “%getTracedataOutput/results/TID%\r\n”, then you will get the errorData like:
bid1,tid1
bid2,tid2
bid3,tid3
Save the errorData string into a file named whatever.csv, you don’t need to do something to maintain the columns, Excel will do it.

Hi Wang,

I tried in the same way but in the string, its coming like
bid1,tid1\r\nbid2,tid2\r\nbid3,tid3\r\n

and in giving this to a java service, in file name providing .xls as extension but in .xls file, everyting is coming in a single column.

Still trying other options, please share if you have any tweaks.

Thanks,
RP

Hi,
I tried a sample service my errorData looks like bid1,tid1,error1 bid2,tid2,error2 bid3,tid3,error3

You can tokenize the string based on space character and then remove the comma if you need (customize the code).

valueList will look like
bid1,tid1,error1
bid2,tid2,error2
bid3,tid3,error3

Pass this as your second input to string concat.
%Mahesh.SAG:getTracedataOutput/getTracedataOutput/results/BID%,%Mahesh.SAG:getTracedataOutput/getTracedataOutput/results/TID%,%Mahesh.SAG:getTracedataOutput/getTracedataOutput/results/ERROR%[one space at last]

Sorry, it’s my fault, it won’t work in that way. You can right click on the input control, and click “Use larger editor” as attached screen-shot, in this editor you can type a carriage return.
larger editor.png

Hello,
Try out what Xiaowei Wang or I suggested. It should work :slight_smile:

Hi,
When i am writing everything to a string list and finally when i am passing it to a fileWriter service,it is just taking very 1st line of String list and writing to a file (is it just because fileWriter takes string as an input ).

When i tried differently like keeping everything in to a single variable say –

final String : bif1,tif1"\r\n"bif2,tif2"\r\n"bif3,tif3"\r\n", when i am writing this to a file it is writing file content too with the same data instead of appending new line in place of “\r\n”.

Kindly help me

Hi RP,
Is this issue resolved?

Did you try the steps suggested as above.

Thanks Mahesh and Wang for your inputs here.

I tried the way which Wang suggested but still i am not getting my desired output.

With the below output there is no use – bif1,tif1"\r\n"bif2,tif2"\r\n"bif3,tif3"\r\n"

By writing some logic, i am able to produce the below output as part of StringList

bid1,tid1,error1
bid2,tid2,error2
bid3,tid3,error3

But when i am trying to write to a file, as writeToFile service takes only only a string, its not writing details which are other than 1st line.

Hence final output to file is – bid1,tid1
Thanks,
RP

You can right click on the input control, and click “Use larger editor” as attached screen-shot, and HIT enter the cursor and close the setValue and save it.\

This will start give the new line feeds…

HTH,
RMG

RP,

Did you try the steps suggested by me in this post. I had replicated the service as per your requirement and it worked for me without any issues :slight_smile:

Share your code (PKG) let me have a look at that.

Hi All,

It’s working fine now. Thanks for your helping hands !!!

Thanks,

Glad to hear it resolved now…if you can update the final resolution would be good for this thread n others: