@NateS
I want to clear the data before we save new data for weekly report every weekend will run the screen once again
@Mark_Wonsil
frequency maybe once a week
this deletion doesn’t affect others i’m sure
my company use ud01 table to store BOM (adapterEngWorkBench.ViewCosts) to get data as weekly or monthly report
EngWorkBenchAdapter adapterEngWorkBench ;
adapterEngWorkBench = new EngWorkBenchAdapter(this.oTrans);
adapterEngWorkBench.BOConnect();
//adapterEngWorkBench.BOConnect();
int key=1;
DataTable tbl = GetBAQData(“DMS_GetAllPart”);
string Part=“”;
string Rev=“”;
string PartParent=“”;
string BomSequence=“”;
for(int a=0;a<tbl.Rows.Count;a++)
{
//if(Part!=tbl.Rows[a][“Part_PartNum”].ToString()&&Rev!=tbl.Rows[a][“PartRev_RevisionNum”].ToString())
//{
session.PlantID=tbl.Rows[a][“Part_Plant_Plant”].ToString();
adapterEngWorkBench = new EngWorkBenchAdapter(this.oTrans);
adapterEngWorkBench.BOConnect();
string ipGroupID = String.Empty;
string ipPartNum = tbl.Rows[a][“Part_PartNum”].ToString();
string ipRevisionNum = tbl.Rows[a][“PartRev_RevisionNum”].ToString();
string ipAltMethod = String.Empty;
System.DateTime ipAsOfDate = DateTime.Now;
//Convert.ToDateTime(tbl.Rows[a][“PartRev_EffectiveDate”].ToString());
decimal ipQuantity = 1.0M;
int ipMaxLevel = 999;
bool ipAssembliesOnly = false;
bool isApproved = Convert.ToBoolean(tbl.Rows[a][“PartRev_Approved”]);
// Call Adapter method
bool result = adapterEngWorkBench.ViewCosts(ipGroupID, ipPartNum, ipRevisionNum, ipAltMethod, ipAsOfDate, ipQuantity, ipMaxLevel, ipAssembliesOnly);
{
int BomLevelPre=0;
int BomLevelCur=0;
string PartParentCur=“”;
//string PartParentPre=“”;
List PartPar=new List(); //Part Parent
List Bomseq=new List(); //Bom Sequence Part Parent
for(int i=0;i<adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows.Count;i++)
{
result = adapterUD01.GetaNewUD01();
if(result)
{
string
PartArr = adapterEngWorkBench.EngWorkBenchCostData.Tables[“PartRevCostsDetail”].Rows[i][“MtlPartNum”].ToString().Split(‘.’);
int PartIndex=PartArr.Length-1;
BomLevelCur=Convert.ToInt32(adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BOMLevel”]);
if(Convert.ToInt32(adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BOMLevel”])==0||Convert.ToInt32(adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BOMLevel”])==1)
{
PartParent=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“PartNum”].ToString();
BomSequence=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[0][“BomSequence”].ToString();
BomLevelPre=Convert.ToInt32(adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BOMLevel”]);
if(BomLevelPre==1)
{
PartPar=new List();
Bomseq=new List();
PartParentCur=PartArr[PartIndex];
PartPar.Add(PartArr[PartIndex]);
Bomseq.Add(adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BomSequence”].ToString());
}
//BomLevelCur=0;
}
else{
if(BomLevelCur>BomLevelPre)
{
if(BomLevelCur>PartPar.Count)
{
PartPar.Add(PartArr[PartIndex]);
Bomseq.Add(adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BomSequence”].ToString());
}
else{
PartPar[BomLevelCur-1]=PartArr[PartIndex];
Bomseq[BomLevelCur-1]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BomSequence”].ToString();
}
}
else if(BomLevelPre==BomLevelCur)
{
PartPar[BomLevelPre-1]=PartArr[PartIndex];
Bomseq[BomLevelPre-1]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BomSequence”].ToString();
}
else{
PartPar[BomLevelCur-1]=PartArr[PartIndex];
Bomseq[BomLevelCur-1]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i][“BomSequence”].ToString();
}
PartParent=PartPar[BomLevelCur-2];
BomSequence=Bomseq[BomLevelCur-2];
BomLevelPre=BomLevelCur;
}
adapterUD01.UD01Data.UD01.Rows[0]["Company"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["Company"];
int l=key.ToString().Length;
string Mykey="000000000"+key.ToString();
adapterUD01.UD01Data.UD01.Rows[0]["Key1"]=string.Format("{0}",Mykey.Remove(0,l));
adapterUD01.UD01Data.UD01.Rows[0]["Key2"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["PartNum"];
adapterUD01.UD01Data.UD01.Rows[0]["Key3"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["RevisionNum"];
adapterUD01.UD01Data.UD01.Rows[0]["Key4"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["MtlPartNum"];
adapterUD01.UD01Data.UD01.Rows[0]["Key5"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["BOMLevel"];
adapterUD01.UD01Data.UD01.Rows[0]["Character01"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["Quantity"];
adapterUD01.UD01Data.UD01.Rows[0]["Character03"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["BOMType"];
adapterUD01.UD01Data.UD01.Rows[0]["Character04"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["MaterialCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Character05"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["LaborCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Character06"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["BurdenCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Character07"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["SubcontractCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Character08"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["BomSequence"];
adapterUD01.UD01Data.UD01.Rows[0]["Character09"]=PartArr[PartIndex];
adapterUD01.UD01Data.UD01.Rows[0]["Character10"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["PartDescription"];
adapterUD01.UD01Data.UD01.Rows[0]["Number01"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["MaterialBurdenCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number02"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["TotalCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number03"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["MaterialUnitCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number04"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["LaborUnitCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number05"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["BurdenUnitCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number06"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["SubcontractUnitCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number07"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["MaterialBurdenUnitCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number08"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["TotalUnitCost"];
adapterUD01.UD01Data.UD01.Rows[0]["Number09"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["QtyPer"];
adapterUD01.UD01Data.UD01.Rows[0]["Number10"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["RequiredQty"];
adapterUD01.UD01Data.UD01.Rows[0]["Number11"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[0].Rows[0]["MaxLevel"];
adapterUD01.UD01Data.UD01.Rows[0]["Date01"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["EffectiveDate"];
adapterUD01.UD01Data.UD01.Rows[0]["ShortChar01"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["MtlRevision"];
adapterUD01.UD01Data.UD01.Rows[0]["ShortChar02"]=tbl.Rows[a]["PartRev_Plant"].ToString();
adapterUD01.UD01Data.UD01.Rows[0]["ShortChar03"]=PartParent;
adapterUD01.UD01Data.UD01.Rows[0]["ShortChar04"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["PartNum"].ToString()+adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["RevisionNum"].ToString()+PartParent+BomSequence;;
adapterUD01.UD01Data.UD01.Rows[0]["ShortChar05"]=adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["PartNum"].ToString()+adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["RevisionNum"].ToString()+PartArr[PartIndex]+adapterEngWorkBench.EngWorkBenchCostData.Tables[1].Rows[i]["BomSequence"].ToString();
adapterUD01.UD01Data.UD01.Rows[0]["CheckBox01"]=isApproved;
adapterUD01.UD01Data.UD01.Rows[0]["Character02"]=isApproved;
adapterUD01.UD01Data.UD01.Rows[0]["Date02"]= DateTime.Today;
adapterUD01.Update();
}
else
{
PartError += ipPartNum +", ";
}
adapterUD01.UD01Data.Clear();
//adapterUD01.Dispose();
key+=1;
}
}
adapterEngWorkBench.EngWorkBenchCostData.Clear();
adapterEngWorkBench.Dispose();
//Part=tbl.Rows[a]["Part_PartNum"].ToString();
//Rev=tbl.Rows[a]["PartRev_RevisionNum"].ToString();
PartParent="";
BomSequence="";
//}
// Cleanup Adapter Reference
}
adapterUD01.Dispose();
Thank you so much have a nice day!