PdcCalculation.Add: Difference between revisions
Jump to navigation
Jump to search
Created page with "== Declaration == Add as PdcCalculation == Description == Returns an new added calculation object == Notes == This property will add a new subcalculation To change the ..." |
|||
Line 20: | Line 20: | ||
objSubCalc.Material.SetPos 5 | objSubCalc.Material.SetPos 5 | ||
objSubCalc.Material.NeededForOperation = 20 | objSubCalc.Material.NeededForOperation = 20 | ||
</source> | |||
If PdcCalculation.Add is being used in combination with Children (Children.Add), the following method can be used to correct DO_MOEDER: | |||
<source lang="vb"> | |||
Sub AddChild(MainCalc, SubCalc) | |||
Dim objCalc, | |||
Dim objSubCalc | |||
Dim objMainCalc | |||
Dim strMother | |||
Set objCalc = pdc.OpenCalculation(MainCalc) | |||
if IsValid(objCalc) then | |||
Set objSubCalc= objCalc.children.add | |||
objSubCalc.Read(SubCalc) | |||
objCalc.Save | |||
set objMainCalc = objCalc | |||
if IsValid(objMainCalc) then | |||
do while IsValid(objMainCalc.Parent) | |||
set objMainCalc = objMainCalc.Parent | |||
loop | |||
strMother = objMainCalc.CalculationNo | |||
end if | |||
Set objCalc = nothing | |||
Set objSubCalc = nothing | |||
sCheckDM_MATLINES strMother, strMother | |||
end if | |||
End Sub | |||
'------------------------------------------------------------------------------- | |||
Sub sCheckDM_MATLINES(strHighestCalcNr, strMotherCalcNr) | |||
dim qryGetMatLines | |||
set qryGetMatLines = pdc.Database.OpenQuery(PdcConData) | |||
qryGetMatLines.SQL = "select * from DM_MATLINES where DM_ORDNR = '" & strHighestCalcNr & "'" | |||
if qryGetMatLines.Execute then | |||
if qryGetMatLines.RecordCount > 0 then | |||
qryGetMatLines.FirstRecord | |||
do while not qryGetMatLines.EoF | |||
sUpdateDO_MOEDER qryGetMatLines.GetField("DM_MATN"), strMotherCalcNr | |||
qryGetMatLines.NextRecord | |||
loop | |||
sCheckDM_MATLINES qryGetMatLines.GetField("DM_MATN"), strMotherCalcNr | |||
end if | |||
else | |||
msgbox pdc.LastError | |||
end if | |||
End Sub | |||
'------------------------------------------------------------------------------- | |||
Sub sUpdateDO_MOEDER(rstrCalcNr, rstrMotherCalcNr) | |||
dim tblDO_Calc | |||
set tblDO_Calc = pdc.Database.OpenTable(PdcConData, "DO_CALC", "DO_ORDNR") | |||
if tblDO_Calc.Locate("DO_ORDNR", rstrCalcNr) then | |||
tblDO_Calc.EditRecord | |||
tblDO_Calc.SetField "DO_MOEDER", rstrMotherCalcNr | |||
tblDO_Calc.PostRecord | |||
end if | |||
End Sub | |||
</source> | </source> | ||
== Availability == | == Availability == |
Revision as of 08:04, 24 May 2012
Declaration
Add as PdcCalculation
Description
Returns an new added calculation object
Notes
This property will add a new subcalculation To change the quantity, posnumber and the operation use the Material property
Code example
dim objCalc
dim objSubCalc
set objCalc = pdc.ActiveCalculation
set objSubCalc = objCalc.Children.Add
objSubCalc.Material.Number = 3
objSubCalc.Material.SetPos 5
objSubCalc.Material.NeededForOperation = 20
If PdcCalculation.Add is being used in combination with Children (Children.Add), the following method can be used to correct DO_MOEDER:
Sub AddChild(MainCalc, SubCalc)
Dim objCalc,
Dim objSubCalc
Dim objMainCalc
Dim strMother
Set objCalc = pdc.OpenCalculation(MainCalc)
if IsValid(objCalc) then
Set objSubCalc= objCalc.children.add
objSubCalc.Read(SubCalc)
objCalc.Save
set objMainCalc = objCalc
if IsValid(objMainCalc) then
do while IsValid(objMainCalc.Parent)
set objMainCalc = objMainCalc.Parent
loop
strMother = objMainCalc.CalculationNo
end if
Set objCalc = nothing
Set objSubCalc = nothing
sCheckDM_MATLINES strMother, strMother
end if
End Sub
'-------------------------------------------------------------------------------
Sub sCheckDM_MATLINES(strHighestCalcNr, strMotherCalcNr)
dim qryGetMatLines
set qryGetMatLines = pdc.Database.OpenQuery(PdcConData)
qryGetMatLines.SQL = "select * from DM_MATLINES where DM_ORDNR = '" & strHighestCalcNr & "'"
if qryGetMatLines.Execute then
if qryGetMatLines.RecordCount > 0 then
qryGetMatLines.FirstRecord
do while not qryGetMatLines.EoF
sUpdateDO_MOEDER qryGetMatLines.GetField("DM_MATN"), strMotherCalcNr
qryGetMatLines.NextRecord
loop
sCheckDM_MATLINES qryGetMatLines.GetField("DM_MATN"), strMotherCalcNr
end if
else
msgbox pdc.LastError
end if
End Sub
'-------------------------------------------------------------------------------
Sub sUpdateDO_MOEDER(rstrCalcNr, rstrMotherCalcNr)
dim tblDO_Calc
set tblDO_Calc = pdc.Database.OpenTable(PdcConData, "DO_CALC", "DO_ORDNR")
if tblDO_Calc.Locate("DO_ORDNR", rstrCalcNr) then
tblDO_Calc.EditRecord
tblDO_Calc.SetField "DO_MOEDER", rstrMotherCalcNr
tblDO_Calc.PostRecord
end if
End Sub