cancel
Showing results for 
Search instead for 
Did you mean: 

Material revaluation on batches

pm_witmond
Participant
0 Kudos
634

Hello,

Does anybody have a working example in creating a material revaluation based on batches ?

All I can find is about FIFO but we have to do this on a specific batch.

Thanks,

Paul

View Entire Topic
pm_witmond
Participant
0 Kudos

Hi,

This is the actual working code in c#

MaterialRevaluation oMaterialRevaluation = (MaterialRevaluation)SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(BoObjectTypes.oMaterialRevaluation);

                SAPbobsCOM.SNBLines oMaterialRevaluationSNBLines = default(SAPbobsCOM.SNBLines);

                oMaterialRevaluation.DocDate = System.DateTime.Now;

                oMaterialRevaluation.RevalType = "P";

                oMaterialRevaluation.Comments = "Herwaardering batches";

                oMaterialRevaluation.Lines.ItemCode = ItemCode;

                oMaterialRevaluation.Lines.RevaluationDecrementAccount = reknr;

                oMaterialRevaluation.Lines.RevaluationIncrementAccount = reknr;

                oMaterialRevaluation.Lines.WarehouseCode = "01";

                oMaterialRevaluation.Lines.Quantity = quantity;

                oMaterialRevaluationSNBLines = oMaterialRevaluation.Lines.SNBLines;

                oMaterialRevaluationSNBLines.SetCurrentLine(0);

                oMaterialRevaluationSNBLines.BaseLine = 0;

                oMaterialRevaluationSNBLines.SnbAbsEntry = Convert.ToInt32(rs.Fields.Item(0).Value);

              

                if (Convert.ToDouble(rs.Fields.Item("SaldoBatch").Value) > 0)

                {

                    double newprice = Convert.ToDouble(rs.Fields.Item("BatchPrijsM3").Value) + opslag;

                    oMaterialRevaluationSNBLines.NewCost = newprice;

                    TextOK("Nieuwe waarde : " + newprice);

                }

                if (oMaterialRevaluation.Add() != 0)

                {

                    oMaterialRevaluation.SaveXML(@"c:\temp\omrv.xml");

                    TextError("batch hw");

                }

                else

                    TextOK("batch hw ok");