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

strScan and Find a first occurrence of a string in a string using x++

strScan (Find a first occurrence of a string in a string) info("int strScan(str _text1,str _text2,int _position,int _number)"); info("Searches a text string for the occurrence of another string."); info("_text1 - The text string to search."); info("_text2 - The string to find."); info("_position - The position at which the search should start."); info("_number - The number of characters that should be searched."); info(int2str(strScan("ABCDEFGHIJ","DE",1,10)));

Get record from table on the basis of field id in Microsoft dynamics axapta x++

How to Get record from table on the basis of field id in dynamics axapta x++. just try following code in job to understand better way. emplTable emplTable; FieldId fieldId; ; fieldId = fieldNum(emplTable, Emplid); select emplTable; info(emplTable.(fieldId)); select emplTable where emplTable.(fieldId) == '1101'; info(emplTable.Name);

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