cancel
Showing results for 
Search instead for 
Did you mean: 

minimum fields required to create an order

Former Member
0 Kudos

Hi, anyone know what the minimum fields required are to create an order?

I've tried to copy what the sample does, but it still gives me an internal error.

Our system doesn't use TaxCodes, but it has VatGroups is that going to be an issue?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Victor,

Try to Add Order from front end(in bone client) with the values you are providing to DIAPI object .

if it adds there then there is some problem in your code.

If you are able to add through front end then please paste your code here if you can,so that we can trace out the problem

Hope it helps you

Regards

Vishnu

Former Member
0 Kudos

I have the SAP B1 client is that what you mean by "bone client"?

I can't run the sample order application as the app.config file is missing.

Former Member
0 Kudos

Hello Victor,

He means that you must run one of the examples (..\SAP\SAP Business One SDK\Samples\COM DI\VB.NET\05.OrderAndInvoice) from a sbo client. Usally a developer has a server and client installed on the developmentsystem.

You can take a look at these samples and try to change some things or debug with breakpoints.

I don't know it exactly but I think cardcode, docduedate, itemcode and quantity are mandatory for a order.

Good luck!

Regards,

Teun Aben

Former Member
0 Kudos

EDIT: it turns out the database user we used did not have enough priviledges.

ok I have tried using the sample bone client and it works. I've tried to make mine to imitate what the bone client is doing, but I'm still getting a "-1 Could not commit transaction"

Here is the code which tries to create the order.

int i, lRetCode, temp, errCode;

string strDocEntry, errMsg;

oBusinessPartner = (BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);

SAPbobsCOM.Documents oOrderDoc;

oOrderDoc = (Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);

if (oBusinessPartner.GetByKey(customerCode))

{

// order details

oOrderDoc.DocNum = docNum;

oOrderDoc.CardCode = customerCode;

oOrderDoc.CardName = customerName;

oOrderDoc.DocDueDate = Convert.ToDateTime(deliveryDate);

oOrderDoc.DocDate = Convert.ToDateTime(orderDate);

oOrderDoc.DocCurrency = "AUD";

oOrderDoc.NumAtCard = "OrderTest";

oOrderDoc.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;

// process order items

for (i = 0; i < Items.Count; i++)

{

oOrderDoc.Lines.ItemCode = order.Items<i>.Id;

oOrderDoc.Lines.ItemDescription = order.Items<i>.Name;

oOrderDoc.Lines.Quantity = order.Items<i>.Qty;

oOrderDoc.Lines.Price = Convert.ToDouble(order.Items<i>.Price);

oOrderDoc.Lines.TaxCode = "";

oOrderDoc.Lines.LineTotal = Convert.ToDouble(order.Items<i>.Price)*order.Items<i>.Qty;

// if on the last item calling this will add a blank row

if (i != 0)

oOrderDoc.Lines.Add();

}

// submit order

lRetCode = oOrderDoc.Add();

// error handling

if (lRetCode != 0)

{

oCompany.GetLastError(out errCode, out errMsg);

// error

lblStatus.Text = errCode + " " + errMsg;

}

else

{

oCompany.GetNewObjectCode(out strDocEntry);

temp = Convert.ToInt32(strDocEntry);

//success

lblStatus.Text = "Order added";

}

}

What's funny is that if I click on submit again, it comes up with the error "-2039 [ RDR1.WhcCode ][ line: 1 ] ,'Another user-modified table' (ODBC -2039)"

and when I check the ORDR table and the order looks like it was entered.

Any ideas?

Edited by: Victor Tran on Jan 5, 2008 8:34 AM

Edited by: Victor Tran on Jan 5, 2008 10:10 AM

Answers (0)