cancel
Showing results for 
Search instead for 
Did you mean: 

How to production with DI API

Johan_H
Active Contributor
0 Kudos

Hi,

I need to do production using the DI API, and I have not done this before. There is no example code in the SDK for this process, so I am hoping someone can steer me in the right direction.

A specific requirement is that I need to change the cost price of one component each time.

All answers, and any advice or suggestions are most welcome.

Following the steps as in the B1 client, I suppose I would have to go about it like this(?):

  1. Open the relevant BOM, and change the price of the relevant component
  2. Create a new Production Order with status planned
  3. Add the Production Order
  4. Get it back with GetByKey and set it to status released.
  5. Create a Receipt From Production
    a. interface WorkOrders > BoObjectTypes.oWorkOrders ?
    b. if so, how do I draw from the Production Order, or is this even possible?
    c. example code for this step would be great.
  6. Add the Receipt From Production
  7. Get the Production Order back with GetByKey and set it to status closed.

Are there any steps I can skip?

Regards,

Johan

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Dear johan.hakkesteegt,

For Production Order, you need to use ProductionOrders object.

SAPbobsCOM.ProductionOrders oPO = (SAPbobsCOM.ProductionOrders)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);
oPO.ItemNo = "S10000";
oPO.PlannedQuantity = 2;
int APO = oPO.Add();

For Receipt From Production, you need to use Documents object.

SAPbobsCOM.Documents oReceiptFromProduction = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry);
oReceiptFromProduction.Lines.BaseEntry = 153;
oReceiptFromProduction.Lines.BaseType = 202;
oReceiptFromProduction.Lines.Quantity = 1;
oReceiptFromProduction.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntComplete;
oReceiptFromProduction.Lines.WarehouseCode = "01";
int ARPO = oReceiptFromProduction.Add();

Will those help for your cause?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Johan_H
Active Contributor
0 Kudos

Hi Ankit,

Thank you so much for this. This is perfect, but would you clarify a few things for me?

About the code example for the Production Order:

  1. You have not set the ProductionOrderType property. Is the default value BoProductionOrderTypeEnum.bopotStandard?
  2. You have not set the ProductionOrderStatus property. Is the default value BoProductionOrderStatusEnum.boposPlanned?

About the code example for Receipt From Production:

  1. You have not used the BaseLine property. Is it not needed, even when there are multiple components? Will the BOM take care of all that? In other words, am I drawing the header of the Production Order?
  2. Does oReceiptFromProduction.Lines.Quantity correspond to oPO.PlannedQuantity?
  3. Do I need to explicitly set oReceiptFromProduction.Lines.WarehouseCode?
  4. Once I have added the Receipt From Production, will the Production Order be closed automatically?

Regards,

Johan

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Dear johan.hakkesteegt,

The idea was to make you aware about the DI objects. The provided sample codes are just vague examples. You may need to add or remove properties based on your requirements.

You can always explicitly set ProductionOrderType and ProductionOrderStatus.

About Receipt From Production, in my case:

1. Yes, It was drawing the header of the Production Order (Product No. on Production Order screen), therefore, I didn't use the BaseLine property.

2. Yes, ReceiptFromProduction.Lines.Quantity corresponds to oPO.PlannedQuantity. You will get the details about the Quantities on the Summary tab of Production Order once Receipt from Production is added.

3. If you do not want to change Warehouse, no need to use it.

4. No, you will have to close the Production Order.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Johan_H
Active Contributor
0 Kudos

Thanks ankit.chauhan1, it is very much appreciated!

Answers (1)

Answers (1)

former_member874547
Discoverer
0 Kudos

hey, this is my code:

using SAPbobsCOM;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace ConexionSAPB1

{

public partial class ConexionSAP : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (ConexioSAP.Open())

{

Linfo.Text = "conexion exitosa a SAP";

Linfo.Visible = true;

}

}

protected void BtnConexion_Click(object sender, EventArgs e)

{

if (ConexioSAP.Open())

{

Linfo.Text = "conexion exitosa a SAP";

Linfo.Visible = true;

}

}

protected void BtnProduccion_Click(object sender, EventArgs e)

{

ProductionOrders wo = ConexioSAP.mycompany.GetBusinessObject(BoObjectTypes.oProductionOrders) as ProductionOrders;

wo.ItemNo = "SILO AZ.";

wo.DueDate = DateTime.Now.AddMonths(1);

wo.ProductionOrderType = BoProductionOrderTypeEnum.bopotSpecial;

wo.PlannedQuantity = 6;

wo.Lines.ItemNo = "LLDPE";

wo.Lines.Add();

wo.Lines.SetCurrentLine(1);

wo.Lines.ItemNo = "COLOR. AZ.";

wo.Lines.Add();

wo.Lines.SetCurrentLine(2);

int retVal = wo.Add();

if (retVal != 0)

{

string errorMessage = ConexioSAP.mycompany.GetLastErrorDescription();

Linfo.Text = "Ocurrió un error al ingresar la orden de fabricación: " + errorMessage.ToString();

}

else

{

Linfo.Text = "Se ha ingresado correctamente la orden de fabricación";

}

}

}

}

it works perfect but i need to automize the most i can, someone knows how to automize the components auto fill?, because i have like 60 products and each one have like 3 components and its a big word to add one per one, and my boss will love me if i can automize it.

thank you

Johan_H
Active Contributor
0 Kudos

Hi,

Adding a lot of BOMs and/or Production Orders, is easier with the Data Transfwer Workbench.

Doing it with code is only necessary if you have some special requirements.

Regards,

Johan