Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Table duplication
ravishanku
I have a collection with some datas. I have to print this datas in different tables..to understand more i have attached a file with this..the collection wil be as follows::<br />
Collection col = new ArrayList();<br />
col[0] = Ledger Head: SBI SB A/C NO: 123 ; <br />
col[1] = 31-Mar-2011 12:00 AM,1,cxc,0,210 (this is the first row see the attachment)....etc like wise it goes...and when it reaches col
= another Ledger Head as it came in col[0] it should start printing in a new table same as above....<br />
<br />
pls anyone help..i am searching this for a long time..i am getting only methods for making dynamic table with dynamic dataset..but i think this is not what i want here...waiting for reply..<br />
<br />
Another thing is that, iteration of collection col is done in an EventHandler Class..in the fetch()...while this iteration of collection, the new table should be created....<br />
<br />
The EventHandler Class is as below......<br />
<br />
public class Testing extends ScriptedDataSetEventAdapter{<br />
<br />
Collection col = new ArrayList();<br />
int count = 0;<br />
Iterator it = null;<br />
DayBookBean foo = new DayBookBean();<br />
float tcred = 0,tdeb = 0;<br />
<br />
public void beforeOpen(IDataSetInstance dataSet, IReportContext reportContext)throws ScriptException {<br />
<br />
super.beforeOpen(dataSet, reportContext);<br />
col = (Collection)reportContext.getParameterValue("myResultSet"); //Retrieved collection through session<br />
}<br />
<br />
<br />
public void open(IDataSetInstance dataSet) throws ScriptException{<br />
<br />
super.open(dataSet);<br />
it = col.iterator();<br />
}<br />
<br />
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow row)<br />
throws ScriptException {<br />
<br />
Boolean status = false;<br />
if(it.hasNext()) {<br />
status = true;<br />
foo = (DayBookBean)it.next();<br />
}<br />
else{<br />
status = false;<br />
}<br />
<br />
if(foo.getOflag()==1){ <br />
String head = "LEDGER HEAD: " + foo.getHeadName();<br />
row.setColumnValue("head",head);<br />
row.setColumnValue("Opbal", foo.getTotalopbalance());<br />
}<br />
<br />
row.setColumnValue("date", foo.getTransactionDate());<br />
row.setColumnValue("rtno", foo.getReceiptNo());<br />
row.setColumnValue("rtno",foo.getVoucherNo());<br />
row.setColumnValue("narration",foo.getNarration());<br />
row.setColumnValue("debit",foo.getDebit());<br />
row.setColumnValue("credit",foo.getCredit());<br />
<br />
return status; <br />
}<br />
<br />
Thanking you,<br />
Ravishankar
Find more posts tagged with
Comments
mwilliams
I'm not sure if I'm understanding correctly, but if I am, you should be able to create a column in your resultSet that just lists the "Ledger Head" value. Then when you create your table in your design, you can group on this value so the correct rows are associated with it, then there would be a new group header and footer for each section of the table with a different "Ledger Head" so you'd essentially have a new table for each "ledger head" value.
Hope this helps.
ravishanku
THANKING YOU SOO MUCH FOR YOUR REPLY...
But Sorry williams..i didnt understand what you meant..
first thing; i am not using any resultSet here...the ledgerhead value and details below(date,rtno,narration...) are from two differnt tables...i have made the collection in such a way that the details of a particular ledger are brought together...
as you are saying to take the ledgervalue alone in a seperate column(which i didnt understand) ..how will i identify which all details have to come under that ledger...
short discription of my code for you to understand better::
//in foo the first collection is der (col[0])
if(foo.getOflag()==1) //this checking is to identify a new ledgervalue has arrived while the iteration
{ //when this happens ledgervalue is printed..
String head = "LEDGER HEAD: " + foo.getHeadName();
row.setColumnValue("head",head);
row.setColumnValue("Opbal", foo.getTotalopbalance());
}
//in this same col[0] the other details are also available which are printed below...
row.setColumnValue("date", foo.getTransactionDate());
row.setColumnValue("rtno", foo.getReceiptNo());
row.setColumnValue("rtno",foo.getVoucherNo());
row.setColumnValue("narration",foo.getNarration());
row.setColumnValue("debit",foo.getDebit());
row.setColumnValue("credit",foo.getCredit());
//this collection will be iterated and all values coming under this ledgervalue will be printed (col[1],col[2],...)
//now when the above if loop works again it means another ledger has arrived (at this point new table should come to play)....that also means the collection set coming under that will be the values for that particular ledger....
i think u have got some more idea....
thanking you,
Ravishankar
ravishanku
Plsss sir i am waiting for your reply...i am not able to move a bit with this problem..
I tried your suggestion but i am not able to connect things (due to ma less undersatnding)...
Pls give me some more explanation if you were on the right path with my prob !!!!
mwilliams
So, you're not creating a scripted dataSet with this? Or you are? Let me know.
It looks to me like you are. In this case, it looks like each "collection" ends up being a row. You then create a table listing each field of the collection as a row. So, what you should need to do is group by row["head"]. This will give you a separate header and footer to use for each "head" value, which if I'm understanding correctly is a collection. Let me know if I'm missing something.
ravishanku
I have made an EventHandler class..in which all this iteration is done(in fetch())...but the dataSets i have made it in the report side..
(I am really new to birt so i may b wrong with the above statement pardon me)
ravishanku
ok ok that is giving some sense to me...but still; some more fuss...how will i print the other details like date,narratn etc... can u pls narrate with a small eg.
mwilliams
Can you first show me what a collection or two of data looks like once you have it in your scripted dataSet? Then, I'll just use this data to show you what I mean with grouping.
ravishanku
I was trying for the last few days...but couldn come to an end...:(
Collection col;
if(col.getOflag()==1) //this checking is to identify a new ledgervalue(header) has arrived while the iteration
{ //when this happens ledgervalue is printed..
row.setColumnValue("head",col.getHeadName());
row.setColumnValue("Opbal", col.getTotalopbalance());
}
row.setColumnValue("date", col.getTransactionDate());
row.setColumnValue("rtno", col.getReceiptNo());
row.setColumnValue("narration",col.getNarration());
row.setColumnValue("debit",col.getDebit());
row.setColumnValue("credit",col.getCredit());
if need more information pls inform...!!!
mwilliams
Can you actually show what your data looks like once you have it in your scripted dataSet?
ravishanku
Collection col;
(i=0,1,2,3,4....)
col[0] = Ledgername: SBI (ie. the header row i have setted in report)
31-march 2011 2 helloworld 100 0 (this i put in the detail row)
col[1] = 1-april 2011 20 welcome 200 0
col[2] = 20-april 2011 11 thanks 0 500
col[3] = Ledgername: FEDERAL BANK
21-april 2011 55 proceed 1000 0
col[4] = 1-april 2011 20 goingon 300 0
like that it goes......(hope you got an idea)
I have done something like this and iam getting it as below...
ravishanku
Collection col;
(i=0,1,2,3,4....)
col[0] = Ledgername: SBI (ie. the header row i have setted in report)
31-march 2011 2 helloworld 100 0 (this i put in the detail row)
col[1] = 1-april 2011 20 welcome 200 0
col[2] = 20-april 2011 11 thanks 0 500
col[3] = Ledgername: FEDERAL BANK
21-april 2011 55 proceed 1000 0
col[4] = 1-april 2011 20 goingon 300 0
like that it goes......(hope you got an idea)
I have done something like this and iam getting it as below...
ravishanku
Here the datas are all jumbled up...those datas that have to come under CASH is coming at top with other datas..
mwilliams
In your scripted dataSet editor, can you click on the "preview results" and take a screenshot of it so I can see what your data looks like in your dataSet? Or drag the dataSet to your design layout and run the report with just the straight dataSet table in it? Thanks!
ravishanku
Hey i got it....:):):):):):):):):):):)
The thing was , in the post no:9 in this thread if you look you will find a if condition { if(col.getOflag()==1) }, this i was using to differentiate the head(ledgerhead) from othe datas....i just avoided it...so its coming perfect...birt itself is grouping the datas...really fantastic!!!!!!! Thank you so much mathew for your cooperation....HAIL BIRT !!!! this is jus an amazing tool...
One more doubt...is it possible to create 2 footer for a group???..i am now only able to create 1 footer
ravishanku
Sorry..it was micheal i meant
..thank you micheal for your help...
ravishanku
This is for all who needs a conclusion for this....
We can group the datas in birt reporting in a simple way...
1) Create your table
2) Right click in table --> select insert group
3) In that name your group and specify the GroupOn
4) You can add the deatil row to this if you have any other datas to be iterated
also footer data.
after this run the programme and sit back ..you can find birt grouping the datas by its on..
My output is attached below.....
mwilliams
Are you still having the issue with needing a second footer? Can you explain? If you just want a second row, you can just right click on the footer row and choose insert > row > below/above. Let me know.
ravishanku
Yaaa gt it....Out of excitement i couldn figure it..!!! Thanks a lot !!!
mwilliams
Sounds good. Let us know whenever you have questions!
ravishanku
My next prob.....:)
How to make this each group in different pages....means each group should start in a new page
ravishanku
I got it...its there in the edit group options...thanks again
mwilliams
Whenever you have a new question, it is best to start a new thread to keep the topics separate! Thanks!