cancel
Showing results for 
Search instead for 
Did you mean: 

To show the result of 2 grids in a single csv file

0 Kudos

Hi,

i want to show 2 grids(seperately) in a csv file.i created a aggregate query that is giving me result of 2 grid seperately but when i use a igrid template with aggregate query it is giving me result in a single row.i.e instead of giving 2 grids it is giving result with all the columns in a single row .I am using Applet.saveas CSV File();is there any way to have 2 seperate grid in a single Excel file.

thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

sufw
Active Participant
0 Kudos

Hi Karthick,

first of all, I would not use AggegrateQuery as, to my knowledge, this is feature is mostly deprecated and now replaced with Business Logic Services and the Join, Union, etc. actions within this tool (feel free to correct me SAP guys).

You can use the following approach using BLS (Business Logic Services):

1. Insert your two queries. As per Som's suggestion, including them in the same sequence is a good idea, even though BLS doesn't currently support parallelisation.

2. Use the "Union" action block to "merge" the separate XML outputs created by these queries into one XML structure (one Rowsets node, containing two Rowset nodes). The Union action block does not perform a union in the database sense, but simply appends the XML document assigned to its second input to the XML document assigned to its first input property.

3. Assign the output of the Union action block to a suitable XML transaction output property.

4. Use an Xacute query template to test your new BLS transaction; you can set the template's output to "text/csv". This will give you the output of the first query, followed immediately by the output of the second query in one CSV file. You can still use the SaveAsCSV function in JavaScript for this template as well.

Hope this helps,

Sascha

Former Member
0 Kudos

Karthik

Aggregate Query is mostly used to combine multiple queries which have at least one common column among those.

For ur requirement, u can use direct BLS with the help of Action Block <b>WriteFile</b>.

<b>Scenario :</b> u hv 2 queries - one with 4 columns A, B, C & D; another with 2 columns E & F

U want to display those tables separately in one single Excel Sheet.

<b>Solution :</b> Forget AggregateQuery and Take the following steps

Step 1: Take those two Queries in one sequence

Step 2: Define two Local variables - Text1 & Text2 with String Data Type

Step 3: Use Repeater to loop one query's result and Assign the Looping results to the Local.Text1 using action <b>Assignment</b> as following expression in the Link Editor

<b>Local.Text1 &

Repeater_0.Output{/Row/A} & tab &

Repeater_0.Output{/Row/B} & tab &

Repeater_0.Output{/Row/C} & tab &

Repeater_0.Output{/Row/D} & crlf

</b>

Step 4: Use another Repeater outside the first Repeater to loop 2nd query's result and Assign the looping results to the Local.Text2 in similarly way as follows in the Link Editor

<b>

Local.Text2 &

Repeater_1.Output{/Row/E} & tab &

Repeater_1.Output{/Row/F} & crlf

</b>

Step 5: Use action <b>WriteFile</b> outside those above Repeaters and take the mode <b>APPEND</b> and FilePath <b>C:
test
TwoTables.xls</b> and Text as follows

<b>

"A" & tab & "B" & tab & "C" & tab & "D" & crlf & Local.Text1 & crlf & crlf &

"E" & tab & "F" & crlf & Local.Text2

</b>

in the Link Editor

Step 6: Hit F5/F6 and see the Excel File with two tables showing separately in the mentioned path above.

Regards

Som