PdcMaterialFile.WriteOff

From External Bemet Wiki
Revision as of 07:12, 20 June 2014 by TC (talk | contribs)
Jump to navigation Jump to search

Declaration

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

Description

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

This set of parameters writes off a quantity on a calculation: 1. You have to apply the parameters CalcNo, MatPos, MatNo, StockID and Quantity) or (DM_ID and DM_MATN).

a. DO_ORDNR, DM_POS or DM_ID are required to define the position in a calculation. 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. 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. 2. You have to apply always LMV_ID and Quantity. The script must change a certificate number into a stock line ID. 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

Adjust a material's sourcing strategy.

Sub btn_SelectMatNrClick(Sender)
  edt_MatNr.Text = pdc.ChooseRecord(36, "", "")
End Sub

Sub btn_CheckSourcesClick(Sender)
dim booResult
dim booStock
  booStock  = (GetAnyField("LM_MAT", "LM_MATN", edt_MatNr.Text, "LM_VR") = "J")
  booResult = pdc.MasterData.MaterialFile.CheckSourceFPart(edt_MatNr.Text, booStock)
  msgbox "CheckSourceFPart = " & booResult
End Sub

Availability

Available since Jsnuary 2013 (4.3).