+ Start a Discussion
Marcelo AgostinhoMarcelo Agostinho 

Creating Table with Apex...

01/2010 - Customer 1Customer 1Hello... sorry but i dont know if this is the best Board to post my question.


Well... actually i need to create a table getting datas from a map...



private List<MovimentoMes__c> movimentosClientes = [Select m.Vendedor__r.Name, m.Cliente__r.cliente__c, m.Cliente__r.campoLivreAlt__c ,											 m.Cliente__r.municipio__c , m.Cliente__r.uf__c ,m.Mes_de_Referencia__c, m.Valor__c									    From MovimentoMes__c m];
	public void mapClienteValorMeses(){
		clienteFaturamentoMes = new Map<String,Map<String,Double>>();
		for(MovimentoMes__c movimento: movimentosClientes){
			cliente = movimento.Cliente__r.cliente__c;
			mesDeReferencia = movimento.Mes_de_Referencia__c;
			valorMesReferencia = movimento.Valor__c;
				faturamentoMes = clienteFaturamentoMes.get(cliente);
					totalMes = faturamentoMes.get(mesDeReferencia);
					totalMes += valorMesReferencia;
			} else {
				faturamentoMes = new Map<String,Double>();

Explaining the code above.

My external map receive a customer (String) as Key, and an Map(String,Double) as Value, and the Internal Map Receive a Month of Purchase(String) as Key and a Value of Purchase(Double) as Value.


So where is my problem....


Considering 12 month (Not exactly all months of the same year)... some customers bought something on month 01, 02, 03, and another bought something on month, 04,06,08...


I know exactly the12 month period, where it begin and where it end...


What i need to do is something like it:


A table where the first column is the name of the customer...the first row is the header with all the month period... 

But i said before some customers doesnt buy all months... and this data will not exist at Map... so if one customer doesnt buy one month... at table this need to appear with 0, how i can do it?


Well sorry about my english =)


Very thanks for everything!


You can create List of List of twelve items where data doenst exist for customer for particular month you can put 0 or null in that cell (position on List)