Skip to Content
0
Former Member
Feb 28, 2006 at 08:11 AM

Problem in create a oPurchaseDeliveryNotes

181 Views

Hi,

I am trying to create a oPurchaseDeliveryNotes using DI API.

When I create Item oPurchaseDeliveryNotes have problems.

This is the code:

SAPbobsCOM.Documents objDoc;

objDoc = (SAPbobsCOM.Documents) (Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes));

objDoc.CardCode = ObjGrid[0].strVendor;

objDoc.DocDate = Convert.ToDateTime("01/25/2006");

objDoc.DocDueDate = Convert.ToDateTime("01/25/2006");

objDoc.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;

objDoc.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes;

objDoc.DocTotal = dDocTotalValue;

objDoc.UserFields.Fields.Item("U_CMCCId").Value = ObjHeader.iContainerCard;

//objDoc.UserFields.Fields.Item("U_CMSCDN").Value = ObjHeader.strContRev;

//objDoc.SalesPersonCode = 4;

int iPODocNUM = 0;

int iRCount = 0;

for(iRowCounter = 0; iRowCounter < ObjGrid.Length; iRowCounter++)

{

if (iPODocNUM != Convert.ToInt32(ObjGrid[iRowCounter].strPO))

{

iPODocNUM = Convert.ToInt32(ObjGrid[iRowCounter].strPO);

iRCount = 0;

}

if(iRowCounter!= 0)

{

objDoc.Lines.Add();

}

//CreateErrorLog("", "InsertSalesOrderData Grid RowCounter " + iRowCounter , Company);

// Add Line Items

objDoc.Lines.SetCurrentLine(iRCount);

objDoc.Lines.ItemCode = ObjGrid[iRowCounter].strItemNo;//"1014";

objDoc.Lines.ItemDescription = ObjGrid[iRowCounter].strItemDesc;

objDoc.Lines.Quantity = Convert.ToDouble(ObjGrid[iRowCounter].iUnit);

// changed after discussing with Sushant by Naveen on 20/02/2005

objDoc.Lines.Price = Convert.ToDouble(ObjGrid[iRowCounter].dFOBPrice);

objDoc.Lines.BaseEntry = Convert.ToInt32(ObjGrid[iRowCounter].strPO);

objDoc.Lines.BaseType = 20; // Hard Code for the BaseType Purchase Order

objDoc.Lines.BaseLine = ObjGrid[iRowCounter].iPOILineNum;

objDoc.Lines.UserFields.Fields.Item("U_CMPCON").Value = "Y";

// Get Item WareHouse Code

objDoc.Lines.WarehouseCode = GetItemWarehouse(Company,ObjGrid[iRowCounter].strItemNo.ToString());

iRCount++;

}

// Start Transaction

Company.StartTransaction();

ret = objDoc.Add();