Reputation: 55
I made an addon for MRP module of SAP B1 and I am trying to create a production order from order recommendation. I have an error that is "Component Item cannot be phantom Item".
The properties of my items are:
ItemCode : "M1" ,Inventory and Sales Item, Planning method: MRP - Make
ItemCode : "M2" ,it's only Sales Item, Planning method: MRP - Make
ItemCode : "M3" ,Inventory, Sales and Purchase Item, Planning method: MRP - Purchase
And the product tree is M1 --> M2 --> M3
What is the reason of this error? When I try to create production order of M1 on standard MIP without my addon it works succesfully.
Here is the code that is adding production order:
public void createWOrderFor(int id,
string itemCode,
string itemName,
int qty,
int satisSip,
string cardCode,
string cardName,
string releaseDate)
{
DataTable dataTable2 = new DataTable();
using (var connection = new SqlConnection("Server=" + server + ";Database=" + database + ";User Id=" + user + ";Password=" + pass + "; connection timeout=30;"))
{
connection.Open();
var comm = new SqlCommand("select Code, Quantity from ITT1 where Father='" + itemCode + "'", connection);
SqlDataReader dr = comm.ExecuteReader();
if (dr.HasRows)
dataTable2.Load(dr);
}
SAPbobsCOM.ProductionOrders BO_itemP;
BO_itemP = (SAPbobsCOM.ProductionOrders)getCompany().GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders);
SAPbobsCOM.ProductionOrders_Lines BO_item_lines = null;
BO_itemP.PostingDate = DateTime.Now;
BO_itemP.DueDate = DateTime.Parse(releaseDate);
BO_itemP.ItemNo = itemCode;
BO_itemP.PlannedQuantity = qty;
BO_itemP.ProductionOrderType = SAPbobsCOM.BoProductionOrderTypeEnum.bopotSpecial;
int count2 = 0;
foreach (DataRow row2 in dataTable2.Rows)
{
BO_item_lines = BO_itemP.Lines;
BO_itemP.Lines.ItemNo = row2["Code"].ToString();
BO_itemP.Lines.PlannedQuantity = miktar * qty;
BO_itemP.Lines.SetCurrentLine(count2);
count2++;
BO_itemP.Lines.BaseQuantity = miktar * qty;
BO_itemP.Lines.Warehouse = "1100";
BO_itemP.Lines.Add();
}
var retVal = BO_itemP.Add();
String err = base.getCompany().GetLastErrorDescription();
if (!err.Equals("")) { SAPbouiCOM.Framework.Application.SBO_Application.StatusBar.SetText("BO_item Hata: "+err, SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error); }
}
Upvotes: 0
Views: 658
Reputation: 1
You can't create a production order for a "Phantom" component. Your component 'M2' is flagged as sales item only which will set the "Phantom" Flag on the Item Master. If you alter your code to skip phantom items it should work.
Upvotes: 0