Hey Orlando, got my mistake, forgot to set the counter in the inner loops back to 1 thats why the loop just run once.
Code: Select all
#****Begin: Generated Statements***
#****End: Generated Statements****
#pFilter = 'Jahre: '|pJahr|' & Version: '|pQuellversion;
#build subsetname
sSubsetName = 'tmpCappingCalc_TI_' | today(1);
nProdCap = pProdCap \ 100;
#create tmp Subsets
if(SubsetExists('Tag', sSubsetName) = 1);
SubsetDestroy('Tag', sSubsetName);
EndIf;
if(SubsetExists('Kontaktart', sSubsetName) = 1);
SubsetDestroy('Kontaktart', sSubsetName);
EndIf;
if(SubsetExists('MA-Pool', sSubsetName) = 1);
SubsetDestroy('MA-Pool', sSubsetName);
EndIf;
SubsetCreatebyMDX(sSubsetName, '{TM1FILTERBYLEVEL({DESCENDANTS(Tag.['|NumberToString(pJahr)|']) }, 0)}');
SubsetCreatebyMDX(sSubsetName, '{TM1FILTERBYLEVEL({DESCENDANTS(Kontaktart.[Kontaktarten Gesamt]) }, 0)}');
SubsetCreatebyMDX(sSubsetName, '{TM1FILTERBYLEVEL({DESCENDANTS([MA-Pool].[MA-Pool Gesamt]) }, 0)}');
#count elements in subsets
numEl = SubsetGetSize('Tag', sSubsetName);
kontaktArtsize = Subsetgetsize('Kontaktart', sSubsetName);
maPoolSize = Subsetgetsize('MA-Pool', sSubsetName);
peSize = Subsetgetsize('Planungseinheit', 'Alle n Level');
dayi = 1;
kontaktArtIndex = 1;
maPoolIndex = 1;
peIndex = 1;
#Loop all elements in Subset
while(dayi<=numEl);
#get element name from index
sDay = SubSetGetElementName('Tag', sSubsetName,dayi);
while(kontaktArtIndex <= kontaktArtsize);
sKontaktArt = SubsetGetElementName('Kontaktart', sSubsetName, kontaktArtIndex);
while(maPoolIndex <= maPoolSize);
sMaPool = SubsetGetElementName('MA-Pool', sSubsetName, maPoolIndex);
while(peIndex <= peSize);
sPE = SubsetGetElementName('Planungseinheit', 'Alle n Level', peIndex);
nErlangMenge = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'ErlangC Menge Lmin');
nSonstigeMenge = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'sonstige Menge Lmin');
nBlendingMenge = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'blending Menge Lmin');
nMengeGesamt = nErlangMenge + nSonstigeMenge + nBlendingMenge;
nErlangRMA = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, 'Leistungsspektrum', sKontaktArt, 'Erlang rMA');
nNichtGeblendeteRMA = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, 'Leistungsspektrum', sKontaktArt, 'nicht geblendete rMA');
nNochNichtGeblendeteRMA = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, 'Leistungsspektrum', sKontaktArt, 'noch nicht geblendete rMA');
nRmaProdCap = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, 'Leistungsspektrum', sKontaktArt, 'noch nicht geblendete rMA');
nGesamtRMA = nErlangRMA + nNichtGeblendeteRMA + nNochNichtGeblendeteRMA;
prod = nMengeGesamt \ (nGesamtRMA * CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'Arbeitszeit in Min'));
ASCIIOUTPUT('C:\Testo.txt',NumberToString(dayi), NumberToString(peIndex), sPE,'Day: ', sDay, sKontaktart, sMaPool, sPE, NumberToString(prod), NumberToString(nProdCap), 'ErlangMenge', NumberToString(nErlangMenge), 'nSonstigeMenge', NumberToString(nSonstigeMenge),'nBlendingMenge', NumberToString(nBlendingMenge) );
While(prod > nProdCap);
ASCIIOUTPUT('C:\Testo.txt', NumberToString(prod), NumberToString(nProdCap));
nErlangMenge = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'ErlangC Menge Lmin');
nSonstigeMenge = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'sonstige Menge Lmin');
nBlendingMenge = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'blending Menge Lmin');
nMengeGesamt = nErlangMenge + nSonstigeMenge + nBlendingMenge;
nErlangRMA = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'Erlang rMA');
nNichtGeblendeteRMA = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'nicht geblendete rMA');
nNochNichtGeblendeteRMA = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'noch nicht geblendete rMA');
nRmaProdCap = CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'noch nicht geblendete rMA');
nGesamtRMA = nErlangRMA + nNichtGeblendeteRMA + nNochNichtGeblendeteRMA;
CellPutN(CellGetN('Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'rmA Prod Capping')+0.5,'Blending_Simulation', sDay, pVersion, sMApool, sPE, sKontaktArt, 'rmA Prod Capping');
end;
peIndex = peIndex +1;
end;
peIndex =1;
maPoolIndex = maPoolIndex +1;
end;
maPoolIndex = 1;
kontaktArtIndex = kontaktArtIndex +1;
end;
kontaktArtIndex = 1;
dayi=dayi+1;
end;
SubsetDestroy('Tag', sSubsetName);
SubsetDestroy('Kontaktart', sSubsetName);
SubsetDestroy('MA-Pool', sSubsetName);
Very bad code, i think its totally vs best practice but it works.