PdcMaterialFile.WriteOff: Difference between revisions

From External Bemet Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 3: Line 3:


== Description ==
== Description ==
This method writes off a stock line (with certificate) for a specific material number on a calculation.
== Notes ==
CalcNo  = Calculation number (DO_ORDNR).<br/>
CalcNo  = Calculation number (DO_ORDNR).<br/>
MatPos  = Material position (DM_POS).<br/>
MatPos  = Material position in the calculation (DM_POS).<br/>
MatID    = Material ID (DM_ID).<br/>
MatID    = Material ID in the calculation (DM_ID).<br/>
MatNo    = Material number (DM_MATN).<br/>
MatNo    = Material number (LM_MATN).<br/>
StockID  = The stockline ID (LMV_ID.<br/>
StockID  = The stockline ID (LMV_ID).<br/>
Quantity = The quantity to write off.<br/>
Quantity = The quantity to write off.<br/>


This set of parameters writes off a quantity on a calculation:
This sets of parameters writes off a quantity on a calculation:<br/>
1. You have to apply the parameters CalcNo, MatPos, MatNo, StockID and Quantity) or (DM_ID and DM_MATN).
1. You have to apply the parameters CalcNo, MatPos, MatNo, StockID and Quantity.<br/>
 
2. You have to apply the parameters MatID, MatNo, StockID and Quantity.<br/>
a. DO_ORDNR, DM_POS or DM_ID are required to define the position in a calculation.
<br/>
b. A material number is required, because on 1 position in a calculation, you can write off several different materials (numbers). This call only change stock lines and reservations for 1 material number for 1 position in a calculation.
This method writes off the quantity and deduct the existing reservation. The reservation is removed when the remaining quantity is zero.<br/>
When more reservations are created for one position (With a different material number), only 1 is changed (and removed). The second one you have to remove in your script.
Write off a material with a different number than the forecast is possible.<br/>
2. You have to apply always LMV_ID and Quantity. The script must change a certificate number into a stock line ID.
A stock history line is also created with this method.<br/>
This command does:
1. Write off the stock line and if remaining quantity is zero, the stock line is removed. Only for one material number.
This function adjusts the sourcing strategy for materials in Fparts according to the input paramater booStock (preferably the value of LM_MAT.LM_VR).
Reduce the reservation and if remaining quantity is zero, the
reservation is removed. Only for one material number.
3. Create a stock history line like standard PdC do. This line is the post calculation for the quantity and the value of that position in the calculation.
== Notes ==
When changing a material's stock strategy in PdC, user is presented with the option to adjust all Fparts the material is incorporated in. This function executes that functionality from vbScript.
Note that any checks required for setting a material to non-stocked (outstanding reservation, purchase order lines and existing stock position) need to be carried out in the script it self!


== Code example ==
== Code example ==
Adjust a material's  sourcing strategy.
Write off 10 m of material "BU.050.050.RVS309" on calculation "01483".


<source lang="vb">
<source lang="vb">
Sub btn_SelectMatNrClick(Sender)
dim strCalcNo
  edt_MatNr.Text = pdc.ChooseRecord(36, "", "")
dim strMatPos
End Sub
dim lngMatID
dim strMatNo
dim strStockID
dim dblQnty


Sub btn_CheckSourcesClick(Sender)
  strCalcNo  = "01483"
dim booResult
   strMatPos = "0001"
dim booStock
  lngMatID  = 0
   booStock = (GetAnyField("LM_MAT", "LM_MATN", edt_MatNr.Text, "LM_VR") = "J")
  strMatNo  = "BU.050.050.RVS309"
   booResult = pdc.MasterData.MaterialFile.CheckSourceFPart(edt_MatNr.Text, booStock)
  strStockID = 7
  msgbox "CheckSourceFPart = " & booResult
   dblQnty    = 10
End Sub
  if pdc.MasterData.MaterialFile.WriteOff(strCalcNo, strMatPos, lngMatID, strMatNo, strStockID, dblQnty) then
    msgbox "Write off completed."
  else
    msgbox pdc.LastError
  end if
</source>
</source>


== Availability ==
== Availability ==
Available since Jsnuary 2013 (4.3).
Available since 20 June 2014 (4.3 and 5.1). 5.1 onwards, this function is removed, because other functionality is build with other methods.

Latest revision as of 08:13, 20 June 2014

Declaration

WriteOff(CalcNo as String, MatPos as String, MatID as long, MatNo as string, StockID as long, Quantity as double) as Boolean

Description

This method writes off a stock line (with certificate) for a specific material number on a calculation.

Notes

CalcNo = Calculation number (DO_ORDNR).
MatPos = Material position in the calculation (DM_POS).
MatID = Material ID in the calculation (DM_ID).
MatNo = Material number (LM_MATN).
StockID = The stockline ID (LMV_ID).
Quantity = The quantity to write off.

This sets of parameters writes off a quantity on a calculation:
1. You have to apply the parameters CalcNo, MatPos, MatNo, StockID and Quantity.
2. You have to apply the parameters MatID, MatNo, StockID and Quantity.

This method writes off the quantity and deduct the existing reservation. The reservation is removed when the remaining quantity is zero.
Write off a material with a different number than the forecast is possible.
A stock history line is also created with this method.

Code example

Write off 10 m of material "BU.050.050.RVS309" on calculation "01483".

dim strCalcNo
dim strMatPos
dim lngMatID
dim strMatNo
dim strStockID
dim dblQnty

  strCalcNo  = "01483"
  strMatPos  = "0001"
  lngMatID   = 0
  strMatNo   = "BU.050.050.RVS309"
  strStockID = 7
  dblQnty    = 10
  if pdc.MasterData.MaterialFile.WriteOff(strCalcNo, strMatPos, lngMatID, strMatNo, strStockID, dblQnty) then
    msgbox "Write off completed."
  else
    msgbox pdc.LastError
  end if

Availability

Available since 20 June 2014 (4.3 and 5.1). 5.1 onwards, this function is removed, because other functionality is build with other methods.