Skip to Content
0
Former Member
Dec 17, 2007 at 04:26 PM

Delivery (oDeliveryNotes) to Save as Draft A/R Invoice (oDrafts)

391 Views

Hi,

I am reading all open delivery documents and Save them as Draft A/R Invoice. The code is running, but I do not find my Draft documents, os there are some code missing: Could you help me?

#region Tab 2 - Delivery Document transfer to Save as Draft A/R Invoice

public void TransferDeliveryToInvoiceTab2()

{

SAPbobsCOM.Documents oDocumentsDelivery;

SAPbobsCOM.Documents oDocumentsInvoiceARDraft2;

int intDocEntry;

oDocumentsDelivery = ( SAPbobsCOM.Documents ) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes); // Init the Documents Delivery object

oDocumentsInvoiceARDraft2 = ( SAPbobsCOM.Documents ) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts); // Init the Documents Invoice A/R Draft object

for ( int i = 0; i <= oGrid.Rows.Count - 1; i++ )

{

if ( ( ( SAPbouiCOM.CheckBoxColumn ) oGrid.Columns.Item(1) ).IsChecked(i) )

{

intDocEntry = ( int ) oGrid.DataTable.GetValue((0), i);

if ( oDocumentsDelivery.GetByKey(intDocEntry) )

{

oDocumentsInvoiceARDraft2.CardCode = oDocumentsDelivery.CardCode;

oDocumentsInvoiceARDraft2.DocDate = System.DateTime.Today;

oDocumentsInvoiceARDraft2.DocObjectCodeEx = Convert.ToString(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);

for ( int j = 0; j <= oDocumentsDelivery.Lines.Count - 1; j++ )

{

oDocumentsInvoiceARDraft2.Lines.SetCurrentLine(j);

oDocumentsDelivery.Lines.SetCurrentLine(j);

oDocumentsInvoiceARDraft2.Lines.ItemCode = oDocumentsDelivery.Lines.ItemCode;

oDocumentsInvoiceARDraft2.Lines.Quantity = oDocumentsDelivery.Lines.Quantity;

oDocumentsInvoiceARDraft2.Lines.BaseEntry = oDocumentsDelivery.DocEntry;

oDocumentsInvoiceARDraft2.Lines.BaseType = 13;

oDocumentsInvoiceARDraft2.Lines.BaseLine = oDocumentsDelivery.Lines.LineNum;

oDocumentsInvoiceARDraft2.Lines.Add();

}

// Close Delivery Document

intDocEntry = oDocumentsDelivery.Close();

if ( intDocEntry != 0 )

{

// Do something...???

}

}

}

}

}

#endregion