Skip to Content
0
Former Member
Mar 31, 2016 at 04:34 PM

Añadir/Actualizar materiales en orden de produccion con DI api v 9.0

1368 Views

Hola amigos

si alguien me pudiera ayudar soy nuevo en el desarrollo sap

tengo una orden de producción y estoy tratando de añadirle materiales nuevos o actulizar los que ya existen y lo que me hace siempre es modificar el primero y si hay mas solo deja uno

el problema ocurre en

oProductionOrder.Lines.Add();

ValRet = oProductionOrder.Update();

este es el codigo completo

SAPbobsCOM.ProductionOrders oProductionOrder = null;

SAPbobsCOM.Recordset oRs = null;

oRs = (SAPbobsCOM.Recordset)SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

oProductionOrder = SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);

oProductionOrder.GetByKey(DocEntry);

oProductionOrder.Lines.Warehouse = Warehouse;

QtyIss = QtyIssued(SBOCompany, DocEntry);

oRs.DoQuery("SELECT VisOrder, LineNum FROM WOR1 WHERE DocEntry = " + DocEntry.ToString() + " AND ItemCode = '" + ItemCode + "'");

if (oRs.RecordCount != 0)

{

oProductionOrder.Lines.SetCurrentLine(oRs.Fields.Item("VisOrder").Value);

if ((RealQuantity + QtyIss) > oProductionOrder.Lines.PlannedQuantity)

{

oProductionOrder.Lines.PlannedQuantity = RealQuantity + QtyIss ;

oProductionOrder.Lines.Add();

ValRet = oProductionOrder.Update();

#region Validates if there was an error Updating Production Order

if (ValRet != 0)

{

SBOCompany.GetLastError(out ValRet, out sErrMsg);

}

#endregion Validates if there was an error Updating Production Order

}

BaseLine = oRs.Fields.Item("LineNum").Value;

}

else

{

if ((RealQuantity + QtyIss) > oProductionOrder.Lines.PlannedQuantity)

{

oProductionOrder.Lines.PlannedQuantity = RealQuantity + QtyIss;

oProductionOrder.Lines.ItemNo = ItemCode;

oProductionOrder.Lines.Add();

ValRet = oProductionOrder.Update();

#region Validates if there was an error Updating Production Order

if (ValRet != 0)

{

SBOCompany.GetLastError(out ValRet, out sErrMsg);

}

#endregion Validates if there was an error Updating Production Order

}

}