Skip to main content

Flags control example in report of MSD Axapta

Flags control example in report of Axapta I think its going to difficult to understand.


 public boolean fetch()  
 {  
 // boolean ret;  
 // ret = super();  
 boolean HeaderFlag;  
 boolean ProgFlag;  
 boolean FirstRun;  
 Boolean HeaderOnFirstRun;  
 QueryBuildDataSource qbds__RegBatchProcess;  
 QueryBuildRange QrRegNo,qrcrop,rangeTransDate,QBR_TechYear;  
 Query q = new Query();  
 ;  
 q = this.query();  
 qbds__RegBatchProcess = q.dataSourceTable(tablenum(_RegBatchProcess));  
 //Add Sort Field  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, InventLocationId));//1 Center  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, _seasonid));//2 Season  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess,Stg));//3 Stage  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, ItemId));//4 Crop  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, CustAccount));//5 MPCode  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, InventColorId));//6 Variety  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, _DistrictName));//7 District  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, _TName));//8 T  
 qbds__RegBatchProcess.addSortField(fieldnum(_RegBatchProcess, _VName));//9 V  
 //Add Sort Field  
 QueryRun = new QueryRun(q);  
 season = "";  
 crop = "";  
 Centername = "";  
 stage = "";  
 HeaderFlag = False;  
 Variety = "";  
 District ="";  
 T = "";  
 V = "";  
 NoOfSP = 0;  
 AreaRegistered = 0;  
 ProgFlag = False;  
 TotalNoOfSP =0 ;  
 TotalAreaReg =0;  
 FirstRun = True;  
 TotalFlag = False;  
 HeaderOnFirstRun = False;  
 chkMPCode = "";  
 QBR_TechYear = qbds__RegBatchProcess.findRange(fieldNum(_RegBatchProcess,TechYear));  
 if (QBR_TechYear.value() != "")  
 {  
 TechYear = QBR_TechYear.value();  
 // info("START");  
 /*while Select * from _RegBatchProcess_object  
 order by _RegBatchProcess_object.InventLocationId ,  
 _RegBatchProcess_object._seasonid ,  
 _RegBatchProcess_object._B_F_II ,  
 _RegBatchProcess_object.ItemId ,  
 _RegBatchProcess_object.InventColorId ,  
 _RegBatchProcess_object._DistrictName , _RegBatchProcess_object._TName,  
 _RegBatchProcess_object._VName*/  
 while(QueryRun.next())  
 {  
 _RegBatchProcess_Object = QueryRun.get(tablenum(_RegBatchProcess));  
 if(Centername != _RegBatchProcess_Object.InventLocationId)  
 {  
 HeaderFlag = True;  
 }  
 else if(season != enum2str(_RegBatchProcess_Object._SeasonId))  
 {  
 HeaderFlag = True;  
 }  
 else if(stage != enum2str(_RegBatchProcess_Object._B_F_II))  
 { HeaderFlag = True; }  
 else if(crop != _RegBatchProcess_Object.ItemId)  
 { HeaderFlag = True; }  
 else  
 {HeaderFlag = False;}  
 /*  
 else if(MPCode != _RegBatchProcess_Object.CustAccount)  
 { HeaderFlag = True; }  
 */  
 if(FirstRun == False)  
 {  
 if(Variety != _RegBatchProcess_Object.InventColorId)  
 {ProgFlag = True;}  
 else if(District != _RegBatchProcess_Object._DistrictName)  
 { ProgFlag = True; }  
 else if(T != _RegBatchProcess_Object._TName)  
 { ProgFlag = True; }  
 else if(V != _RegBatchProcess_Object._VName)  
 { ProgFlag = True; }  
 else if(MPCode != _RegBatchProcess_Object.CustAccount)  
 { ProgFlag = True; }  
 else  
 {ProgFlag = False;}  
 }  
 if (FirstRun == True)  
 {  
 Centername = _RegBatchProcess_Object.InventLocationId;  
 season = enum2str(_RegBatchProcess_Object._SeasonId);  
 stage = enum2str(_RegBatchProcess_Object._B_F_II);  
 crop = _RegBatchProcess_Object.ItemId;  
 MPCode = _RegBatchProcess_Object.CustAccount;  
 Variety = _RegBatchProcess_Object.InventColorId;  
 District = _RegBatchProcess_Object._DistrictName;  
 T = _RegBatchProcess_Object._TName;  
 V = _RegBatchProcess_Object._VName;  
 // Header  
 // if (Variety != "" && District != "" && T != "" && V != "")  
 // {  
 info ("HEADER # " + Centername + " : " + stage + " : " + season  
 + " : " + InventTable::find(crop).ItemName);  
 MPCode = _RegBatchProcess_Object.CustAccount;  
 Header1.executeSection();  
 chkMPCode = "";  
 HeaderOnFirstRun = True;  
 // }  
 ProgFlag = False;  
 NoOfSP = 0;  
 AreaRegistered = 0 ;  
 //Reset Total  
 TotalNoOfSP =0 ;  
 TotalAreaReg =0;  
 }  
 else  
 {  
 if(HeaderFlag == True)  
 {  
 Centername = _RegBatchProcess_Object.InventLocationId;  
 season = enum2str(_RegBatchProcess_Object._SeasonId);  
 stage = enum2str(_RegBatchProcess_Object._B_F_II);  
 crop = _RegBatchProcess_Object.ItemId;  
 MPCode = _RegBatchProcess_Object.CustAccount;  
 Variety = _RegBatchProcess_Object.InventColorId;  
 District = _RegBatchProcess_Object._DistrictName;  
 T = _RegBatchProcess_Object._TName;  
 V = _RegBatchProcess_Object._VName;  
 // if (Variety != "" && District != "" && T != "" && V != "")  
 // {  
 if (HeaderOnFirstRun != True)  
 {  
 info ("HEADER # " + Centername + " : " + stage + " : " + season  
 + " : " + InventTable::find(crop).ItemName);  
 Header1.executeSection();  
 chkMPCode = "";  
 HeaderOnFirstRun = True;  
 }  
 info ("PS # " + CustTable::find(MPCode).Name  
 + " : " +InventColor::find(Variety,Crop).Name  
 + " : " + _District::find(District)._DistrictName  
 + " : " + _T::find(T)._TName  
 + " : " + _V::find(V)._VName  
 + " : " + num2str(NoOfSP,4,2,0,0)  
 + " : " + num2str(AreaRegistered,4,2,0,0));  
 progdetail.executeSection();  
 TotalNoOfSP = NoOfSP + TotalNoOfSP;  
 TotalAreaReg = AreaRegistered + TotalAreaReg;  
 TotalFlag = True;  
 // }  
 if(TotalFlag == True)  
 {  
 info ("TOTAL # " + Centername + " : " + stage + " : " + season  
 + " : " + InventTable::find(crop).ItemName  
 + " : " + num2str(TotalNoOfSP,4,2,0,0)  
 + " : " + num2str(TotalAreaReg,4,2,0,0));  
 TotalFlag = False;  
 ProgTotal.executeSection();  
 }  
 // if (Variety != "" && District != "" && T != "" && V != "")  
 // {  
 info ("HEADER # " + Centername + " : " + stage + " : " + season  
 + " : " + InventTable::find(crop).ItemName);  
 this.newPage();  
 chkMPCode = "";  
 Header1.executeSection();  
 // }  
 ProgFlag = False;  
 NoOfSP = 0;  
 AreaRegistered = 0 ;  
 //Reset Total  
 TotalNoOfSP =0 ;  
 TotalAreaReg =0;  
 }  
 }  
 if(ProgFlag == True)  
 {  
 //programmable section execution  
 if (Variety != "" && District != "" && T != "" && V != "")  
 {  
 if (HeaderOnFirstRun != True)  
 {  
 info ("HEADER # " + Centername + " : " + stage + " : " + season  
 + " : " + InventTable::find(crop).ItemName);  
 Header1.executeSection();  
 chkMPCode = "";  
 HeaderOnFirstRun = True;  
 }  
 info ("PS # " + CustTable::find(MPCode).Name+ " : " +InventColor::find(Variety,Crop).Name+ " : " + _District::find(District)._DistrictName+ " : " + _T::find(T)._TName+ " : " + _V::find(V)._VName+ " : " + num2str(NoOfSP,4,2,0,0)+ " : " + num2str(AreaRegistered,4,2,0,0));  
 progdetail.executeSection();  
 TotalNoOfSP = NoOfSP + TotalNoOfSP;  
 TotalAreaReg = AreaRegistered + TotalAreaReg;  
 TotalFlag = True;  
 }  
 if(HeaderFlag == True)  
 {  
 if(TotalFlag == True)  
 {  
 info ("TOTAL # " + Centername + " : " + stage + " : " + season+ " : " + InventTable::find(crop).ItemName+ " : " + num2str(TotalNoOfSP,4,2,0,0)+ " : " + num2str(TotalAreaReg,4,2,0,0));  
 TotalFlag = False;  
 ProgTotal.executeSection();  
 }  
 // if (Variety != "" && District != "" && T != "" && V != "")  
 // {  
 info ("HEADER # " + Centername + " : " + stage + " : " + season+ " : " + InventTable::find(crop).ItemName);  
 this.newPage();  
 chkMPCode = "";  
 Header1.executeSection();  
 // }  
 ProgFlag = False;  
 NoOfSP = 0;  
 AreaRegistered = 0 ;  
 //Reset Total  
 TotalNoOfSP =0 ;  
 TotalAreaReg =0;  
 }  
 NoOfSP = 0;  
 AreaRegistered = 0 ;  
 }  
 Centername = _RegBatchProcess_Object.InventLocationId;  
 season = enum2str(_RegBatchProcess_Object._SeasonId);  
 stage = enum2str(_RegBatchProcess_Object._B_F_II);  
 crop = _RegBatchProcess_Object.ItemId;  
 MPCode = _RegBatchProcess_Object.CustAccount;  
 Variety = _RegBatchProcess_Object.InventColorId;  
 District = _RegBatchProcess_Object._DistrictName;  
 T = _RegBatchProcess_Object._TName;  
 V = _RegBatchProcess_Object._VName;  
 NoOfSP = NoOfSP + 1;  
 AreaRegistered = AreaRegistered + _RegBatchProcess_Object._Area;  
 info ("DATA # " + Centername + " : " + stage + " : " + season  
 + " : " + InventTable::find(crop).ItemName  
 + " : " + CustTable::find(MPCode).Name  
 + " : " + InventColor::find(Variety,Crop).Name  
 + " : " + _District::find(District)._DistrictName  
 + " : " + _T::find(T)._TName  
 + " : " + _V::find(V)._VName  
 + " : " + num2str(NoOfSP,4,2,0,0)  
 + " : " + num2str(AreaRegistered,4,2,0,0));  
 FirstRun = False;  
 }  
 // if (Variety != "" && District != "" && T != "" && V != "")  
 // {  
 info ("PS # " +InventColor::find(Variety,Crop).Name+ " : " + _District::find(District)._DistrictName+ " : " + _T::find(T)._TNam+ " : " + _V::find(V)._VName+ " : " + num2str(NoOfSP,4,2,0,0)+ " : " + num2str(AreaRegistered,4,2,0,0));  
 // TotalFlag = True;  
 progdetail.executeSection();  
 TotalNoOfSP = NoOfSP + TotalNoOfSP;  
 TotalAreaReg = AreaRegistered + TotalAreaReg;  
 info ("TOTAL # " + Centername + " : " + stage + " : " + season+ " : " + InventTable::find(crop).ItemNam+ " : " + CustTable::find(MPCode).Name+ " : " + num2str(TotalNoOfSP,4,2,0,0)  
 + " : " + num2str(TotalAreaReg,4,2,0,0));  
 // TotalFlag = False;  
 ProgTotal.executeSection();  
 // }  
 return true;  
 }  
 else  
 {  
 info("Select TechYear");  
 return False;  
 }  
 }  

Popular posts from this blog

Code to get customer Primary Address in Ax 2012

Below Code to get customer Primary Address in Ax 2012. CustTable custTable_P; DirPartyTable dirPartyTable_P; DirPartyLocation dirPartyLocation_P; DirPartyLocationRole dirPartyLocationRole_P; LogisticsLocation logisticsLocation_P; LogisticsLocationRole logisticsLocationRole_P; LogisticsPostalAddress logisticsPostalAddress_P; LogisticsPostalAddress primaryAddress_P; while select custTable_P where custTable_P.AccountNum =='ED_01029' join dirPartyTable_P where dirPartyTable_P.RecId == custTable_P.Party join dirPartyLocation_P where dirPartyLocation_P.Party == custTable_P.Party && dirPartyLocation_P.IsPrimary==NoYes::Yes join dirPartyLocationRole_P where dirPartyLocationRole_P.PartyLocation == dirPartyLocation_P.RecId join logisticsLocationRole_P where logisticsLocationRole_P.RecId == dirPartyLocationRole...

Table lists which can have large number of records in Ax 2012

If you are facing database or application performance issue then you can check these tables that may have large number of records. ECORESPRODUCTVARIANTDIMENSIONVALUE INVENTBATCH ECORESPRODUCTMASTERDIMENSIONVALUE ECORESPRODUCTMASTERDIMENSIONVALUE ECORESPRODUCT ECORESPRODUCTTRANSLATION ECORESPRODUCT ECORESPRODUCTVARIANTDIMENSIONVALUE INVENTDIMCOMBINATION ECORESRELEASESESSIONPRODUCT ECORESRELEASEPRODUCTLEGALENTITY INVENTSUMLOGTTS INVENTCOSTLISTPARM GENERALJOURNALACCOUNTENTRY GENERALJOURNALACCOUNTENTRYZAKAT_SA SMMTRANSLOG LEDGERENTRYJOURNALIZING DIMENSIONFOCUSBALANCE MARKUPTRANS INVENTTRANSPOSTING INVENTREPORTDIMHISTORY SALESPARMLINE SOURCEDOCUMENTLINE INVENTTRANS TRANSACTIONLOG INVENTTRANSORIGIN INVENTSETTLEMENT SALESPARMSUBTABLE SALESPARMTABLE SOURCEDOCUMENTHEADER SALESPARMUPDATE SQLSYNCINFO GENERALJOURNALENTRY SUBLEDGERVOUCHERGENERALJOURNALENTRY CUSTSETTLEMENT SMMACTIVITYPARENTLINKTABLE INVENTSUMDATETRANS LEDGERTRANSSTATEMENTTMP DIMENSIONFOCUSLE...

Code to get Invoice settlement data for customer in ax 2012

This is simple Code to get Invoice settlement amount data for customer payment in ax 2012. This data is after posting of data. select sum(SettleAmountCur) from custSettlement where custSettlement.TransRecId == custtrans.RecId If you want get settlement amount before posting than you can refer spectrans table.The table SpecTrans contains all the transactions marked for settlement for payment journal. while select spectrans join custtransopen join custtrans where spectrans.SpecCompany == ledgerjournaltrans.DataAreaId && spectrans.SpecTableId == ledgerjournaltrans.TableId && spectrans.SpecRecId == ledgerjournaltrans.RecId && spectrans.RefCompany == custtranssopen.DataAreaId && spectrans.RefTableId == custtranssopen.TableId && spectrans.RefRecId == custtranssopen.RecId && custtransopen.RefRecId == custtrans.RecId && custtransopen.AccountNum == custtrans.AccountNum { info...